diff --git a/Test.LightweightIocContainer.Validation/IocValidatorTest.cs b/Test.LightweightIocContainer.Validation/IocValidatorTest.cs index f4e8b4d..98ca6c8 100644 --- a/Test.LightweightIocContainer.Validation/IocValidatorTest.cs +++ b/Test.LightweightIocContainer.Validation/IocValidatorTest.cs @@ -31,6 +31,30 @@ public class IocValidatorTest { public Test(IParameter parameter) => parameter.Method(); } + + [UsedImplicitly] + public interface IConstraint + { + + } + + [UsedImplicitly] + public interface IGenericTest where T : IConstraint, new() + { + + } + + [UsedImplicitly] + public class GenericTest : IGenericTest where T : IConstraint, new() + { + + } + + [UsedImplicitly] + public interface IGenericTestFactory + { + IGenericTest Create() where T : IConstraint, new(); + } [UsedImplicitly] private class TestViewModelDontIgnoreDesignTimeCtor : ITest @@ -264,6 +288,16 @@ public class IocValidatorTest AssertNoMatchingConstructorFoundForType(aggregateException); } + [Test] + public void TestValidateFactoryOfOpenGenericType() + { + IocContainer iocContainer = new(); + iocContainer.Register(r => r.AddOpenGenerics(typeof(IGenericTest<>), typeof(GenericTest<>)).WithFactory()); + + IocValidator validator = new(iocContainer); + validator.Validate(); + } + private void AssertNoMatchingConstructorFoundForType(AggregateException aggregateException) { Exception exception = aggregateException?.InnerExceptions[0];