public MFTestResults SystemType12_InvokeMember_Test() { /// <summary> /// 1. Test the InvokeMember(String,BindingFlags) method /// This test is currently a stub /// TODO: expand test #1 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the InvokeMember(String,BindingFlags) method"); Log.Comment("This test must be re-written once BindingFlags is working, "); Log.Comment("see 17246 for more details."); //Assigned and manipulated to avoid compiler warning Int32 I = 0; I++; TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); testResult &= ((int)myType2.InvokeMember("Method2", BindingFlags.Default | BindingFlags.InvokeMethod, null, testTestObject2, new object[] { -6 }) == -6); } catch (NotImplementedException) { return(MFTestResults.KnownFailure); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return(testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType9_GetInterfaces_Test() { /// <summary> /// 1. Test the GetInterfaces(String) method /// 2. Test the GetInterfaces(String,BindingFlags) method /// This test is currently a stub /// TODO: Write test #2 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetInterfaces() method"); Log.Comment("This test must be re-written once BindingFlags is working, "); Log.Comment("see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); Log.Comment("The full name is " + myType1.FullName); testResult &= (myType1.GetInterfaces().Length == 0); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); Type myType3 = Type.GetType("Microsoft.SPOT.Platform.Tests.SystemTypeTests+iEmpty"); testResult &= (myType2.GetInterfaces()[0] == myType3); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return(testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public void SystemType10_GetMethod_Test() { OutputHelper.WriteLine("This tests the GetMethod(String) method"); OutputHelper.WriteLine("This test must be re-written once BindingFlags is working, "); OutputHelper.WriteLine("see 17246 for more details."); Int32 I = 0; I++; TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); OutputHelper.WriteLine("The full name is " + myType2.FullName); MethodInfo methodInfo1 = myType2.GetMethod("Method2"); Assert.Equal(methodInfo1.IsAbstract, false); Assert.Equal(methodInfo1.IsFinal, false); Assert.Equal(methodInfo1.IsPublic, true); Assert.Equal(methodInfo1.IsStatic, false); Assert.Equal(methodInfo1.IsVirtual, false); Assert.True(methodInfo1.MemberType == MemberTypes.Method); Assert.Equal(methodInfo1.Name, "Method2"); Assert.IsType(methodInfo1.ReturnType, I.GetType()); Assert.IsType(methodInfo1.DeclaringType, myType2); Assert.Equal((int)(methodInfo1.Invoke(testTestObject2, new object[] { 1 })), 1); }
public MFTestResults SystemType5_GetConstructor_Test() { /// <summary> /// 1. Tests the GetConstructor(Type[]) method for a user defined type /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetConstructor(Type[]) method"); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); Type[] typeOfInt32Arr = new Type[] { Type.GetType("System.Int32") }; object[] value5Arr = new object[] { 5 }; TestObject2 testTestObject3 = (TestObject2)myType2.GetConstructor(typeOfInt32Arr).Invoke(value5Arr); testResult &= (testTestObject2.m_data == testTestObject3.m_data); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return(testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType11_GetMethods_Test() { /// <summary> /// 1. Test the GetMethods(String) method /// 2. Test the GetMethods(String,BindingFlags) method /// This test is currently a stub /// TODO: Write test #2 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetMethods() method"); Log.Comment("This test must be re-written once BindingFlags is working, "); Log.Comment("see 17246 for more details."); //Assigned and manipulated to avoid compiler warning Int32 I = 0; I++; TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); MethodInfo[] methodInfoArr1 = myType2.GetMethods(); MethodInfo methodInfo1 = null; if (methodInfoArr1[0].Name == "Method2") { methodInfo1 = methodInfoArr1[0]; Log.Comment("Method2 found in position 0"); } else if (methodInfoArr1[1].Name == "Method2") { methodInfo1 = methodInfoArr1[1]; Log.Comment("Method2 found in position 1"); } testResult &= (methodInfo1.IsAbstract == false); testResult &= (methodInfo1.IsFinal == false); testResult &= (methodInfo1.IsPublic == true); testResult &= (methodInfo1.IsStatic == false); testResult &= (methodInfo1.IsVirtual == false); testResult &= (methodInfo1.MemberType == MemberTypes.Method); testResult &= (methodInfo1.Name == "Method2"); testResult &= (methodInfo1.ReturnType == I.GetType()); testResult &= (methodInfo1.DeclaringType == myType2); testResult &= ((int)(methodInfo1.Invoke(testTestObject2, new object[] { 1 })) == 1); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return(testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public void SystemType7_GetField_Test() { OutputHelper.WriteLine("This tests the GetField(String) "); OutputHelper.WriteLine("and the GetField(String,BindingFlags) methods)"); OutputHelper.WriteLine("Currently this test fails, see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); OutputHelper.WriteLine("The full name is " + myType1.FullName); Assert.True(myType1.GetField("m_data") == null); OutputHelper.WriteLine(" TestObject2 type has one data member \"m_data\" of type Int32."); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); OutputHelper.WriteLine("The full name is " + myType2.FullName); OutputHelper.WriteLine(" Check that type of m_data is Int32"); Assert.IsType(myType2.GetField("m_data", BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance).FieldType, myType1); OutputHelper.WriteLine(" Check that value in m_data is 5 ( becuase we called new TestObject2(5))"); Assert.Equal((int)myType2.GetField("m_data", BindingFlags.IgnoreCase | BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance).GetValue(testTestObject2), 5); OutputHelper.WriteLine(" Check that m_data is a field"); Assert.True(myType2.GetField("m_data").MemberType == MemberTypes.Field); OutputHelper.WriteLine(" Check that field m_data has Name \"m_data\""); Assert.Equal(myType2.GetField("m_data").Name, "m_data"); OutputHelper.WriteLine(" Check that misspelling of m_data return NULL."); Assert.True(null == myType2.GetField("data")); OutputHelper.WriteLine(" Checks that case misspelling of m_data return NULL if flag BindingFlags.IgnoreCase not specified."); Assert.True(null == myType2.GetField("m_Data")); OutputHelper.WriteLine("Check retrieval with BindingFlags.IgnoreCase. If flag BindingFlags.IgnoreCase is ised, then the case should be ignored. We should get the same type information."); FieldInfo fInfo_m_Data = myType2.GetField("m_Data", BindingFlags.IgnoreCase | BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance); FieldInfo fInfo_m_data = myType2.GetField("m_data"); Assert.NotNull(fInfo_m_Data); Assert.NotNull(fInfo_m_data); Assert.True(fInfo_m_Data.Name.Equals(fInfo_m_data.Name)); OutputHelper.WriteLine(" Indirectly set m_data in testTestObject2 to 6 and then check it."); myType2.GetField("m_data").SetValue(testTestObject2, 6); Assert.Equal((int)myType2.GetField("m_data").GetValue(testTestObject2), 6); Assert.Equal(testTestObject2.m_data, 6); }
public void SystemType5_GetConstructor_Test() { OutputHelper.WriteLine("This tests the GetConstructor(Type[]) method"); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); OutputHelper.WriteLine("The full name is " + myType2.FullName); Type[] typeOfInt32Arr = new Type[] { Type.GetType("System.Int32") }; object[] value5Arr = new object[] { 5 }; TestObject2 testTestObject3 = (TestObject2)myType2.GetConstructor(typeOfInt32Arr).Invoke(value5Arr); Assert.Equal(testTestObject2.m_data, testTestObject3.m_data); }
public void SystemType9_GetInterfaces_Test() { OutputHelper.WriteLine("This tests the GetInterfaces() method"); OutputHelper.WriteLine("This test must be re-written once BindingFlags is working, "); OutputHelper.WriteLine("see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); OutputHelper.WriteLine("The full name is " + myType1.FullName); Assert.Equal(myType1.GetInterfaces().Length, 0); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); OutputHelper.WriteLine("The full name is " + myType2.FullName); Type myType3 = Type.GetType("NFUnitTestSystemLib.UnitTestTypeTests+iEmpty"); Assert.IsType(myType2.GetInterfaces()[0], myType3); }
public void SystemType8_GetFields_Test() { OutputHelper.WriteLine("This tests the GetFields(String) method"); OutputHelper.WriteLine("This test must be re-written once BindingFlags is working, "); OutputHelper.WriteLine("see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); OutputHelper.WriteLine("The full name is " + myType1.FullName); Assert.Null(myType1.GetField("m_data")); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); OutputHelper.WriteLine("The full name is " + myType2.FullName); Assert.IsType(myType2.GetField("m_data").FieldType, myType1); Assert.Equal((int)myType2.GetField("m_data").GetValue(testTestObject2), 5); Assert.True(myType2.GetField("m_data").MemberType == MemberTypes.Field); Assert.Equal(myType2.GetField("m_data").Name, "m_data"); myType2.GetField("m_data").SetValue(testTestObject2, 6); Assert.Equal((int)myType2.GetField("m_data").GetValue(testTestObject2), 6); }
public void SystemType11_GetMethods_Test() { OutputHelper.WriteLine("This tests the GetMethods() method"); OutputHelper.WriteLine("This test must be re-written once BindingFlags is working, "); OutputHelper.WriteLine("see 17246 for more details."); //Assigned and manipulated to avoid compiler warning Int32 I = 0; I++; TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); OutputHelper.WriteLine("The full name is " + myType2.FullName); MethodInfo[] methodInfoArr1 = myType2.GetMethods(); MethodInfo methodInfo1 = null; if (methodInfoArr1[0].Name == "Method2") { methodInfo1 = methodInfoArr1[0]; OutputHelper.WriteLine("Method2 found in position 0"); } else if (methodInfoArr1[1].Name == "Method2") { methodInfo1 = methodInfoArr1[1]; OutputHelper.WriteLine("Method2 found in position 1"); } Assert.Equal(methodInfo1.IsAbstract, false); Assert.Equal(methodInfo1.IsFinal, false); Assert.Equal(methodInfo1.IsPublic, true); Assert.Equal(methodInfo1.IsStatic, false); Assert.Equal(methodInfo1.IsVirtual, false); Assert.True(methodInfo1.MemberType == MemberTypes.Method); Assert.Equal(methodInfo1.Name, "Method2"); Assert.IsType(methodInfo1.ReturnType, I.GetType()); Assert.IsType(methodInfo1.DeclaringType, myType2); Assert.Equal((int)(methodInfo1.Invoke(testTestObject2, new object[] { 1 })), 1); }
public MFTestResults SystemType8_GetFields_Test() { /// <summary> /// 1. Test the GetFields(String) method /// 2. Test the GetFields(String,BindingFlags) method /// This test is currently a stub /// TODO: Write test #2 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetFields(String) method"); Log.Comment("This test must be re-written once BindingFlags is working, "); Log.Comment("see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); Log.Comment("The full name is " + myType1.FullName); testResult &= (myType1.GetField("m_data") == null); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); testResult &= (myType2.GetField("m_data").FieldType == myType1); testResult &= ((int)myType2.GetField("m_data").GetValue(testTestObject2) == 5); testResult &= (myType2.GetField("m_data").MemberType == MemberTypes.Field); testResult &= (myType2.GetField("m_data").Name == "m_data"); myType2.GetField("m_data").SetValue(testTestObject2, 6); testResult &= ((int)myType2.GetField("m_data").GetValue(testTestObject2) == 6); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return(testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType12_InvokeMember_Test() { /// <summary> /// 1. Test the InvokeMember(String,BindingFlags) method /// This test is currently a stub /// TODO: expand test #1 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the InvokeMember(String,BindingFlags) method"); Log.Comment("This test must be re-written once BindingFlags is working, "); Log.Comment("see 17246 for more details."); //Assigned and manipulated to avoid compiler warning Int32 I = 0; I++; TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); testResult &= ((int)myType2.InvokeMember("Method2", BindingFlags.Default | BindingFlags.InvokeMethod, null, testTestObject2, new object[] { -6 }) == -6); } catch (NotImplementedException) { return MFTestResults.KnownFailure; } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return (testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType11_GetMethods_Test() { /// <summary> /// 1. Test the GetMethods(String) method /// 2. Test the GetMethods(String,BindingFlags) method /// This test is currently a stub /// TODO: Write test #2 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetMethods() method"); Log.Comment("This test must be re-written once BindingFlags is working, "); Log.Comment("see 17246 for more details."); //Assigned and manipulated to avoid compiler warning Int32 I = 0; I++; TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); MethodInfo[] methodInfoArr1 = myType2.GetMethods(); MethodInfo methodInfo1 = null; if (methodInfoArr1[0].Name == "Method2") { methodInfo1 = methodInfoArr1[0]; Log.Comment("Method2 found in position 0"); } else if (methodInfoArr1[1].Name == "Method2") { methodInfo1 = methodInfoArr1[1]; Log.Comment("Method2 found in position 1"); } testResult &= (methodInfo1.IsAbstract == false); testResult &= (methodInfo1.IsFinal == false); testResult &= (methodInfo1.IsPublic == true); testResult &= (methodInfo1.IsStatic == false); testResult &= (methodInfo1.IsVirtual == false); testResult &= (methodInfo1.MemberType == MemberTypes.Method); testResult &= (methodInfo1.Name == "Method2"); testResult &= (methodInfo1.ReturnType == I.GetType()); testResult &= (methodInfo1.DeclaringType == myType2); testResult &= ((int)(methodInfo1.Invoke(testTestObject2, new object[] { 1 })) == 1); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return (testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType9_GetInterfaces_Test() { /// <summary> /// 1. Test the GetInterfaces(String) method /// 2. Test the GetInterfaces(String,BindingFlags) method /// This test is currently a stub /// TODO: Write test #2 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetInterfaces() method"); Log.Comment("This test must be re-written once BindingFlags is working, "); Log.Comment("see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); Log.Comment("The full name is " + myType1.FullName); testResult &= (myType1.GetInterfaces().Length == 0); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); Type myType3 = Type.GetType("Microsoft.SPOT.Platform.Tests.SystemTypeTests+iEmpty"); testResult &= (myType2.GetInterfaces()[0] == myType3); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return (testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType8_GetFields_Test() { /// <summary> /// 1. Test the GetFields(String) method /// 2. Test the GetFields(String,BindingFlags) method /// This test is currently a stub /// TODO: Write test #2 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetFields(String) method"); Log.Comment("This test must be re-written once BindingFlags is working, "); Log.Comment("see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); Log.Comment("The full name is " + myType1.FullName); testResult &= (myType1.GetField("m_data") == null); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); testResult &= (myType2.GetField("m_data").FieldType == myType1); testResult &= ((int)myType2.GetField("m_data").GetValue(testTestObject2) == 5); testResult &= (myType2.GetField("m_data").MemberType == MemberTypes.Field); testResult &= (myType2.GetField("m_data").Name == "m_data"); myType2.GetField("m_data").SetValue(testTestObject2, 6); testResult &= ((int)myType2.GetField("m_data").GetValue(testTestObject2) == 6); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return (testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType7_GetField_Test() { /// <summary> /// 1. Test the GetField(String) method /// 2. Test the GetField(String,BindingFlags) method /// TODO: Expand test #2 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetField(String) "); Log.Comment("and the GetField(String,BindingFlags) methods)"); Log.Comment("Currently this test fails, see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); Log.Comment("The full name is " + myType1.FullName); testResult &= (myType1.GetField("m_data") == null); Log.Comment(" TestObject2 type has one data member \"m_data\" of type Int32."); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); Log.Comment(" Check that type of m_data is Int32"); testResult &= (myType2.GetField("m_data", BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance).FieldType == myType1); Log.Comment(" Check that value in m_data is 5 ( becuase we called new TestObject2(5))"); testResult &= ((int)myType2.GetField("m_data", BindingFlags.IgnoreCase | BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance).GetValue(testTestObject2) == 5); if ( !testResult ) { Log.Exception( " Last test failed " ); } Log.Comment(" Check that m_data is a field"); testResult &= (myType2.GetField("m_data").MemberType == MemberTypes.Field); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Check that field m_data has Name \"m_data\""); testResult &= (myType2.GetField("m_data").Name == "m_data"); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Check that misspelling of m_data return NULL."); testResult &= null == myType2.GetField("data"); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Checks that case misspelling of m_data return NULL if flag BindingFlags.IgnoreCase not specified."); testResult &= null == myType2.GetField("m_Data"); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment("Check retrieval with BindingFlags.IgnoreCase. If flag BindingFlags.IgnoreCase is ised, then the case should be ignored. We should get the same type information."); FieldInfo fInfo_m_Data = myType2.GetField("m_Data", BindingFlags.IgnoreCase | BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance); FieldInfo fInfo_m_data = myType2.GetField("m_data"); testResult &= fInfo_m_Data != null && fInfo_m_data != null; testResult &= fInfo_m_Data.Name.Equals( fInfo_m_data.Name ); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Indirectly set m_data in testTestObject2 to 6 and then check it."); myType2.GetField("m_data").SetValue(testTestObject2, 6); testResult &= ((int)myType2.GetField("m_data").GetValue(testTestObject2) == 6); testResult &= testTestObject2.m_data == 6; if (!testResult) { Log.Exception(" Last test failed "); } } // In case of exceptions we log it and set testResult = false; catch (NullReferenceException e) { Log.Comment("NullRef " + e.Message); testResult = false; } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return (testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType5_GetConstructor_Test() { /// <summary> /// 1. Tests the GetConstructor(Type[]) method for a user defined type /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetConstructor(Type[]) method"); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); Type[] typeOfInt32Arr = new Type[] { Type.GetType("System.Int32") }; object[] value5Arr = new object[] { 5 }; TestObject2 testTestObject3 = (TestObject2)myType2.GetConstructor(typeOfInt32Arr).Invoke(value5Arr); testResult &= (testTestObject2.m_data == testTestObject3.m_data); } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return (testResult ? MFTestResults.Pass : MFTestResults.Fail); }
public MFTestResults SystemType7_GetField_Test() { /// <summary> /// 1. Test the GetField(String) method /// 2. Test the GetField(String,BindingFlags) method /// TODO: Expand test #2 once bug 17246 is resolved /// </summary> /// bool testResult = true; try { Log.Comment("This tests the GetField(String) "); Log.Comment("and the GetField(String,BindingFlags) methods)"); Log.Comment("Currently this test fails, see 17246 for more details."); Type myType1 = Type.GetType("System.Int32"); Log.Comment("The full name is " + myType1.FullName); testResult &= (myType1.GetField("m_data") == null); Log.Comment(" TestObject2 type has one data member \"m_data\" of type Int32."); TestObject2 testTestObject2 = new TestObject2(5); Type myType2 = testTestObject2.GetType(); Log.Comment("The full name is " + myType2.FullName); Log.Comment(" Check that type of m_data is Int32"); testResult &= (myType2.GetField("m_data", BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance).FieldType == myType1); Log.Comment(" Check that value in m_data is 5 ( becuase we called new TestObject2(5))"); testResult &= ((int)myType2.GetField("m_data", BindingFlags.IgnoreCase | BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance).GetValue(testTestObject2) == 5); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Check that m_data is a field"); testResult &= (myType2.GetField("m_data").MemberType == MemberTypes.Field); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Check that field m_data has Name \"m_data\""); testResult &= (myType2.GetField("m_data").Name == "m_data"); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Check that misspelling of m_data return NULL."); testResult &= null == myType2.GetField("data"); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Checks that case misspelling of m_data return NULL if flag BindingFlags.IgnoreCase not specified."); testResult &= null == myType2.GetField("m_Data"); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment("Check retrieval with BindingFlags.IgnoreCase. If flag BindingFlags.IgnoreCase is ised, then the case should be ignored. We should get the same type information."); FieldInfo fInfo_m_Data = myType2.GetField("m_Data", BindingFlags.IgnoreCase | BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance); FieldInfo fInfo_m_data = myType2.GetField("m_data"); testResult &= fInfo_m_Data != null && fInfo_m_data != null; testResult &= fInfo_m_Data.Name.Equals(fInfo_m_data.Name); if (!testResult) { Log.Exception(" Last test failed "); } Log.Comment(" Indirectly set m_data in testTestObject2 to 6 and then check it."); myType2.GetField("m_data").SetValue(testTestObject2, 6); testResult &= ((int)myType2.GetField("m_data").GetValue(testTestObject2) == 6); testResult &= testTestObject2.m_data == 6; if (!testResult) { Log.Exception(" Last test failed "); } } // In case of exceptions we log it and set testResult = false; catch (NullReferenceException e) { Log.Comment("NullRef " + e.Message); testResult = false; } catch (Exception e) { Log.Comment("Typeless " + e.Message); testResult = false; } return(testResult ? MFTestResults.Pass : MFTestResults.Fail); }