diff --git a/Test.LightweightIocContainer/IocValidatorTest.cs b/Test.LightweightIocContainer/IocValidatorTest.cs index 181308e..7af50ee 100644 --- a/Test.LightweightIocContainer/IocValidatorTest.cs +++ b/Test.LightweightIocContainer/IocValidatorTest.cs @@ -68,7 +68,9 @@ namespace Test.LightweightIocContainer IocValidator validator = new(iocContainer); - validator.Validate(); + var aggregateException = Assert.Throws(() => validator.Validate()); + + AssertNoMatchingConstructorFoundForType(aggregateException); } [Test] @@ -108,13 +110,18 @@ namespace Test.LightweightIocContainer IocValidator validator = new(iocContainer); - AggregateException aggregateException = Assert.Throws(() => validator.Validate()); + var aggregateException = Assert.Throws(() => validator.Validate()); - Exception exception = aggregateException?.InnerExceptions[0]; + AssertNoMatchingConstructorFoundForType(aggregateException); + } + + private static void AssertNoMatchingConstructorFoundForType(AggregateException aggregateException) + { + Exception exception = aggregateException?.InnerExceptions[0]; Assert.IsInstanceOf(exception); - - NoMatchingConstructorFoundException noMatchingConstructorFoundException = (NoMatchingConstructorFoundException) exception; - Assert.AreEqual(typeof(Test), noMatchingConstructorFoundException?.Type); + + NoMatchingConstructorFoundException noMatchingConstructorFoundException = (NoMatchingConstructorFoundException)exception; + Assert.AreEqual(typeof(T), noMatchingConstructorFoundException?.Type); } } } \ No newline at end of file