コード例 #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);
        }
コード例 #2
0
        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();
        }
コード例 #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);
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        public void Initial_reference_count_should_be_one()
        {
            var subject = new ReferenceCounted <IDisposable>(_mockDisposable.Object);

            subject.ReferenceCount.Should().Be(1);
        }