Ejemplo n.º 1
0
        private ActionResult PostArrangeExecute(bool executeCommandContainsError = false)
        {
            var routeData = new RouteData();

            routeData.Values.Add("controller", "DummyReadExecute");
            _controller.ControllerContext = new ControllerContext
            {
                RouteData = routeData
            };
            var form = new FormCollection();

            _controller.ValueProvider = form.ToValueProvider();

            _viewModelFactory
            .Stub(x => x.GetViewModel())
            .Return(new DummyReadExecuteViewModel());

            _commandExecutor
            .Stub(x => x.ExecuteCommand(Arg <DummyReadExecuteCommand> .Is.Anything))
            .Return(new CommandResult
            {
                ContainsError = executeCommandContainsError
            });

            return(_controller.Execute(form));
        }
        private ActionResult ArrangeAndAct_WhenModelStateIsValid()
        {
            var mapper = MockRepository.GenerateMock <IViewModelToCommandMappingEngine>();
            var mockedServiceLocator = MockRepository.GenerateMock <IServiceLocator>();

            mockedServiceLocator
            .Stub(x => x.GetInstance <IViewModelToCommandMappingEngine>())
            .Return(mapper);
            ServiceLocator.SetLocatorProvider(() => mockedServiceLocator);
            _commandExecutor
            .Stub(x => x.ExecuteCommand <DummyExecuteCommand>(null))
            .IgnoreArguments()
            .Return(new CommandResult
            {
                ContainsError = false,
                Message       = "Success"
            });

            _referrerProvider
            .Stub(x => x.GetAbsoluteUri())
            .Return("localhost");

            return(_controller.Execute(new DummyExecuteViewModel()));
        }