Esempio n. 1
0
        public void Snack_Service_Should_Update_Snack_Sucessfully()
        {
            //Arrange
            var snack    = ObjectMother.GetDefaultSnack();
            var snackCmd = ObjectMother.GetSnackUpdateCommand();
            var updated  = true;

            _mockSnackRepository.Setup(e => e.GetById(snackCmd.Id)).Returns(snack);
            _mockSnackRepository.Setup(r => r.Save()).Returns(updated);

            //Action
            var updateSnack = _snackService.Update(snackCmd);

            //Assert
            _mockSnackRepository.Verify(e => e.GetById(snackCmd.Id), Times.Once);
            _mockSnackRepository.Verify(r => r.Update(snack), Times.Once);
            updateSnack.Should().BeTrue();
        }
Esempio n. 2
0
        public IHttpActionResult Update(SnackUpdateCommand command)
        {
            var validator = command.Validate(_service);

            if (!validator.IsValid)
            {
                return(HandleValidationFailure(validator.Errors));
            }

            return(HandleCallback(_service.Update(command)));
        }
Esempio n. 3
0
 public IActionResult Put(int id, [FromBody] Snack snack)
 {
     return(Ok(_snackService.Update(id, snack)));
 }