Exemple #1
0
        public object Execute(IRequest request, IEndpointAction action)
        {
            var    instance   = _resolver.GetInstance(action.EndpointType);
            object inputModel = null;

            if (action.InputModelType != null)
            {
                inputModel = _resolver.GetInstance(action.InputModelType);
                _modelBindingController.Bind(request, inputModel);
            }

            return(action.Run(instance, inputModel));
        }
Exemple #2
0
        public ActionExecutorTests()
        {
            var resolver = Substitute.For <IRequestResolver>();

            resolver.GetInstance(Arg.Any <Type>()).Returns(new object());
            resolver.GetInstance(null).Returns(x => { throw new Exception(); });

            _action = Substitute.For <IEndpointAction>();

            _action.EndpointType.Returns(typeof(TestEndpoint));
            _action.Run(Arg.Any <object>(), Arg.Any <object>()).Returns(new TestViewModel());

            var executor = new ActionExecutor(resolver, Substitute.For <IModelBindingController>());

            _runTest = () => executor.Execute(Substitute.For <IRequest>(), _action);
        }