public void TheUserIsRedirectedToTheWorkoutSummary() { var invoker = new Mock<ICommandInvoker>(); var controller = new AddController(invoker.Object, null); var input = new AddCardioInputModel { ExerciseId = 1, Level = 1, Duration = 45, Notes = string.Empty }; var result = (RedirectToRouteResult)controller.Cardio(input); result.RouteValues["action"].ShouldEqual("Index"); }
public void AnAddCommandIsSubmitted() { var invoker = new Mock<ICommandInvoker>(); var controller = new AddController(invoker.Object, null); var input = new AddCardioInputModel {ExerciseId = 1, Level = 1, Duration = 45, Notes = string.Empty}; var result = controller.Cardio(input); invoker.Verify(i => i.Execute(It.Is<AddCardioCommand>(cmd => cmd.Duration == input.Duration && cmd.ExerciseId == input.ExerciseId && cmd.Level == input.Level && cmd.Notes == input.Notes))); }
public void IfTheModelStateIsNotValidTheUserIsPromptedToReEnter() { var invoker = new Mock<ICommandInvoker>(); var controller = new AddController(invoker.Object, null); controller.ModelState.AddModelError("Level", "foo"); var input = new AddCardioInputModel { ExerciseId = 1, Level = 1, Duration = 45, Notes = string.Empty }; var res = (ViewResult) controller.Cardio(input); res.ViewName.ShouldEqual(""); }