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(); }
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(); }
public void Initial_reference_count_should_be_one() { var subject = new ReferenceCounted <IDisposable>(_mockDisposable.Object); subject.ReferenceCount.Should().Be(1); }