From 9547685b51206c30f17ace8d65f135ccd8cd2d58 Mon Sep 17 00:00:00 2001 From: JCH2k Date: Wed, 15 Jun 2022 14:21:53 +0200 Subject: [PATCH] Adapted test PR #57 --- .../IocValidatorTest.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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