public void WhenDisposingTrait_ShouldDisposeChildren()
        {
            // Arrange
            var vm                = new StubObservableObject();
            var trait             = new StubViewModelTrait(vm);
            var aDisposableObject = new StubDisposable();

            aDisposableObject.DisposeWith(trait);

            trait.Dispose();

            Assert.That(trait.IsDisposed, Is.True, "Trait");
            Assert.That(aDisposableObject.IsDisposed, Is.True, "Child");
        }
Esempio n. 2
0
        public void WhenDisposingParentShouldDispose()
        {
            // Arrange
            var container  = new UnityContainer();
            var parent     = new StubObservableObject();
            var collection = new ViewModelTraitCollection(parent, new TraitDependencyResolver(container));
            var child      = new StubDisposable();

            // Act
            var b0 = collection.Add <StubViewModelTrait>();

            child.DisposeWith(b0);
            parent.Dispose();

            // Assert
            Assert.That(parent.IsDisposed, Is.True);
            Assert.That(b0.IsDisposed, Is.True);
            Assert.That(child.IsDisposed, Is.True);
        }