public void UpdateTape() { // arrange int tapeId = 1; var tapeInput = new TapeInputModel { Title = "Pulp Fiction", DirectorName = "Peter Jackson", Eidr = "2", ReleaseDate = new DateTime(1999, 10, 10), Type = "VHS" }; _tapeRepositoryMock.Setup(method => method.UpdateTape(tapeInput, tapeId)); _tapeRepositoryMock.Setup(method => method.GetTapeById(tapeId)).Returns( FizzWare.NBuilder.Builder <TapeDetailsDto> .CreateNew().With(x => x.Id = 1).With(x => x.Eidr = "2").With(x => x.Title = "Pulp Fiction") .With(x => x.Type = "VHS").With(x => x.AverageRating = 2.2) .With(x => x.DirectorName = "Quentin Tarantino") .With(x => x.ReleaseDate = DateTime.Today).Build()); // act _tapeService.UpdateTape(tapeInput, tapeId); // assert //_tapeRepositoryMock.Verify(x => x.GetTapeById(tapeId), Times.Once); _tapeRepositoryMock.Verify(x => x.UpdateTape(tapeInput, tapeId), Times.Once); }
public IActionResult UpdateTape([FromBody] TapeInputModel tape, int?id) { if (!ModelState.IsValid) { throw new ModelFormatException(); } return(Ok(_tapeService.UpdateTape(tape, (int)id))); }
public IActionResult UpdateTapeById([FromBody] TapeInputModel tape, int tapeId) { if (!ModelState.IsValid) { throw new ModelFormatException("Tape was not properly formatted"); } _tapeService.UpdateTape(tape, tapeId); return(NoContent()); }
public void UpdateValidTape_ReturnsNothing() { // act service.UpdateTape(tape, 1); _tapeRepository.Verify((m => m.GetTapeById(1)), Times.Once()); }