Ejemplo n.º 1
0
        public void Handle(AddExerciseCommand command)
        {
            var dataModel = new ExerciseDocument {
                Description = command.Description, ExerciseType = command.Type
            };

            _exerciseRepository.Add(new Exercise(dataModel));
        }
        public void TheChangesAreApplied()
        {
            var document = new ExerciseDocument {
                Id = 99, Description = "bar", ExerciseType = ExerciseType.Cardio
            };
            var existing = new Exercise(document);

            var repo = new Mock <IExerciseRepository>();

            repo.Setup(x => x.Load(99)).Returns(existing);

            var command = new UpdateExerciseCommand(99, "new description", ExerciseType.Strength);
            var handler = new UpdateExerciseCommandHandler(repo.Object);


            handler.Handle(command);

            document.Description.ShouldEqual("new description");
            document.ExerciseType.ShouldEqual(ExerciseType.Strength);
        }