Revert "#61: move test"

This reverts commit 6b74419932.
master
Simon G. 1 month ago
parent 6b74419932
commit 1e92358719
Signed by: SimonG
GPG Key ID: 0B82B964BA536523
  1. 25
      Test.LightweightIocContainer/DisposeStrategyTest.cs
  2. 11
      Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs

@ -13,7 +13,11 @@ namespace Test.LightweightIocContainer;
public class DisposeStrategyTest public class DisposeStrategyTest
{ {
[UsedImplicitly] [UsedImplicitly]
public interface ITest : IDisposable; public interface ITest : IDisposable
{
}
private class Test : ITest private class Test : ITest
{ {
public void Dispose() => throw new Exception(); public void Dispose() => throw new Exception();
@ -29,6 +33,14 @@ public class DisposeStrategyTest
private class TestNotDisposable; private class TestNotDisposable;
[UsedImplicitly]
public interface IInterfaceSegregation : ITest;
private class TestInterfaceSegregation : IInterfaceSegregation
{
public void Dispose() => throw new Exception();
}
[Test] [Test]
public void TestValidContainerDisposeStrategySingleton() public void TestValidContainerDisposeStrategySingleton()
{ {
@ -111,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());
}
} }

@ -147,15 +147,4 @@ public class IocContainerInterfaceSegregationTest
Assert.That(anotherBar, Is.SameAs(foo)); Assert.That(anotherBar, Is.SameAs(foo));
Assert.That(anotherOne, Is.SameAs(foo)); Assert.That(anotherOne, Is.SameAs(foo));
} }
[Test]
public void TestValidDisposeStrategyForSingleton()
{
IocContainer iocContainer = new();
iocContainer.Register(r => r.Add<IFoo, IBar, Foo>(Lifestyle.Singleton).WithDisposeStrategy(DisposeStrategy.Application));
iocContainer.Resolve<IFoo>();
Assert.DoesNotThrow(() => iocContainer.Dispose());
}
} }
Loading…
Cancel
Save