diff --git a/Test.LightweightIocContainer/DisposeStrategyTest.cs b/Test.LightweightIocContainer/DisposeStrategyTest.cs index 565d7bd..e60a781 100644 --- a/Test.LightweightIocContainer/DisposeStrategyTest.cs +++ b/Test.LightweightIocContainer/DisposeStrategyTest.cs @@ -13,7 +13,11 @@ namespace Test.LightweightIocContainer; public class DisposeStrategyTest { [UsedImplicitly] - public interface ITest : IDisposable; + public interface ITest : IDisposable + { + + } + private class Test : ITest { public void Dispose() => throw new Exception(); @@ -29,6 +33,14 @@ public class DisposeStrategyTest private class TestNotDisposable; + [UsedImplicitly] + public interface IInterfaceSegregation : ITest; + private class TestInterfaceSegregation : IInterfaceSegregation + { + public void Dispose() => throw new Exception(); + } + + [Test] public void TestValidContainerDisposeStrategySingleton() { @@ -111,4 +123,15 @@ public class DisposeStrategyTest IocContainer iocContainer = new(); Assert.Throws(() => iocContainer.Register(r => r.Add(Lifestyle.Singleton).WithDisposeStrategy(DisposeStrategy.Container))); } + + [Test] + public void TestValidDisposeStrategyForSingletonInterfaceSegregation() + { + IocContainer iocContainer = new(); + iocContainer.Register(r => r.Add(Lifestyle.Singleton).WithDisposeStrategy(DisposeStrategy.Application)); + + iocContainer.Resolve(); + + Assert.DoesNotThrow(() => iocContainer.Dispose()); + } } \ No newline at end of file diff --git a/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs b/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs index a1d162f..b6adda7 100644 --- a/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs +++ b/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs @@ -147,15 +147,4 @@ public class IocContainerInterfaceSegregationTest Assert.That(anotherBar, Is.SameAs(foo)); Assert.That(anotherOne, Is.SameAs(foo)); } - - [Test] - public void TestValidDisposeStrategyForSingleton() - { - IocContainer iocContainer = new(); - iocContainer.Register(r => r.Add(Lifestyle.Singleton).WithDisposeStrategy(DisposeStrategy.Application)); - - iocContainer.Resolve(); - - Assert.DoesNotThrow(() => iocContainer.Dispose()); - } } \ No newline at end of file