public void Dispose_ShouldNotRecallDisposeActionWhenCalledAgain() { //---------------Set up test pack------------------- var disposeCalls = 0; var sut = new AutoResetter(() => { }, () => disposeCalls++); //---------------Assert Precondition---------------- Expect(disposeCalls).To.Equal(0); //---------------Execute Test ---------------------- sut.Dispose(); sut.Dispose(); //---------------Test Result ----------------------- Expect(disposeCalls).To.Equal(1); }
public void Dispose_ShouldOnlyCallActionOfT_Once() { //---------------Set up test pack------------------- var disposeCalls = 0; var sut = new AutoResetter <int>(() => 0, v => disposeCalls++); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- sut.Dispose(); Expect(disposeCalls).To.Equal(1); sut.Dispose(); //---------------Test Result ----------------------- Expect(disposeCalls).To.Equal(1); }
public void Dispose_ShouldCallDisposalActionExactlyOnce() { //---------------Set up test pack------------------- var disposeCalls = 0; var sut = new AutoResetter(() => { }, () => disposeCalls++); //---------------Assert Precondition---------------- Expect(disposeCalls).To.Equal(0); //---------------Execute Test ---------------------- sut.Dispose(); //---------------Test Result ----------------------- Expect(disposeCalls).To.Equal(1); }