public void ConstructorByExtensionMethodAndType_StringParam() { var c = TestClassType.Contructor <Func <string, TestClass> >(); Assert.IsNotNull(c); var instance = c("s"); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestClassType); }
public void ConstructorByObjects_StringParam() { var c = TestClassType.Contructor(typeof(string)); Assert.IsNotNull(c); var instance = c(new object[] { "s" }); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestClassType); }
public void ConstructorByExtensionMethodAndObject_IntParam_FromStruct() { var c = TestStructType.Contructor <Func <int, object> >(); Assert.IsNotNull(c); var instance = c(0); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestStructType); }
public void IndexerSet_ByObjects_Public_FromStruct() { var @is = _testStrucType.IndexerSetStruct(typeof(int), typeof(int)); Assert.IsNotNull(@is); var objectStruct = (object)_testStructInstance; @is(ref objectStruct, new object[] { FirstIntIndex }, NewIntValue); Assert.AreEqual(NewIntValue, ((TestStruct)objectStruct).IndexerBackend[FirstIntIndex]); }
public void IndexerSet_ByObjects_Internal_FromStruct() { var @is = _testStrucType.IndexerSetStruct(typeof(double), typeof(double)); Assert.IsNotNull(@is); var objectStruct = (object)_testStructInstance; @is(ref objectStruct, new object[] { FirstDoubleIndex }, NewDoubleValue); Assert.AreEqual(NewDoubleValue, ((TestStruct)objectStruct).InternalIndexer); }
public void ConstructorByObjects_BoolParam() { var c = TestClassType.Contructor(typeof(bool)); Assert.IsNotNull(c); var instance = c(new object[] { false }); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestClassType); }
public void ConstructorByObjects_IntParam_FromStruct() { var c = TestStructType.Contructor(typeof(int)); Assert.IsNotNull(c); var instance = c(new object[] { 0 }); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestStructType); }
public void ConstructorByDelegateWithType_IntParam() { var c = DelegateFactory.Contructor <Func <int, TestClass> >(); Assert.IsNotNull(c); var instance = c(0); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestClassType); }
public void ConstructorByObjects_NoParam() { var c = TestClassType.Contructor(); Assert.IsNotNull(c); var instance = c(null); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestClassType); }
public void ConstructorByExtensionMethodAndObject_BoolParam() { var c = TestClassType.Contructor <Func <bool, object> >(); Assert.IsNotNull(c); var instance = c(false); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestClassType); }
public void IndexerSet_ByExtensionAndReturnType_2Index_FromStruct() { var @is = _testStrucType.IndexerSetStruct <int, int, int>(); Assert.IsNotNull(@is); var objectStruct = (object)_testStructInstance; @is(ref objectStruct, FirstIntIndex, SecondIntIndex, NewIntValue); Assert.AreEqual(NewIntValue, ((TestStruct)objectStruct).PrivateIndexer); }
public void ConstructorByDelegateWithType_WithCustomDelegate_SingleParam() { var cd = DelegateFactory.Contructor <CustomCtrSingleParam>(); Assert.IsNotNull(cd); var instance = cd(0); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, TestClassType); }
public void Private_GenericMethod_Void_NoParameter_OneTypeParameter_ByObjects() { var m = _testClassType.InstanceGenericMethodVoid("PrivateInstanceGenericMethodVoid", null, new[] { typeof(string) }); Assert.IsNotNull(m); m(_testClassInstance, new object[0]); Assert.AreEqual(null, _testClassInstance.PublicParams); Assert.AreEqual(typeof(string), _testClassInstance.PublicTypeParams[0]); }
public void Private_GenericMethod_NoVoid_NoParameter_OneTypeParameter_ByObjectAndTypes_WithCast() { var m = _testClassType.InstanceMethod <Func <object, TestClass>, TestClass>("PrivateInstanceGenericMethod"); Assert.IsNotNull(m); var result = m(_testClassInstance); Assert.AreEqual(null, _testClassInstance.PublicParams); Assert.IsInstanceOfType(result, typeof(TestClass)); Assert.AreEqual(typeof(TestClass), _testClassInstance.PublicTypeParams[0]); }
public void Internal_GenericMethod_NoVoid_NoParameter_OneTypeParameter_ByTypes() { var m = DelegateFactory.StaticMethod <TestClass, Func <TestClass>, TestClass>("InternalStaticGenericMethod"); Assert.IsNotNull(m); var result = m(); Assert.AreEqual(null, TestClass.StaticPublicParams); Assert.IsInstanceOfType(result, typeof(TestClass)); Assert.AreEqual(typeof(TestClass), TestClass.StaticPublicTypeParams[0]); }
public void Public_GenericMethod_NoVoid_NoParameter_OneTypeParameter_ByTypes() { var m = DelegateFactory.InstanceMethod <Func <TestClass, TestClass>, TestClass>("PublicInstanceGenericMethod"); Assert.IsNotNull(m); var result = m(_testClassInstance); Assert.AreEqual(null, _testClassInstance.PublicParams); Assert.IsInstanceOfType(result, typeof(TestClass)); Assert.AreEqual(typeof(TestClass), _testClassInstance.PublicTypeParams[0]); }
public void Private_GenericMethod_NoVoid_NoParameter_OneTypeParameter_ByObjectAndTypes() { var m = _testClassType.StaticMethod <Func <TestClass>, TestClass>("PrivateStaticGenericMethod"); Assert.IsNotNull(m); var result = m(); Assert.AreEqual(null, TestClass.StaticPublicParams); Assert.IsInstanceOfType(result, typeof(TestClass)); Assert.AreEqual(typeof(TestClass), TestClass.StaticPublicTypeParams[0]); }
public void Private_GenericMethod_NoVoid_NoParameter_OneTypeParameter_ByObjects() { var m = _testClassType.StaticGenericMethod("PrivateStaticGenericMethod", null, new[] { _testClassType }); Assert.IsNotNull(m); var result = m(new object[] { }); Assert.AreEqual(null, TestClass.StaticPublicParams); Assert.IsInstanceOfType(result, typeof(TestClass)); Assert.AreEqual(typeof(TestClass), TestClass.StaticPublicTypeParams[0]); }
public void Protected_GenericMethod_NoVoid_NoParameter_OneTypeParameter_ByObjects() { var m = _testClassType.InstanceGenericMethod("ProtectedInstanceGenericMethod", null, new[] { _testClassType }); Assert.IsNotNull(m); var result = m(_testClassInstance, new object[] { _testClassInstance }); Assert.AreEqual(null, _testClassInstance.PublicParams); Assert.IsInstanceOfType(result, typeof(TestClass)); Assert.AreEqual(typeof(TestClass), _testClassInstance.PublicTypeParams[0]); }
public void GenericMethod_NoVoid_SingleParameter_OneTypeParameter_ByObjectAndTypes() { var m = _testClassType.StaticMethod <Func <TestClass, TestClass>, TestClass>("StaticGenericMethod"); Assert.IsNotNull(m); var result = m(_testClassInstance); Assert.AreEqual(1, TestClass.StaticPublicParams.Length); Assert.AreEqual(_testClassInstance, TestClass.StaticPublicParams[0]); Assert.AreEqual(_testClassInstance, result); Assert.AreEqual(typeof(TestClass), TestClass.StaticPublicTypeParams[0]); }
public void GenericMethod_NoVoid_SingleParameter_OneTypeParameter_ByObjectAndTypes_WithCast() { var m = _testClassType.InstanceMethod <Func <object, TestClass, TestClass>, TestClass>("InstanceGenericMethod"); Assert.IsNotNull(m); var result = m(_testClassInstance, _testClassInstance); Assert.AreEqual(1, _testClassInstance.PublicParams.Length); Assert.AreEqual(_testClassInstance, _testClassInstance.PublicParams[0]); Assert.AreEqual(_testClassInstance, result); Assert.AreEqual(typeof(TestClass), _testClassInstance.PublicTypeParams[0]); }
public void GenericMethod_NoVoid_NoParameter_2TypeParameters_ByObjectAndTypes() { var m = _testClassType.InstanceMethod <Func <TestClass, TestClass>, TestClass, TestStruct> ("InstanceGenericMethod"); Assert.IsNotNull(m); var result = m(_testClassInstance); Assert.AreEqual(null, _testClassInstance.PublicParams); Assert.IsInstanceOfType(result, typeof(TestClass)); Assert.AreEqual(typeof(TestClass), _testClassInstance.PublicTypeParams[0]); Assert.AreEqual(typeof(TestStruct), _testClassInstance.PublicTypeParams[1]); }
public void GenericMethod_NoVoid_2Parameter_OneTypeParameter_ByTypes() { var m = DelegateFactory.StaticMethod <TestClass, Func <TestClass, int, TestClass>, TestClass> ("StaticGenericMethod"); Assert.IsNotNull(m); var result = m(_testClassInstance, 0); Assert.AreEqual(2, TestClass.StaticPublicParams.Length); Assert.AreEqual(_testClassInstance, TestClass.StaticPublicParams[0]); Assert.AreEqual(_testClassInstance, result); Assert.AreEqual(typeof(TestClass), TestClass.StaticPublicTypeParams[0]); }
public void GenericMethod_NoVoid_SingleParameter_OneTypeParameter_ByTypes() { var m = DelegateFactory.InstanceMethod <Func <TestClass, TestClass, TestClass>, TestClass> ("InstanceGenericMethod"); Assert.IsNotNull(m); var result = m(_testClassInstance, _testClassInstance); Assert.AreEqual(1, _testClassInstance.PublicParams.Length); Assert.AreEqual(_testClassInstance, _testClassInstance.PublicParams[0]); Assert.AreEqual(_testClassInstance, result); Assert.AreEqual(typeof(TestClass), _testClassInstance.PublicTypeParams[0]); }
public void GenericMethod_NoVoid_NoParameter_2TypeParameters_ByObjects() { var m = _testClassType.StaticGenericMethod("StaticGenericMethod", null, new[] { _testClassType, _testStructType }); Assert.IsNotNull(m); var result = m(new object[0]); Assert.AreEqual(null, TestClass.StaticPublicParams); Assert.IsInstanceOfType(result, typeof(TestClass)); Assert.AreEqual(typeof(TestClass), TestClass.StaticPublicTypeParams[0]); Assert.AreEqual(typeof(TestStruct), TestClass.StaticPublicTypeParams[1]); }
public void GenericMethod_NoVoid_2Parameter_OneTypeParameter_ByObjectAndTypes() { var m = _testClassType.InstanceMethod <Func <TestClass, TestClass, int, TestClass>, TestClass> ("InstanceGenericMethod"); Assert.IsNotNull(m); var result = m(_testClassInstance, _testClassInstance, 0); Assert.AreEqual(2, _testClassInstance.PublicParams.Length); Assert.AreEqual(_testClassInstance, _testClassInstance.PublicParams[0]); Assert.AreEqual(0, _testClassInstance.PublicParams[1]); Assert.AreEqual(_testClassInstance, result); Assert.AreEqual(typeof(TestClass), _testClassInstance.PublicTypeParams[0]); }
public void GenericMethod_NoVoid_2Parameter_OneTypeParameter_ByObjects() { var m = _testClassType.StaticGenericMethod("StaticGenericMethod", new[] { _testClassType, typeof(int) }, new[] { _testClassType }); Assert.IsNotNull(m); var result = m(new object[] { _testClassInstance, 0 }); Assert.AreEqual(2, TestClass.StaticPublicParams.Length); Assert.AreEqual(_testClassInstance, TestClass.StaticPublicParams[0]); Assert.AreEqual(0, TestClass.StaticPublicParams[1]); Assert.AreEqual(_testClassInstance, result); Assert.AreEqual(typeof(TestClass), TestClass.StaticPublicTypeParams[0]); }
public void EventAdd_ByTypes_Private() { var accessor = DelegateFactory.EventAdd <TestClass, TestClass.PrivateEventArgs>("PrivateEvent"); Assert.IsNotNull(accessor); var eventExecuted = false; accessor(_testClassInstance, (sender, args) => { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(TestClass.PrivateEventArgs)); }); _testClassInstance.InvokePrivateEvent(); Assert.IsTrue(eventExecuted); }
public void EventAdd_ByObjects_Protected() { var accessor = _testClassType.EventAdd("ProtectedEvent"); Assert.IsNotNull(accessor); var eventExecuted = false; accessor(_testClassInstance, (sender, args) => { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(TestClass.ProtectedEventArgs)); }); _testClassInstance.InvokeProtectedEvent(); Assert.IsTrue(eventExecuted); }
public void EventAdd_ByObjectAndType_Internal() { var accessor = _testClassType.EventAdd <TestClass.InternalEventArgs>("InternalEvent"); Assert.IsNotNull(accessor); var eventExecuted = false; accessor(_testClassInstance, (sender, args) => { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(TestClass.InternalEventArgs)); }); _testClassInstance.InvokeInternalEvent(); Assert.IsTrue(eventExecuted); }