コード例 #1
0
        public void IfThereIsNoCurrentWorkoutAnExceptionIsThrown()
        {
            var ws = new Mock<IWorkoutService>();
            var repo = new Mock<IExerciseRepository>();
            var handler = new AddStrengthCommandHandler(ws.Object, repo.Object);
            var command = new AddStrengthCommand { Weight = 20, ExerciseId = 1, Repetitions = 99, Notes = "foo" };

            ws.Setup(x => x.CurrentWorkout()).Returns<Workout>(null);
            repo.Setup(x => x.Load(1)).Returns(new Exercise(new ExerciseDocument { Description = "exer" }));

            Assert.Throws<ApplicationException>(() => handler.Handle(command));
        }
コード例 #2
0
        public void TheStrengthActivityIsAddedToTheCurrentWorkout()
        {
            var workOut = new Workout(new WorkoutDocument());
            var repo = new Mock<IExerciseRepository>();
            var ws = new Mock<IWorkoutService>();
            var handler = new AddStrengthCommandHandler(ws.Object, repo.Object);
            var command = new AddStrengthCommand { Weight = 20, ExerciseId = 1, Repetitions= 99, Notes = "foo" };

            ws.Setup(x => x.CurrentWorkout()).Returns(workOut);
            repo.Setup(x => x.Load(1)).Returns(new Exercise(new ExerciseDocument { Description = "exer" }));
            handler.Handle(command);

            workOut.StrengthSegments.Count().ShouldEqual(1);
        }
コード例 #3
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");
        }