public void Update_ShouldUpdateSpecification() { // Arrange var id = 2; var spec = _updateSpecifications.SingleOrDefault(v => v.Id == id); var newNote = "NewUpdate"; var newSpecificationRequest = new SpecificationUpdateRequest { IsCurrent = true, Note = newNote, }; // Act _updateService.Update(id, newSpecificationRequest); // Assert _updateRepository.Verify( mock => mock.Update(It.IsAny <Specification>()), Times.Exactly(2)); Assert.Equal(newNote, _updateSpecifications.SingleOrDefault(v => v.Id == id).Note); Assert.Single(_updateSpecifications.Where( v => v.Mark.Id == spec.Mark.Id && v.IsCurrent)); }
public ActionResult Update( int id, [FromBody] SpecificationUpdateRequest specificationRequest) { if (!specificationRequest.Validate()) { return(BadRequest()); } try { _service.Update(id, specificationRequest); } catch (ArgumentNullException) { return(NotFound()); } return(NoContent()); }