|
|
|
|
@ -2,7 +2,6 @@ |
|
|
|
|
// Created: 2019-06-06 |
|
|
|
|
// Copyright(c) 2019 SimonG. All Rights Reserved. |
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using JetBrains.Annotations; |
|
|
|
|
using LightweightIocContainer; |
|
|
|
|
using LightweightIocContainer.Exceptions; |
|
|
|
|
@ -21,7 +20,7 @@ namespace Test.LightweightIocContainer |
|
|
|
|
|
|
|
|
|
private interface ITest |
|
|
|
|
{ |
|
|
|
|
void DoSomething(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private interface IFoo |
|
|
|
|
@ -36,10 +35,7 @@ namespace Test.LightweightIocContainer |
|
|
|
|
|
|
|
|
|
private class Test : ITest |
|
|
|
|
{ |
|
|
|
|
public void DoSomething() |
|
|
|
|
{ |
|
|
|
|
throw new Exception(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
@ -59,17 +55,6 @@ namespace Test.LightweightIocContainer |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestOnCreate() |
|
|
|
|
{ |
|
|
|
|
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object); |
|
|
|
|
IRegistrationBase<ITest> testRegistration = registrationFactory.Register<ITest, Test>(Lifestyle.Transient).OnCreate(t => t.DoSomething()); |
|
|
|
|
|
|
|
|
|
ITest test = new Test(); |
|
|
|
|
|
|
|
|
|
Assert.Throws<Exception>(() => testRegistration.OnCreateAction(test)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestWithParameters() |
|
|
|
|
{ |
|
|
|
|
|