Пример #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 BusyIndicatorIsSetToIdleAlthoughTheInnerResultIsCancelled()
        {
            BusyIndicatorMock.Setup(x => x.Idle())
                .Verifiable();

            var inner = TestHelper.MockResult(false, new Exception()).Object;
            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();
        }
Пример #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();
        }
Пример #4
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);
            }
        }