Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
0
        public override IEnumerable <IResult> Decorate(IEnumerable <IResult> coroutine, ActionExecutionContext context)
        {
            var inner = new SequentialResult(coroutine.GetEnumerator());

            if (!String.IsNullOrWhiteSpace(Message))
            {
                var busyDecorator = new BusyResultDecorator(inner, Message);
                if (BusyIndicatorImplementation != null)
                {
                    busyDecorator.In(BusyIndicatorImplementation);
                }

                yield return(busyDecorator);
            }
            else
            {
                yield return(new WorkerThreadResultDecorator(inner));
            }
        }
Exemplo n.º 4
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();
        }