瀏覽代碼

2009-06-20 Zoltan Varga <[email protected]>

	* *.cs: Convert all tests to new-style nunit classes/methods.

svn path=/trunk/mcs/; revision=136552
Zoltan Varga 16 年之前
父節點
當前提交
4efdd38b4d

+ 5 - 10
mcs/class/corlib/Test/System.Reflection.Emit/AssemblyBuilderAccessTest.cs

@@ -14,29 +14,24 @@ namespace MonoTests.System.Reflection.Emit
 	/// A simple class to test the values of the enum AssemblyBuilderAccess.
 	/// </summary>
 	[TestFixture]
-	public class AssemblyBuilderAccessTest : Assertion
+	public class AssemblyBuilderAccessTest
 	{
 		[Test]
 		public void RunTest ()
 		{
-			AssertEquals("Testing Run value",
-				(int) AssemblyBuilderAccess.Run , 1);
+			Assert.AreEqual((int) AssemblyBuilderAccess.Run, 1);
 		}
 		
 		[Test]
 		public void RunAndSaveTest ()
 		{
-			AssertEquals ("Testing RunAndSave value",
-				(int) AssemblyBuilderAccess.RunAndSave , 3);
+			Assert.AreEqual ((int) AssemblyBuilderAccess.RunAndSave, 3);
 		}
 		
 		[Test]
 		public void SaveTest()
 		{
-			AssertEquals ("Testing Save value",
-				(int) AssemblyBuilderAccess.Save , 2);
-		}
-
-		
+			Assert.AreEqual ((int) AssemblyBuilderAccess.Save, 2);
+		}		
 	}
 }

+ 4 - 0
mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog

@@ -1,3 +1,7 @@
+2009-06-20  Zoltan Varga  <[email protected]>
+
+	* *.cs: Convert all tests to new-style nunit classes/methods.
+
 2009-06-02 Rodrigo Kumpera  <[email protected]>
 
 	* ILGeneratorTest.cs: Tests for #509131.

+ 21 - 21
mcs/class/corlib/Test/System.Reflection.Emit/CustomAttributeBuilderTest.cs

@@ -29,7 +29,7 @@ namespace MonoTests.System.Reflection.Emit
 	/// </summary>
 
 	[TestFixture]
-	public class CustomAttributeBuilderTest : Assertion
+	public class CustomAttributeBuilderTest
 	{
 		
 		// the CustomAttribute class is used for testing and it has to be public
@@ -144,18 +144,18 @@ namespace MonoTests.System.Reflection.Emit
 			//check the validity of the attribute associated with Print method 
 			
 			object [] methodAttrs =  myType.GetMember ("Print") [0].GetCustomAttributes (true);
-			AssertEquals ("#method Print has exactly one attribute", methodAttrs.Length, 1);
+			Assert.AreEqual (methodAttrs.Length, 1, "#1");
 			CustomAttribute methodAttr = methodAttrs [0] as CustomAttribute;
-			AssertEquals ("#AttributeOne", methodAttr.AttributeOne, "hello");
-			AssertEquals ("#AttributeTwo", methodAttr.AttributeTwo, "world");
+			Assert.AreEqual (methodAttr.AttributeOne, "hello", "#2");
+			Assert.AreEqual (methodAttr.AttributeTwo, "world", "#3");
 			
 			//check the validity of the attribute associated with Str feild
 
 			object [] fieldAttrs = myType.GetField ("Str").GetCustomAttributes (true);
-			AssertEquals("#feild Str has exactly one attribute", fieldAttrs.Length, 1);
+			Assert.AreEqual(fieldAttrs.Length, 1, "#4");
 			CustomAttribute fieldAttr = fieldAttrs [0] as CustomAttribute;
-			AssertEquals("#AttributeOne", fieldAttr.AttributeOne, "one");
-			AssertEquals("#AttributeTwo", fieldAttr.AttributeTwo, "two");
+			Assert.AreEqual(fieldAttr.AttributeOne, "one", "#5");
+			Assert.AreEqual(fieldAttr.AttributeTwo, "two", "#6");
 		}
 
 		[Test]
@@ -207,13 +207,13 @@ namespace MonoTests.System.Reflection.Emit
 
 			//check the validity of the attribute associated with Print method 
 			object [] customAttrs = myType.GetCustomAttributes (false);
-			AssertEquals ("#TestType has exactly one attribute", customAttrs.Length, 1);
+			Assert.AreEqual (customAttrs.Length, 1, "1");
 
 			//Custom Attributes of TestType
 			CustomAttribute attr = customAttrs [0] as CustomAttribute;
-			AssertEquals ("#AttributeOne", attr.AttributeOne, "Test");
-			AssertEquals ("#AttributeTwo", attr.AttributeTwo, "Type");
-			AssertEquals ("#CustomAttribute.Feild",attr.Feild, "TestCase");
+			Assert.AreEqual (attr.AttributeOne, "Test", "#2");
+			Assert.AreEqual (attr.AttributeTwo, "Type", "#3");
+			Assert.AreEqual (attr.Feild, "TestCase", "#4");
 
 		}
 
@@ -266,11 +266,11 @@ namespace MonoTests.System.Reflection.Emit
 
 			//check the validity of the attribute associated with Print method 
 			object [] customAttrs = myType.GetCustomAttributes (false);
-			AssertEquals ("#TestType has exactly one attribute", customAttrs.Length , 1);
+			Assert.AreEqual (customAttrs.Length , 1, "#1");
 
 			//Custom Attributes of TestType
 			CustomAttribute attr = customAttrs [0] as CustomAttribute;
-			AssertEquals("#AttributeOne", attr.AttributeOne, "TestCase");
+			Assert.AreEqual(attr.AttributeOne, "TestCase", "#2");
 		}
 
 		[Test]
@@ -326,12 +326,12 @@ namespace MonoTests.System.Reflection.Emit
 
 			//check the validity of the attribute associated with Print method 
 			object [] customAttrs = myType.GetCustomAttributes (false);
-			AssertEquals("#TestType has exactly one attribute",customAttrs.Length , 1);
+			Assert.AreEqual(customAttrs.Length , 1, "#1");
 
 			//Custom Attributes of TestType
 			CustomAttribute attr = customAttrs [0] as CustomAttribute;
-			AssertEquals ("#AttributeOne", attr.AttributeOne, "TestCase");
-			AssertEquals ("#Field ", attr.Feild, "FieldValue");
+			Assert.AreEqual (attr.AttributeOne, "TestCase", "#2");
+			Assert.AreEqual (attr.Feild, "FieldValue", "#3");
 		}
 	
 		
@@ -370,7 +370,7 @@ namespace MonoTests.System.Reflection.Emit
 				typeof (CustomAttribute).GetConstructor (BindingFlags.Instance |
                                                 BindingFlags.NonPublic, null, ctorParams, null);
 
-			Assert ("#Custom Attribute has private constuctor ", classCtorInfo != null);
+			Assert.IsNotNull (classCtorInfo);
 
 			CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
 				classCtorInfo,
@@ -555,7 +555,7 @@ namespace MonoTests.System.Reflection.Emit
 			ConstructorInfo classCtorInfo = 
 				typeof (CustomAttribute).GetConstructor (ctorParams);
 
-			Assert ("#ctor not null", classCtorInfo != null);
+			Assert.IsNotNull (classCtorInfo);
 			CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
 				classCtorInfo,
 				new object [] { "1","2" },
@@ -577,7 +577,7 @@ namespace MonoTests.System.Reflection.Emit
 			ConstructorInfo classCtorInfo = 
 				typeof (CustomAttribute).GetConstructor (ctorParams);
 
-			Assert ("#ctor not null", classCtorInfo != null);
+			Assert.IsNotNull (classCtorInfo);
 			CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
 				classCtorInfo,
 				null, //<-- here is the error
@@ -599,7 +599,7 @@ namespace MonoTests.System.Reflection.Emit
 			ConstructorInfo classCtorInfo = 
 				typeof (CustomAttribute).GetConstructor (ctorParams);
 
-			Assert ("#ctor not null", classCtorInfo != null);
+			Assert.IsNotNull (classCtorInfo);
 			CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
 				classCtorInfo,
 				new object [] { "one","two" },
@@ -621,7 +621,7 @@ namespace MonoTests.System.Reflection.Emit
 			ConstructorInfo classCtorInfo = 
 				typeof (CustomAttribute).GetConstructor (ctorParams);
 
-			Assert ("#ctor not null", classCtorInfo != null);
+			Assert.IsNotNull (classCtorInfo);
 			CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
 				classCtorInfo,
 				new object [] { "one","two" },

+ 20 - 20
mcs/class/corlib/Test/System.Reflection.Emit/EventBuilderTest.cs

@@ -17,7 +17,7 @@ namespace MonoTests.System.Reflection.Emit
 {
 
 [TestFixture]
-public class EventBuilderTest : Assertion
+public class EventBuilderTest
 {
 	public delegate void AnEvent (object o);
 
@@ -170,36 +170,36 @@ public class EventBuilderTest : Assertion
 		MethodInfo mi = t.GetMethod ("OnAnEvent");
 
 		EventInfo[] events = t.GetEvents ();
-		AssertEquals (2, events.Length);
+		Assert.AreEqual (2, events.Length);
 
 		{
 			EventInfo ev = t.GetEvent ("event1");
-			AssertEquals ("event1", ev.Name);
-			AssertEquals (EventAttributes.None, ev.Attributes);
-			AssertEquals (t, ev.DeclaringType);
+			Assert.AreEqual ("event1", ev.Name);
+			Assert.AreEqual (EventAttributes.None, ev.Attributes);
+			Assert.AreEqual (t, ev.DeclaringType);
 
-			AssertEquals (typeof (AnEvent), ev.EventHandlerType);
-			AssertEquals (true, ev.IsMulticast);
-			AssertEquals (false, ev.IsSpecialName);
+			Assert.AreEqual (typeof (AnEvent), ev.EventHandlerType);
+			Assert.AreEqual (true, ev.IsMulticast);
+			Assert.AreEqual (false, ev.IsSpecialName);
 
-			AssertEquals (mi, ev.GetAddMethod ());
-			AssertEquals (null, ev.GetRaiseMethod ());
-			AssertEquals (mi, ev.GetRemoveMethod ());
+			Assert.AreEqual (mi, ev.GetAddMethod ());
+			Assert.AreEqual (null, ev.GetRaiseMethod ());
+			Assert.AreEqual (mi, ev.GetRemoveMethod ());
 		}
 
 		{
 			EventInfo ev = t.GetEvent ("event2");
-			AssertEquals ("event2", ev.Name);
-			AssertEquals (EventAttributes.SpecialName, ev.Attributes);
-			AssertEquals (t, ev.DeclaringType);
+			Assert.AreEqual ("event2", ev.Name);
+			Assert.AreEqual (EventAttributes.SpecialName, ev.Attributes);
+			Assert.AreEqual (t, ev.DeclaringType);
 
-			AssertEquals (typeof (AnEvent), ev.EventHandlerType);
-			AssertEquals (true, ev.IsMulticast);
-			AssertEquals (true, ev.IsSpecialName);
+			Assert.AreEqual (typeof (AnEvent), ev.EventHandlerType);
+			Assert.AreEqual (true, ev.IsMulticast);
+			Assert.AreEqual (true, ev.IsSpecialName);
 
-			AssertEquals (mi, ev.GetAddMethod ());
-			AssertEquals (mi, ev.GetRaiseMethod ());
-			AssertEquals (mi, ev.GetRemoveMethod ());
+			Assert.AreEqual (mi, ev.GetAddMethod ());
+			Assert.AreEqual (mi, ev.GetRaiseMethod ());
+			Assert.AreEqual (mi, ev.GetRemoveMethod ());
 		}
 	}		
 		

+ 12 - 12
mcs/class/corlib/Test/System.Reflection.Emit/PropertyBuilderTest.cs

@@ -17,7 +17,7 @@ namespace MonoTests.System.Reflection.Emit
 {
 
 [TestFixture]
-public class PropertyBuilderTest : Assertion
+public class PropertyBuilderTest
 {	
     private TypeBuilder tb;
 
@@ -81,24 +81,24 @@ public class PropertyBuilderTest : Assertion
 		Type t = tb.CreateType ();
 
 		PropertyInfo[] props = t.GetProperties (BindingFlags.Public|BindingFlags.Instance);
-		AssertEquals (1, props.Length);
+		Assert.AreEqual (1, props.Length);
 
 		PropertyInfo p = t.GetProperty ("prop");
 
-		AssertEquals (PropertyAttributes.HasDefault, p.Attributes);
-		AssertEquals (true, p.CanRead);
-		AssertEquals (true, p.CanWrite);
-		AssertEquals ("prop", p.Name);
-		AssertEquals (MemberTypes.Property, p.MemberType);
-		AssertEquals (typeof (int), p.PropertyType);
+		Assert.AreEqual (PropertyAttributes.HasDefault, p.Attributes);
+		Assert.AreEqual (true, p.CanRead);
+		Assert.AreEqual (true, p.CanWrite);
+		Assert.AreEqual ("prop", p.Name);
+		Assert.AreEqual (MemberTypes.Property, p.MemberType);
+		Assert.AreEqual (typeof (int), p.PropertyType);
 		MethodInfo[] methods = p.GetAccessors ();
-		AssertEquals (2, methods.Length);
-		AssertNotNull (p.GetGetMethod ());
-		AssertNotNull (p.GetSetMethod ());
+		Assert.AreEqual (2, methods.Length);
+		Assert.IsNotNull (p.GetGetMethod ());
+		Assert.IsNotNull (p.GetSetMethod ());
 
 		object o = Activator.CreateInstance (t);
 		p.SetValue (o, 42, null);
-		AssertEquals (42, p.GetValue (o, null));
+		Assert.AreEqual (42, p.GetValue (o, null));
 	}
 }
 }

+ 2 - 4
mcs/class/corlib/Test/System.Reflection.Emit/TypeBuilderTest.cs

@@ -913,8 +913,7 @@ namespace MonoTests.System.Reflection.Emit
 
 			/* Is .E a valid name ?
 			TypeBuilder tb4 = module.DefineType (".E");
-			AssertEquals ("",
-						  "E", tb4.Name);
+			Assert.AreEqual ("E", tb4.Name);
 			*/
 		}
 
@@ -932,8 +931,7 @@ namespace MonoTests.System.Reflection.Emit
 
 			/* Is .E a valid name ?
 			TypeBuilder tb4 = module.DefineType (".E");
-			AssertEquals ("",
-						  "E", tb4.Name);
+			Assert.AreEqual ("E", tb4.Name);
 			*/
 		}