|
|
|
|
@ -26,6 +26,7 @@ namespace Test.LightweightIocContainer |
|
|
|
|
ITest Create(string name); |
|
|
|
|
ITest Create(MultitonScope scope); |
|
|
|
|
ITest CreateTest(string name = null); |
|
|
|
|
ITest Create(byte id); |
|
|
|
|
|
|
|
|
|
void ClearMultitonInstance<T>(); |
|
|
|
|
} |
|
|
|
|
@ -61,6 +62,17 @@ namespace Test.LightweightIocContainer |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
private class TestByte : ITest |
|
|
|
|
{ |
|
|
|
|
private readonly byte _id; |
|
|
|
|
|
|
|
|
|
public TestByte(byte id) |
|
|
|
|
{ |
|
|
|
|
_id = id; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public class MultitonScope |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
@ -346,6 +358,18 @@ namespace Test.LightweightIocContainer |
|
|
|
|
Assert.IsInstanceOf<TestConstructor>(createdTest); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestResolveFromFactoryWithByte() |
|
|
|
|
{ |
|
|
|
|
_iocContainer.Register<ITest, TestByte>(); |
|
|
|
|
_iocContainer.RegisterFactory<ITestFactory>(); |
|
|
|
|
|
|
|
|
|
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>(); |
|
|
|
|
ITest createdTest = testFactory.Create(1); |
|
|
|
|
|
|
|
|
|
Assert.IsInstanceOf<TestByte>(createdTest); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestResolveMultitonFromFactory() |
|
|
|
|
{ |
|
|
|
|
|