2008-01-20 Olivier Dufour <olivier.duff@gmail.com>
authorOlivier Dufour <olivier@mono-cvs.ximian.com>
Sun, 20 Jan 2008 10:07:14 +0000 (10:07 -0000)
committerOlivier Dufour <olivier@mono-cvs.ximian.com>
Sun, 20 Jan 2008 10:07:14 +0000 (10:07 -0000)
* ResXResourceReaderTest.cs: Add tests to check GetNodePosition.

svn path=/trunk/mcs/; revision=93341

mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog
mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXResourceReaderTest.cs

index 3b9d191ef8886366c101626e0136d08b516290b1..1f14ce1913922b195b7987378140ae59fc3c31e8 100644 (file)
@@ -1,7 +1,6 @@
-2007-12-01  Olivier Dufour <olivier.duff@gmail.com>
+2008-01-20  Olivier Dufour <olivier.duff@gmail.com>
 
-       * ResXResourceReaderTest.cs: Add tests to check GetMetadataEnumerator 
-       and UseResXDataNode in the reader.
+       * ResXResourceReaderTest.cs: Add tests to check GetNodePosition.
 
 2007-05-23  Andreia Gaita <avidigal@novell.com>
 
index 1f86e8ae727181a2c652c204f47407967f1fa9b1..340f74eb5c73969376ae6acac80b8386e8b5b108 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Authors:
 //     Gert Driesen <drieseng@users.sourceforge.net>
+//     Olivier Dufour <olivier.duff@gmail.com>
 //
 
 using System;
@@ -16,6 +17,7 @@ using System.Windows.Forms;
 using System.Xml;
 
 using NUnit.Framework;
+using System.Reflection;
 
 namespace MonoTests.System.Resources
 {
@@ -1473,6 +1475,7 @@ namespace MonoTests.System.Resources
                }
 
 #if NET_2_0
+
                [Test]
                public void useResXDataNodes ()
                {
@@ -1496,9 +1499,34 @@ namespace MonoTests.System.Resources
                                ResXDataNode node = enumerator.Value as ResXDataNode;
                                Assert.IsNotNull (node, "#A3");
                                Assert.AreEqual ("foo", node.Name, "#A4");
+                               Bitmap bitmap = node.GetValue (new AssemblyName[] {typeof (Bitmap).Assembly.GetName ()}) as Bitmap;
+                               Assert.IsNotNull (bitmap, "#A5");
+                       }
+               }
+               
+               [Test]
+               public void getPosition()
+               {
+                       string refFile = Path.Combine (_tempDirectory, "32x32.ico");
+                       WriteEmbeddedResource ("32x32.ico", refFile);
+
+                       string resxFile = Path.Combine (_tempDirectory, "resources.resx");
+                       using (StreamWriter sw = new StreamWriter (resxFile, false, Encoding.UTF8)) {
+                               sw.Write (string.Format (CultureInfo.InvariantCulture,
+                                       _resXFileRefTemplate, ResXResourceWriter.ResMimeType, "1.0",
+                                       Consts.AssemblySystem_Windows_Forms, refFile,
+                                       typeof (Bitmap).AssemblyQualifiedName, string.Empty));
+                       }
+
+                       using (ResXResourceReader r = new ResXResourceReader (resxFile)) {
+                               r.UseResXDataNodes = true;
+                               IDictionaryEnumerator enumerator = r.GetEnumerator ();
+                               enumerator.MoveNext ();
+                               ResXDataNode node = enumerator.Value as ResXDataNode;
+                               Assert.IsNotNull (node, "#A1");
+                               Assert.AreEqual(new Point(1, 1020), node.GetNodePosition (), "#A2");
                        }
                }
-               //TODO assemblyNames
 
                [Test]
                public void GetMetadataEnumerator ()
@@ -1519,12 +1547,14 @@ namespace MonoTests.System.Resources
                                enumerator.MoveNext ();
                                Assert.IsNotNull (enumerator.Current, "#A1");
                                Assert.AreEqual ("panel_label.Locked", enumerator.Key, "#A2");
+                               Assert.AreEqual(typeof(bool), enumerator.Value.GetType(), "#A3");
                                bool flag = (bool)enumerator.Value;
-                               Assert.IsNotNull (flag, "#A3");
                                Assert.AreEqual (true, flag, "#A4");
                        }
                }
+
 #endif
+
                [Test]
                public void TypeConversion ()
                {