Exemple #1
0
        public void Decrement_should_call_dispose_when_reference_count_is_zero()
        {
            var subject = new ReferenceCounted <IDisposable>(_mockDisposable.Object);

            subject.DecrementReferenceCount();

            subject.ReferenceCount.Should().Be(0);
            _mockDisposable.Verify(d => d.Dispose(), Times.Once);
        }
        public void Decrement_should_call_dispose_when_reference_count_is_zero()
        {
            var subject = new ReferenceCounted <IDisposable>(_disposable);

            subject.DecrementReferenceCount();

            subject.ReferenceCount.Should().Be(0);
            _disposable.Received().Dispose();
        }
Exemple #3
0
        public void Decrement_should_not_call_dispose_when_reference_count_is_greater_than_zero()
        {
            var subject = new ReferenceCounted <IDisposable>(_mockDisposable.Object);

            subject.IncrementReferenceCount();
            subject.DecrementReferenceCount();

            subject.ReferenceCount.Should().Be(1);
            _mockDisposable.Verify(d => d.Dispose(), Times.Never);
        }
        public void Decrement_should_not_call_dispose_when_reference_count_is_greater_than_zero()
        {
            var subject = new ReferenceCounted <IDisposable>(_disposable);

            subject.IncrementReferenceCount();
            subject.DecrementReferenceCount();

            subject.ReferenceCount.Should().Be(1);
            _disposable.DidNotReceive().Dispose();
        }