Exemplo n.º 1
0
        public void SequenceHandlerExecutorTest()
        {
            var handler = new SequenceHandlerExecutor();

            Assert.True(handler is ICompositeHandler);
            Assert.True(handler is IAsyncRisible);

            Assert.False(handler is IRisible);
            Assert.False(handler is IMethodExecutable);
            Assert.False(handler is IParameterContainer);
            Assert.False(handler is ISkipReturnable);
            Assert.False(handler is IGenericRisible);
            Assert.False(handler is ICommandExecutable);
            Assert.False(handler is IAsyncGenericRisible);
            Assert.False(handler is ICompositeParallelHandler);
        }
Exemplo n.º 2
0
        public void ReturnParameterForSequenceAndParallelTest()
        {
            var view = new ViewWithButton {
                BindingContext = new ViewModelSimleHandling()
            };
            var behavior = new EventToMultipleHandlersBehavior {
                EventName = "Clicked"
            };
            var handlerWithReturn = new EventToMethodHandler <int> {
                MethodName = "MethodWithReturnInt"
            };
            var sequenceExecutor = new SequenceHandlerExecutor {
                WaitResult = true
            };
            var innerParallelExecutor = new ParallelHandlerExecutor {
                WaitResult = true
            };
            var handlerWithMethod = new EventToMethodHandler {
                MethodName = "Method"
            };

            var handlerWithReturnParameter1 = new EventToMethodHandler {
                MethodName = "MethodWithParameterInt"
            };
            var returnParameter1 = new ReturnParameter <int>();

            handlerWithReturnParameter1.Parameters.Add(returnParameter1);
            var handlerWithReturnParameter2 = new EventToMethodHandler {
                MethodName = "MethodWithParameterInt"
            };
            var returnParameter2 = new ReturnParameter <int>();

            handlerWithReturnParameter2.Parameters.Add(returnParameter2);
            var handlerWithReturnParameter3 = new EventToMethodHandler {
                MethodName = "MethodWithParameterInt"
            };
            var returnParameter3 = new ReturnParameter <int>();

            handlerWithReturnParameter3.Parameters.Add(returnParameter3);
            var handlerWithReturnParameter4 = new EventToMethodHandler {
                MethodName = "MethodWithParameterInt"
            };
            var returnParameter4 = new ReturnParameter <int>();

            handlerWithReturnParameter4.Parameters.Add(returnParameter4);

            behavior.Handlers.Add(handlerWithReturn);
            behavior.Handlers.Add(handlerWithMethod);
            behavior.Handlers.Add(new DelayEventHandler());
            behavior.Handlers.Add(sequenceExecutor);

            sequenceExecutor.Handlers.Add(handlerWithReturnParameter1);
            sequenceExecutor.Handlers.Add(handlerWithReturn);
            sequenceExecutor.Handlers.Add(handlerWithMethod);
            sequenceExecutor.Handlers.Add(innerParallelExecutor);

            innerParallelExecutor.Handlers.Add(handlerWithReturnParameter3);
            innerParallelExecutor.Handlers.Add(handlerWithReturn);
            innerParallelExecutor.Handlers.Add(handlerWithMethod);
            innerParallelExecutor.Handlers.Add(handlerWithReturnParameter4);

            sequenceExecutor.Handlers.Add(handlerWithReturnParameter2);

            view.Button.Behaviors.Add(behavior);

            view.Button.SendClicked();

            returnParameter1.GetValue().Should().Be(9);
            returnParameter2.GetValue().Should().Be(9);
            returnParameter3.GetValue().Should().Be(9);
            returnParameter4.GetValue().Should().Be(9);
        }