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

            // the action should only fire the first time
            actionExecuted = false;
            disposable.Dispose();
            Assert.False(actionExecuted);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public void ActionIsExecutedOnDisposeMethodCall()
 {
     bool actionExecuted = false;
     IDisposable disposable = new ActionOnDispose(() => actionExecuted = true);
     Assert.False(actionExecuted);
     disposable.Dispose();
     Assert.True(actionExecuted);
 }
Ejemplo n.º 4
0
        public void ActionIsExecutedOnDisposeMethodCall()
        {
            bool        actionExecuted = false;
            IDisposable disposable     = new ActionOnDispose(() => actionExecuted = true);

            Assert.IsFalse(actionExecuted);
            disposable.Dispose();
            Assert.IsTrue(actionExecuted);
        }