예제 #1
0
        public void ReturnParameterMultipleSkipableTest()
        {
            var view = new ViewWithButton {
                BindingContext = new ViewModelSimleHandling()
            };
            var behavior = new EventToMultipleHandlersBehavior {
                EventName = "Clicked"
            };
            var handlerWithReturn = new EventToMethodHandler <int> {
                MethodName = "MethodWithReturnInt"
            };
            var handlerWithReturnParameter = new EventToMethodHandler {
                MethodName = "MethodWithParameterInt"
            };
            var returnParameter = new ReturnParameter <int>();

            handlerWithReturnParameter.Parameters.Add(returnParameter);
            behavior.Handlers.Add(handlerWithReturn);
            behavior.Handlers.Add(new DelayEventHandler());
            behavior.Handlers.Add(new DelayEventHandler());
            behavior.Handlers.Add(new DelayEventHandler());
            behavior.Handlers.Add(handlerWithReturnParameter);
            view.Button.Behaviors.Add(behavior);

            view.Button.SendClicked();

            returnParameter.GetValue().Should().Be(9);
            view.BindingContext.GetFieldValue("_parameterValue").Should().Be(9);
        }
예제 #2
0
        public void ReturnParameterForParallelTest()
        {
            var view = new ViewWithButton {
                BindingContext = new ViewModelSimleHandling()
            };
            var behavior = new EventToMultipleHandlersBehavior {
                EventName = "Clicked"
            };
            var handlerWithReturn = new EventToMethodHandler <int> {
                MethodName = "MethodWithReturnInt"
            };
            var parallelExecutor      = new ParallelHandlerExecutor();
            var innerParallelExecutor = new ParallelHandlerExecutor();
            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);

            parallelExecutor.Handlers.Add(handlerWithReturnParameter1);
            parallelExecutor.Handlers.Add(handlerWithMethod);
            parallelExecutor.Handlers.Add(innerParallelExecutor);
            parallelExecutor.Handlers.Add(handlerWithReturnParameter2);

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

            behavior.Handlers.Add(handlerWithReturn);
            behavior.Handlers.Add(handlerWithMethod);
            behavior.Handlers.Add(new DelayEventHandler());
            behavior.Handlers.Add(parallelExecutor);
            view.Button.Behaviors.Add(behavior);

            view.Button.SendClicked();

            returnParameter1.GetValue().Should().Be(9);
            returnParameter2.GetValue().Should().Be(9);
            returnParameter3.GetValue().Should().Be(9);
        }
예제 #3
0
        public void ReturnParameterTest()
        {
            var intParameter    = new ReturnParameter <int>();
            var stringParameter = new ReturnParameter <string>();

            intParameter.SetReturnValue(3);
            stringParameter.SetReturnValue("qwerty1234");

            intParameter.GetParamType().Should().BeAssignableTo <int>();
            intParameter.GetValue().Should().Be(3);
            intParameter.Should().BeAssignableTo <IReturnable>();

            stringParameter.GetParamType().Should().BeAssignableTo <string>();
            stringParameter.GetValue().Should().Be("qwerty1234");
            stringParameter.Should().BeAssignableTo <IReturnable>();
        }