- add failing test for openGeneric parameter validation

master
Simon G. 12 months ago
parent f855cb17a1
commit 4945fb8035
Signed by: SimonG
GPG Key ID: 0B82B964BA536523
  1. 26
      Test.LightweightIocContainer.Validation/IocValidatorTest.cs

@ -31,6 +31,9 @@ public class IocValidatorTest
[UsedImplicitly]
public interface IConstraint;
[UsedImplicitly]
public class Constraint : IConstraint;
[UsedImplicitly]
public interface IGenericTest<T> where T : IConstraint, new();
@ -44,6 +47,18 @@ public class IocValidatorTest
IGenericTest<T> Create<T>() where T : IConstraint, new();
}
[UsedImplicitly]
public interface IGenericParameter;
[UsedImplicitly]
public class GenericParameter : IGenericParameter
{
public GenericParameter(IGenericTest<Constraint> test)
{
}
}
[UsedImplicitly]
private class TestViewModelDontIgnoreDesignTimeCtor : ITest
{
@ -286,6 +301,17 @@ public class IocValidatorTest
validator.Validate();
}
[Test]
public void TestValidateOpenGenericTypeAsParameter()
{
IocContainer iocContainer = new();
iocContainer.Register(r => r.AddOpenGenerics(typeof(IGenericTest<>), typeof(GenericTest<>)));
iocContainer.Register(r => r.Add<IGenericParameter, GenericParameter>());
IocValidator validator = new(iocContainer);
validator.Validate();
}
private void AssertNoMatchingConstructorFoundForType<T>(AggregateException aggregateException)
{
Exception exception = aggregateException?.InnerExceptions[0];

Loading…
Cancel
Save