public void CreateInstance_DefaultParameterlessConstructor() { var result = ConstructorDiscovery.CreateInstance(typeof(DummyClassWithDefaultParameterlessConstructor), null); Assert.NotNull(result); Assert.IsInstanceOf(typeof(DummyClassWithDefaultParameterlessConstructor), result); }
public void CreateInstance_ChildClassConstructor() { var arg = new ArgumentChildClass(); var result = ConstructorDiscovery.CreateInstance(typeof(DummyClassWithSingleArgConstructor), arg); Assert.NotNull(result); Assert.IsInstanceOf(typeof(DummyClassWithSingleArgConstructor), result); var typed = result as DummyClassWithSingleArgConstructor; Assert.False(typed.WithParentClass); Assert.True(typed.WithChildClass); }
public void CreateInstance_ParentAndChildClassConstructor_Ordered() { var arg1 = new ArgumentBaseClass(); var arg2 = new ArgumentChildClass(); var result = ConstructorDiscovery.CreateInstance(typeof(DummyClassWithSingleArgConstructor), arg1, arg2); Assert.NotNull(result); Assert.IsInstanceOf(typeof(DummyClassWithSingleArgConstructor), result); var typed = result as DummyClassWithSingleArgConstructor; Assert.True(typed.WithParentClass); Assert.True(typed.WithChildClass); }