public void VerifyGetNewDisposableObjectIdReturnsUniqueValues()
        {
            DisposableObjectId id1 = DisposableObjectManager.GetNewDisposableObjectId();
            DisposableObjectId id2 = DisposableObjectManager.GetNewDisposableObjectId();

            Assert.AreNotEqual(id1, id2);
        }
        public void VerifyAllObjectAreDisposedWhenManagerIsDisposed()
        {
            var manager = new DisposableObjectManager();

            var parent     = new ManagedDisposableObject();
            var child1     = new ManagedDisposableObject();
            var child2     = new ManagedDisposableObject();
            var child3     = new ManagedDisposableObject();
            var grandchild = new ManagedDisposableObject();

            manager.Register(parent);
            manager.RegisterAsDependent(child1, parent);
            manager.RegisterAsDependent(child2, parent);
            manager.RegisterAsDependent(child3, parent);
            manager.RegisterAsDependent(grandchild, child2);

            manager.Dispose();
            Assert.IsTrue(parent.WasDisposed);
            Assert.IsTrue(child1.WasDisposed);
            Assert.IsTrue(child2.WasDisposed);
            Assert.IsTrue(child3.WasDisposed);
            Assert.IsTrue(grandchild.WasDisposed);
        }
        public void VerifyDisposableObjectIdCompareToReturnsZeroForEqualIds()
        {
            DisposableObjectId id1 = DisposableObjectManager.GetNewDisposableObjectId();

            Assert.AreEqual(0, id1.CompareTo(id1));
        }
 public void Setup()
 {
     this.manager = new DisposableObjectManager();
 }
        public void VerifyAllObjectAreDisposedWhenManagerIsDisposed()
        {
            var manager = new DisposableObjectManager();

            var parent = new ManagedDisposableObject();
            var child1 = new ManagedDisposableObject();
            var child2 = new ManagedDisposableObject();
            var child3 = new ManagedDisposableObject();
            var grandchild = new ManagedDisposableObject();

            manager.Register(parent);
            manager.RegisterAsDependent(child1, parent);
            manager.RegisterAsDependent(child2, parent);
            manager.RegisterAsDependent(child3, parent);
            manager.RegisterAsDependent(grandchild, child2);

            manager.Dispose();
            Assert.IsTrue(parent.WasDisposed);
            Assert.IsTrue(child1.WasDisposed);
            Assert.IsTrue(child2.WasDisposed);
            Assert.IsTrue(child3.WasDisposed);
            Assert.IsTrue(grandchild.WasDisposed);
        }
 public ManagedDisposableObject()
 {
     this.WasDisposed = false;
     this.Id          = DisposableObjectManager.GetNewDisposableObjectId();
 }
 public void Setup()
 {
     this.manager = new DisposableObjectManager();
 }