close #35: add test to check that NoMatchingConstructorException is not thrown wronly

- remove TESTME
pull/43/head
Simon G 6 years ago
parent ea6b26abce
commit cd4b80de5b
  1. 2
      LightweightIocContainer/IocContainer.cs
  2. 21
      Test.LightweightIocContainer/IocContainerTest.cs

@ -499,7 +499,7 @@ namespace LightweightIocContainer
if (!sortedConstructors.Any()) //no public constructor available if (!sortedConstructors.Any()) //no public constructor available
throw new NoPublicConstructorFoundException(type); 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) foreach (ConstructorInfo ctor in sortedConstructors)
{ {

@ -82,6 +82,20 @@ namespace Test.LightweightIocContainer
} }
} }
[UsedImplicitly]
private class TestMultipleConstructors : ITest
{
public TestMultipleConstructors(string name, bool success)
{
}
public TestMultipleConstructors(string name)
{
}
}
[UsedImplicitly] [UsedImplicitly]
private class TestByte : ITest private class TestByte : ITest
{ {
@ -322,6 +336,13 @@ namespace Test.LightweightIocContainer
Assert.AreEqual(typeof(TestConstructor), exception.Type); Assert.AreEqual(typeof(TestConstructor), exception.Type);
} }
[Test]
public void TestResolveNoMatchingConstructorNotThrownWrongly()
{
_iocContainer.Register<ITest, TestMultipleConstructors>();
Assert.DoesNotThrow(() => _iocContainer.Resolve<ITest>("Name"));
}
[Test] [Test]
public void TestResolvePrivateConstructor() public void TestResolvePrivateConstructor()
{ {

Loading…
Cancel
Save