From cd4b80de5b06307b67f8fa18823f104426960734 Mon Sep 17 00:00:00 2001 From: Simon G Date: Wed, 29 Jan 2020 14:24:59 +0100 Subject: [PATCH] close #35: add test to check that NoMatchingConstructorException is not thrown wronly - remove TESTME --- LightweightIocContainer/IocContainer.cs | 2 +- .../IocContainerTest.cs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index d8f5630..43e9c84 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -499,7 +499,7 @@ namespace LightweightIocContainer if (!sortedConstructors.Any()) //no public constructor available throw new NoPublicConstructorFoundException(type); - NoMatchingConstructorFoundException noMatchingConstructorFoundException = null; //TestMe: Is this thrown when a matching constructor is found but first a non matching one is found? + NoMatchingConstructorFoundException noMatchingConstructorFoundException = null; foreach (ConstructorInfo ctor in sortedConstructors) { diff --git a/Test.LightweightIocContainer/IocContainerTest.cs b/Test.LightweightIocContainer/IocContainerTest.cs index c9b855d..da80733 100644 --- a/Test.LightweightIocContainer/IocContainerTest.cs +++ b/Test.LightweightIocContainer/IocContainerTest.cs @@ -82,6 +82,20 @@ namespace Test.LightweightIocContainer } } + [UsedImplicitly] + private class TestMultipleConstructors : ITest + { + public TestMultipleConstructors(string name, bool success) + { + + } + + public TestMultipleConstructors(string name) + { + + } + } + [UsedImplicitly] private class TestByte : ITest { @@ -322,6 +336,13 @@ namespace Test.LightweightIocContainer Assert.AreEqual(typeof(TestConstructor), exception.Type); } + [Test] + public void TestResolveNoMatchingConstructorNotThrownWrongly() + { + _iocContainer.Register(); + Assert.DoesNotThrow(() => _iocContainer.Resolve("Name")); + } + [Test] public void TestResolvePrivateConstructor() {