public void Dispose_ExecutesTheDelegate()
        {
            bool delegateExecuted = false;
            var  scope            = new DelegateBasedDisposable(() => delegateExecuted = true);

            Assert.That(delegateExecuted, Is.False);

            scope.Dispose();

            Assert.That(delegateExecuted, Is.True);
        }
        public void Dispose_Twice_SecondCallIsIgnored()
        {
            int delegateExecutionCount = 0;

            var scope = new DelegateBasedDisposable(() => ++ delegateExecutionCount);

            Assert.That(delegateExecutionCount, Is.EqualTo(0));

            scope.Dispose();
            scope.Dispose();

            Assert.That(delegateExecutionCount, Is.EqualTo(1));
        }