Skip to content

Commit

Permalink
Added more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Mar 17, 2017
1 parent ac4e6de commit 82bf298
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/stashbox.tests/DecoratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,31 @@ public void DecoratorTests_Multiple()
}
}

[TestMethod]
public void DecoratorTests_Multiple_Scoped()
{
using (var container = new StashboxContainer())
{
container.RegisterScoped<ITest1, Test1>();
container.RegisterDecorator<ITest1, TestDecorator1>();
container.RegisterDecorator<ITest1, TestDecorator2>();

using (var child = container.BeginScope())
{
var test = child.Resolve<ITest1>();

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
Expand Down
20 changes: 20 additions & 0 deletions src/stashbox.tests/DisposeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down

0 comments on commit 82bf298

Please sign in to comment.