#61: add failing test

master
Simon G. 1 month ago
parent d6765ac85a
commit 41bae406c2
Signed by: SimonG
GPG Key ID: 0B82B964BA536523
  1. 19
      Test.LightweightIocContainer/DisposeStrategyTest.cs

@ -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());
}
} }
Loading…
Cancel
Save