|
|
|
@ -31,9 +31,13 @@ public class DisposeStrategyTest |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class TestNotDisposable |
|
|
|
private class TestNotDisposable; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
|
|
|
public interface IInterfaceSegregation : ITest; |
|
|
|
|
|
|
|
private class TestInterfaceSegregation : IInterfaceSegregation |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
public void Dispose() => throw new Exception(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -119,4 +123,15 @@ public class DisposeStrategyTest |
|
|
|
IocContainer iocContainer = new(); |
|
|
|
IocContainer iocContainer = new(); |
|
|
|
Assert.Throws<InvalidDisposeStrategyException>(() => iocContainer.Register(r => r.Add<TestNotDisposable>(Lifestyle.Singleton).WithDisposeStrategy(DisposeStrategy.Container))); |
|
|
|
Assert.Throws<InvalidDisposeStrategyException>(() => iocContainer.Register(r => r.Add<TestNotDisposable>(Lifestyle.Singleton).WithDisposeStrategy(DisposeStrategy.Container))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void TestValidDisposeStrategyForSingletonInterfaceSegregation() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IocContainer iocContainer = new(); |
|
|
|
|
|
|
|
iocContainer.Register(r => r.Add<ITest, IInterfaceSegregation, TestInterfaceSegregation>(Lifestyle.Singleton).WithDisposeStrategy(DisposeStrategy.Application)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iocContainer.Resolve<ITest>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.DoesNotThrow(() => iocContainer.Dispose()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |