public void DisposeTwiceDoesNotThrowException() { var node = new DummyNavigable("node"); node.Dispose(); Assert.That(node.Dispose, Throws.Nothing); }
public void DisposeChangesProperty() { var node = new DummyNavigable("node"); Assert.That(node.Disposed, Is.False); node.Dispose(); Assert.That(node.Disposed, Is.True); }
public void RemoveChildrenAfterDisposeThrowsException() { var node = new DummyNavigable("node"); node.Add(new DummyNavigable("child")); node.Dispose(); Assert.That(node.RemoveChildren, Throws.TypeOf <ObjectDisposedException>()); }
public void AddThrowsExceptionAfterDispose() { var node = new DummyNavigable("MyParent"); DummyNavigable child = null; node.Dispose(); Assert.That( () => node.Add(child), Throws.TypeOf <ObjectDisposedException>()); }
public void RemoveChildByNameThrowsWhenDisposed() { var node = new DummyNavigable("My parent"); var child1 = new DummyNavigable("Child1"); node.Add(child1); node.Dispose(); Assert.That( () => node.Remove("Child1"), Throws.InstanceOf <ObjectDisposedException>()); }
public void AddChildrenThrowsExceptionAfterDispose() { var node = new DummyNavigable("MyParent"); var children = new List <DummyNavigable> { new DummyNavigable("child") }; node.Dispose(); Assert.That( () => node.Add(children), Throws.TypeOf <ObjectDisposedException>()); }
public void SortChildrenAfterDisposeThrowsException() { var node = new DummyNavigable("node"); using var child = new DummyNavigable("child"); node.Add(child); node.Dispose(); Assert.That(() => node.SortChildren(), Throws.TypeOf <ObjectDisposedException>()); Assert.That(() => node.SortChildren(new ReverseNodeComparer()), Throws.TypeOf <ObjectDisposedException>()); Assert.That( () => node.SortChildren((x, y) => string.Compare(y.Name, x.Name, StringComparison.CurrentCulture)), Throws.TypeOf <ObjectDisposedException>()); }
public void DisposeRemoveChildrens() { DummyNavigable parent = new DummyNavigable("Parent"); DummyNavigable child1 = new DummyNavigable("Child1"); DummyNavigable child2 = new DummyNavigable("Child2"); DummyNavigable subchild1 = new DummyNavigable("Subchild1"); child1.Add(subchild1); parent.Add(child1); parent.Add(child2); parent.Dispose(); Assert.IsEmpty(parent.Children); Assert.IsEmpty(child1.Children); Assert.IsTrue(parent.Disposed); Assert.IsTrue(child1.Disposed); Assert.IsTrue(child2.Disposed); Assert.IsTrue(subchild1.Disposed); }