コード例 #1
0
        public void DisposingContainerCausesContainedObjectsToBeTornDown()
        {
            TestableRootCompositionContainer cc = new TestableRootCompositionContainer();
            MockTearDownStrategy strategy = new MockTearDownStrategy();
            cc.Builder.Strategies.Add(strategy, WCSFBuilderStage.PreCreation);

            cc.Dispose();

            Assert.IsTrue(strategy.TearDownCalled);
        }
コード例 #2
0
        public void TestServicesAreTornDownWhenContainerIsDisposed()
        {
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            MockService svc = container.Services.AddNew<MockService>();

            container.Dispose();

            Assert.IsTrue(svc.OnTearingDownCalled);
        }
コード例 #3
0
        public void ChildContainerAreDisposedWithParent()
        {
            TestableRootCompositionContainer parent = new TestableRootCompositionContainer();
            CompositionContainer child = parent.Containers.AddNew<CompositionContainer>();

            MockService svc = child.Services.AddNew<MockService>();
            parent.Dispose();

            Assert.IsTrue(svc.OnTearingDownCalled);
        }