Exemplo n.º 1
0
 public void MultipleDisposal()
 {
     var t = new TestDisposableObject();
     t.Dispose();
     t.Dispose();
     Assert.That(t.DisposeUnmanagedResourcesCount, Is.EqualTo(1));
     Assert.That(t.DisposeManagedResourcesCount, Is.EqualTo(1));
 }
Exemplo n.º 2
0
        public void Dispose_CalledExplicitly()
        {
            //Act
            TestDisposableObject target = new TestDisposableObject();

            target.Dispose();

            //Assert
            target.IsDisposed.Should().BeTrue();
        }
Exemplo n.º 3
0
        public void Dispose_CalledExplicitlyAndWithUsing()
        {
            //Act
            TestDisposableObject target = null;

            using (target = new TestDisposableObject())
            {
                target.Dispose();
            };

            //Assert
            target.IsDisposed.Should().BeTrue();
            target.DisposeCount.Should().Be(1);
        }
Exemplo n.º 4
0
        public void Clear_ValidCollectionWithDisposedObjectsIsDisposed()
        {
            var expected = new TestDisposableObject();
            var target   = new DisposableCollection();

            target.Add(expected);

            //Act
            expected.Dispose();
            target.Clear();

            //Assert
            expected.IsDisposed.Should().BeTrue();
        }