コード例 #1
0
            public void AnAddStrengthCommandIsSubmitted()
            {
                var invoker = new Mock<ICommandInvoker>();
                var controller = new AddController(invoker.Object, null);
                var input = new AddStrengthInputModel {ExerciseId = 2, Notes = "f", Repetitions = 10, Weight = 185};

                var result = controller.Strength(input);

                invoker.Verify(i =>i.Execute(It.Is<AddStrengthCommand>(cmd =>
                            cmd.ExerciseId == input.ExerciseId && cmd.Notes == input.Notes &&
                            cmd.Repetitions == input.Repetitions && cmd.Weight == input.Weight)));
            }
コード例 #2
0
ファイル: AddController.cs プロジェクト: girish66/MovePigMove
        public ActionResult Strength(AddStrengthInputModel input)
        {
            if (!ModelState.IsValid) return View(input);

            var command = new AddStrengthCommand
                {
                    ExerciseId = input.ExerciseId,
                    Notes = input.Notes,
                    Repetitions = input.Repetitions,
                    Weight = input.Weight
                };

            _commandInvoker.Execute(command);

            return RedirectToAction("Index", "Workout");
        }
コード例 #3
0
            public void TheUserIsRedirectedToTheWokoutSummary()
            {
                var invoker = new Mock<ICommandInvoker>();
                var controller = new AddController(invoker.Object, null);
                var input = new AddStrengthInputModel { ExerciseId = 2, Notes = "f", Repetitions = 10, Weight = 185 };

                var result = (RedirectToRouteResult)controller.Strength(input);
                result.RouteValues["action"].ShouldEqual("Index");
            }