public void ActionIsExecutedOnDisposeMethodCall()
 {
     bool actionExecuted = false;
     IDisposable disposable = new ActionOnDispose(() => actionExecuted = true);
     Assert.IsFalse(actionExecuted);
     disposable.Dispose();
     Assert.IsTrue(actionExecuted);
 }
        public void ActionIsExecutedPostUsing()
        {
            bool actionExecuted = false;
            using (IDisposable disposable = new ActionOnDispose(() => actionExecuted = true))
            {
                Assert.IsFalse(actionExecuted);
            }

            Assert.IsTrue(actionExecuted);
        }
        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);
        }