Exemplo n.º 1
0
        public void ActionIsExecutedOnceWhenDisposeIsCalledTwice()
        {
            bool actionExecuted = false;
            IDisposable disposable = new ActionOnDispose(() => actionExecuted = true);
            Assert.IsFalse(actionExecuted);
            disposable.Dispose();
            Assert.IsTrue(actionExecuted);

            // the action should only fire the first time
            actionExecuted = false;
            disposable.Dispose();
            Assert.IsFalse(actionExecuted);
        }
Exemplo n.º 2
0
 public void ActionIsExecutedOnDisposeMethodCall()
 {
     bool actionExecuted = false;
     IDisposable disposable = new ActionOnDispose(() => actionExecuted = true);
     Assert.IsFalse(actionExecuted);
     disposable.Dispose();
     Assert.IsTrue(actionExecuted);
 }