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));
        }
        public void AddsExerciseToCurrentWorkout()
        {
            var wk = new Workout();
            var service = NSubstitute.Substitute.For<IWorkoutService>();
            service.CurrentWorkout().Returns(wk);
            var command = new AddStrengthCommand(new AddStrengthInputModel {Description = "a", Repetitions = 1, Weight = 10});
            AutoMapper.Mapper.Initialize(x => x.AddProfile<Core.Mapping.StrengthMappingProfile>());

            var handler = new AddStrengthCommandHandler(service);
            handler.Handle(command);

            wk.Strength.Count.ShouldEqual(1);
        }
        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);
        }
        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));
        }
        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);
        }