From 82bf298d3a4abe37bd1eebafc13af0f791882116 Mon Sep 17 00:00:00 2001 From: Peter Csajtai Date: Fri, 17 Mar 2017 23:03:40 +0100 Subject: [PATCH] Added more unit tests --- src/stashbox.tests/DecoratorTests.cs | 25 +++++++++++++++++++++++++ src/stashbox.tests/DisposeTests.cs | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/stashbox.tests/DecoratorTests.cs b/src/stashbox.tests/DecoratorTests.cs index ddb63d33..2f945e7f 100644 --- a/src/stashbox.tests/DecoratorTests.cs +++ b/src/stashbox.tests/DecoratorTests.cs @@ -174,6 +174,31 @@ public void DecoratorTests_Multiple() } } + [TestMethod] + public void DecoratorTests_Multiple_Scoped() + { + using (var container = new StashboxContainer()) + { + container.RegisterScoped(); + container.RegisterDecorator(); + container.RegisterDecorator(); + + using (var child = container.BeginScope()) + { + var test = child.Resolve(); + + Assert.IsNotNull(test); + Assert.IsInstanceOfType(test, typeof(TestDecorator2)); + + Assert.IsNotNull(test.Test); + Assert.IsInstanceOfType(test.Test, typeof(TestDecorator1)); + + Assert.IsNotNull(test.Test.Test); + Assert.IsInstanceOfType(test.Test.Test, typeof(Test1)); + } + } + } + public interface ITest1 { ITest1 Test { get; } } public class Test1 : ITest1 diff --git a/src/stashbox.tests/DisposeTests.cs b/src/stashbox.tests/DisposeTests.cs index c446ef36..bd9e5c16 100644 --- a/src/stashbox.tests/DisposeTests.cs +++ b/src/stashbox.tests/DisposeTests.cs @@ -224,6 +224,26 @@ public void DisposeTests_TrackTransientDisposal_Scoped_Transient_Singleton() Assert.IsTrue(test6.Test1.Disposed); } + [TestMethod] + public void DisposeTests_Instance_TrackTransient() + { + ITest1 test = new Test1(); + using (var container = new StashboxContainer(config => config.WithDisposableTransientTracking())) + container.RegisterInstance(test); + + Assert.IsTrue(test.Disposed); + } + + [TestMethod] + public void DisposeTests_WireUp_TrackTransient() + { + ITest1 test = new Test1(); + using (var container = new StashboxContainer(config => config.WithDisposableTransientTracking())) + container.WireUp(test); + + Assert.IsTrue(test.Disposed); + } + public interface ITest11 { } public interface ITest12 { }