public async Task Put_given_valid_study_calls_UpdateAsync()
        {
            // Arrange
            var repository = new Mock <IStudyRepository>();
            var controller = new StudyController(repository.Object, log.Object);

            var study = new StudyDTO {
                Id = 11
            };

            // Act
            await controller.Put(11, study);

            // Arrange
            repository.Verify(r => r.UpdateAsync(study));
        }
        public async Task Put_given_id_not_eq_to_studyId_returns_BadRequest()
        {
            // Arrange
            var repository = new Mock <IStudyRepository>();
            var controller = new StudyController(repository.Object, log.Object);

            var customer = new StudyDTO {
                Id = 11
            };

            // Act
            var result = await controller.Put(0, customer);

            // Assert
            Assert.IsType <BadRequestObjectResult>(result);
        }
        public async Task Put_given_invalid_study_doesnot_call_UpdateAsync()
        {
            // Arrange
            var repository = new Mock <IStudyRepository>();

            var controller = new StudyController(repository.Object, log.Object);

            controller.ModelState.AddModelError(string.Empty, "Error");

            var study = new StudyDTO();

            // Act
            await controller.Put(11, study);

            // Assert
            repository.Verify(r => r.UpdateAsync(It.IsAny <StudyDTO>()), Times.Never);
        }
        public async Task Put_given_valid_study_returns_NoContent()
        {
            // Arrange
            var repository = new Mock <IStudyRepository>();

            repository.Setup(r => r.UpdateAsync(It.IsAny <StudyDTO>())).ReturnsAsync(true);

            var controller = new StudyController(repository.Object, log.Object);

            var study = new StudyDTO {
                Id = 11
            };

            // Act
            var result = await controller.Put(11, study);

            // Assert
            Assert.IsType <NoContentResult>(result);
        }
        public async Task Put_given_nonexisting_study_returns_NotFound()
        {
            // Act
            var repository = new Mock <IStudyRepository>();

            repository.Setup(r => r.UpdateAsync(It.IsAny <StudyDTO>())).ReturnsAsync(false);

            var controller = new StudyController(repository.Object, log.Object);

            var study = new StudyDTO {
                Id = 11
            };

            // Act
            var result = await controller.Put(11, study);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
        public async Task Put_given_invalid_study_returns_BadRequest()
        {
            // Arrange
            var repository = new Mock <IStudyRepository>();

            var controller = new StudyController(repository.Object, log.Object);

            controller.ModelState.AddModelError(string.Empty, "Error");

            var study = new StudyDTO {
                Id = 11
            };

            // Act
            var result = await controller.Put(11, study);

            // Assert
            Assert.IsType <BadRequestObjectResult>(result);
        }