public void AutodisposablesAreOnlyDisposedOnce() { //---------------Set up test pack------------------- var disposable = Substitute.For<IDisposable>(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var ad = new AutoDisposer(); ad.Add(disposable); ad.Dispose(); ad.Dispose(); //---------------Test Result ----------------------- disposable.Received(1).Dispose(); }
public void AutodisposablesAreOnlyDisposedOnce() { //---------------Set up test pack------------------- var disposable = Substitute.For <IDisposable>(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var ad = new AutoDisposer(); ad.Add(disposable); ad.Dispose(); ad.Dispose(); //---------------Test Result ----------------------- disposable.Received(1).Dispose(); }
public void Dispose() { lock (_lock) { _disposer?.Dispose(); _disposer = null; } }
public void Add_GenericVersion_ShouldReturnThing() { //---------------Set up test pack------------------- var disposer = new AutoDisposer(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var thing = disposer.Add(new SomeDisposable()); //---------------Test Result ----------------------- Assert.IsInstanceOf <SomeDisposable>(thing); Assert.IsFalse(thing.Disposed); disposer.Dispose(); Assert.IsTrue(thing.Disposed); }
public void Add_GenericVersion_ShouldReturnThing() { //---------------Set up test pack------------------- var disposer = new AutoDisposer(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var thing = disposer.Add(new SomeDisposable()); //---------------Test Result ----------------------- Assert.IsInstanceOf<SomeDisposable>(thing); Assert.IsFalse(thing.Disposed); disposer.Dispose(); Assert.IsTrue(thing.Disposed); }