Improve test coverage slightly

This commit is contained in:
Antony Male 2015-02-19 22:17:30 +00:00
parent ccc55dc800
commit 9ab3655c5f
3 changed files with 22 additions and 3 deletions

View File

@ -338,7 +338,7 @@ namespace StyletIoC.Internal
}
else
{
// This will throw a StyletIoCRegistrationException is GetSingle is requested
// This will throw a StyletIoCRegistrationException if GetSingle is requested
registrations = new EmptyRegistrationCollection(typeKey.Type);
}
}

View File

@ -20,10 +20,15 @@ namespace StyletUnitTests
this.C1Func = c1Func;
}
}
private interface I1 { }
public interface I1 { }
private class C11 : I1 { }
private class C12 : I1 { }
public interface I1Factory
{
I1 GetI1();
}
[Test]
public void FuncFactoryWorksForGetNoKey()
{
@ -101,5 +106,19 @@ namespace StyletUnitTests
Assert.IsInstanceOf<C11>(funcCollection[0]());
Assert.IsInstanceOf<C12>(funcCollection[1]());
}
[Test]
public void FuncFactoryOfAbstractFactoryWorksAsExpected()
{
var builder = new StyletIoCBuilder();
builder.Bind<I1>().To<C11>();
builder.Bind<I1Factory>().ToAbstractFactory();
var ioc = builder.BuildContainer();
var func = ioc.Get<Func<I1Factory>>();
Assert.IsNotNull(func);
var i1 = func().GetI1();
Assert.IsInstanceOf<C11>(i1);
}
}
}