예제 #1
0
        public void BusyIndicatorIsSetToBusyBeforeTheInnerResultGetsExecuted()
        {
            bool isInnerExecuted = false;

            BusyIndicatorMock.Setup(x => x.Busy(It.IsAny <string>()))
            .Callback(() => Assert.IsFalse(isInnerExecuted, "BusyIndicator set busy to busy after inner result was executed"));

            var inner = new DelegateResult(() => isInnerExecuted = true);
            var sut   = new BusyResultDecorator(inner, "foo")
                        .In(BusyIndicator);

            sut.Execute(null);

            BusyIndicatorMock.VerifyAll();
        }
예제 #2
0
        public void BusyIndicatorGetsSetToIdle()
        {
            BusyIndicatorMock.Setup(x => x.Idle())
            .Verifiable();

            var waitHandle = new ManualResetEvent(false);
            var inner      = TestHelper.ThrowingResult(new Exception()).Object;
            var sut        = new BusyResultDecorator(inner, "foo")
                             .In(BusyIndicator);

            sut.Completed += (sender, args) => waitHandle.Set();

            sut.Execute(null);
            waitHandle.WaitOne(3000);

            BusyIndicatorMock.VerifyAll();
        }
예제 #3
0
        public void BusyIndicatorIsSetToIdleAfterTheInnerResultCompleted()
        {
            bool isInnerCompleted = false;

            BusyIndicatorMock.Setup(x => x.Idle())
            .Callback(() => Assert.IsTrue(isInnerCompleted, "BusyIndicator set busy to idle before inner result completed"));

            var inner = new DelegateResult(() => { });

            inner.Completed += (sender, args) => { isInnerCompleted = true; };
            var sut = new BusyResultDecorator(inner, "foo")
                      .In(BusyIndicator);
            var waitHandle = new ManualResetEvent(false);

            sut.Completed += (sender, args) => waitHandle.Set();

            sut.Execute(null);
            waitHandle.WaitOne(3000);

            BusyIndicatorMock.VerifyAll();
        }