public void Should_Be_Able_To_Update_The_Price_Of_A_Call() { var data = CallViewModelFaker.GenerateCallViewModel(); var call = CallFaker.GenerateCall(data); call.PricePerMinute = 4.30m; var updatedCall = call; updatedCall.PricePerMinute = data.PricePerMinute; var updatedCallViewModel = data; updatedCallViewModel.PricePerMinute = updatedCall.PricePerMinute; callsRepository.Setup(x => x.FindByFromToAreaCode(data.FromAreaCode, data.ToAreaCode) ).Returns(call); callsRepository.Setup(x => x.SaveChanges()); mapper.Setup(x => x.Map <CallViewModel>(updatedCall)) .Returns(updatedCallViewModel); var response = callServices.UpdateCallPrice(data); Assert.NotNull(response); }
public ActionResult <CallViewModel> Update( [FromServices] ICallServices services, [FromBody] CallViewModel data ) { data.Validate(); if (data.Invalid) { return(BadRequest(data.Notifications)); } var call = services.UpdateCallPrice(data); return(Ok(call)); }