|
|
|
|
@ -32,6 +32,30 @@ public class IocValidatorTest |
|
|
|
|
public Test(IParameter parameter) => parameter.Method(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
public interface IConstraint |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
public interface IGenericTest<T> where T : IConstraint, new() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
public class GenericTest<T> : IGenericTest<T> where T : IConstraint, new() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
public interface IGenericTestFactory |
|
|
|
|
{ |
|
|
|
|
IGenericTest<T> Create<T>() where T : IConstraint, new(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
private class TestViewModelDontIgnoreDesignTimeCtor : ITest |
|
|
|
|
{ |
|
|
|
|
@ -264,6 +288,16 @@ public class IocValidatorTest |
|
|
|
|
AssertNoMatchingConstructorFoundForType<Test>(aggregateException); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestValidateFactoryOfOpenGenericType() |
|
|
|
|
{ |
|
|
|
|
IocContainer iocContainer = new(); |
|
|
|
|
iocContainer.Register(r => r.AddOpenGenerics(typeof(IGenericTest<>), typeof(GenericTest<>)).WithFactory<IGenericTestFactory>()); |
|
|
|
|
|
|
|
|
|
IocValidator validator = new(iocContainer); |
|
|
|
|
validator.Validate(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void AssertNoMatchingConstructorFoundForType<T>(AggregateException aggregateException) |
|
|
|
|
{ |
|
|
|
|
Exception exception = aggregateException?.InnerExceptions[0]; |
|
|
|
|
|