public void SystemReflectionMemberTests_ConstructorInfo_Test2() { /// /// Test the ConstructorInfo class members /// Type t = typeof(TestClass); ConstructorInfo ci = t.GetConstructor(new Type[] { }); Assert.True(ci.IsPublic); Assert.False(ci.IsStatic); Assert.True(ci.Invoke(new object[] { }) is TestClass); ci = typeof(AbsTestClass).GetConstructor(new Type[] { typeof(float) }); Assert.False(ci.IsPublic); Assert.False(ci.IsStatic); Assert.IsType(ci.DeclaringType, typeof(AbsTestClass)); AbsTestClass tst = ci.Invoke(new object[] { 1.2f }) as AbsTestClass; Assert.NotNull(tst); ci = t.GetConstructor(new Type[] { typeof(int) }); Assert.False(ci.IsStatic); Assert.False(ci.IsPublic); Assert.True(ci.Invoke(new object[] { 3 }) is TestClass); ci = t.GetConstructor(new Type[] { typeof(bool) }); Assert.False(ci.IsStatic); Assert.False(ci.IsPublic); Assert.True(ci.Invoke(new object[] { true }) is TestClass); }
public MFTestResults SystemReflectionMemberTests_ConstructorInfo_Test2() { bool fRes = true; /// /// Test the ConstructorInfo class members /// Type t = typeof(TestClass); ConstructorInfo ci = t.GetConstructor(new Type[] { }); fRes &= ci.IsPublic; fRes &= !ci.IsStatic; fRes &= ci.Invoke(new object[] { }) is TestClass; ci = typeof(AbsTestClass).GetConstructor(new Type[] { typeof(float) }); fRes &= !ci.IsPublic; fRes &= !ci.IsStatic; fRes &= ci.DeclaringType == typeof(AbsTestClass); AbsTestClass tst = ci.Invoke(new object[] { 1.2f }) as AbsTestClass; fRes &= tst != null; ci = t.GetConstructor(new Type[] { typeof(int) }); fRes &= !ci.IsStatic; fRes &= !ci.IsPublic; fRes &= ci.Invoke(new object[] { 3 }) is TestClass; ci = t.GetConstructor(new Type[] { typeof(bool) }); fRes &= !ci.IsStatic; fRes &= !ci.IsPublic; fRes &= ci.Invoke(new object[] { true }) is TestClass; return(fRes ? MFTestResults.Pass : MFTestResults.Fail); }