diff --git a/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs b/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs index db34562..03665e6 100644 --- a/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs +++ b/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs @@ -40,11 +40,26 @@ public class OpenGenericRegistrationTest } + [UsedImplicitly] + public class CtorTest : ITest where T : IConstraint, new() + { + public CtorTest(T item) + { + + } + } + [UsedImplicitly] public interface ITestFactory { ITest Create() where T : IConstraint, new(); } + + [UsedImplicitly] + public interface ICtorTestFactory + { + ITest Create(T item) where T : IConstraint, new(); + } [SetUp] public void SetUp() => _iocContainer = new IocContainer(); @@ -90,6 +105,15 @@ public class OpenGenericRegistrationTest _iocContainer.Register(r => r.AddOpenGenerics(typeof(ITest<>), typeof(Test<>)).WithFactory()); ITestFactory testFactory = _iocContainer.Resolve(); ITest test = testFactory.Create(); - Assert.IsInstanceOf>(test); + Assert.IsInstanceOf>(test); + } + + [Test] + public void TestRegisterFactoryOfOpenGenericTypeWithCtorParameter() + { + _iocContainer.Register(r => r.AddOpenGenerics(typeof(ITest<>), typeof(CtorTest<>)).WithFactory()); + ICtorTestFactory testFactory = _iocContainer.Resolve(); + ITest test = testFactory.Create(new Constraint()); + Assert.IsInstanceOf>(test); } } \ No newline at end of file