public IHttpActionResult Create(AddExerciseRequest exerciseRequest)
        {
            if (exerciseRequest == null || !ModelState.IsValid)
            {
                return(ResponseMessage(CreateCustomResponseMessage(HttpStatusCode.BadRequest)));
            }
            var result = _exerciseService.Add(exerciseRequest);

            return(ResponseMessage(CreateCustomResponseMessage(result)));
        }
        private void MethodAddExerciseReturnsCorrectResponse()
        {
            _repository.Setup(repo => repo.Add(_exercise1));
            _service.Add(_exerciseDTO1);

            _repository.Verify(repo => repo.Add(_exercise1), Times.Once);
        }
        public void Should_Add_Exercise()
        {
            //ARRANGE
            var exercise = new Exercise();
            var repoMock = new Mock <IRepository <Exercise> >(MockBehavior.Strict);

            repoMock
            .Setup(mock => mock.Add(It.IsAny <Exercise>(), true))
            .Returns(exercise);

            var sut = new ExerciseService(repoMock.Object);

            //ACT
            var result = sut.Add(exercise, true);

            //ASSERT
            result.ShouldBeSameAs(exercise);
            repoMock.Verify(mock => mock.Add(exercise, true), Times.Once);
        }
Esempio n. 4
0
 public void Add(Exercise Exercise)
 {
     exerciseService.Add(Exercise);
 }