public ActionResult <IEnumerable <CallViewModel> > GetPrice( [FromServices] ICallServices services, [FromQuery(Name = "from-area-code")] byte fromAreaCode, [FromQuery(Name = "to-area-code")] byte toAreaCode ) { if (fromAreaCode <= 0 || fromAreaCode >= 101) { return(BadRequest(new { StatusCode = 400, Message = "Origin area code must be between 1 and 100" })); } if (toAreaCode <= 0 || toAreaCode >= 101) { return(BadRequest(new { StatusCode = 400, Message = "Destiny area code must be between 1 and 100" })); } var call = services.GetCallPriceFromTo(fromAreaCode, toAreaCode); return(Ok(call)); }
public void Should_Return_A_Call_Price() { var call = CallFaker.GenerateCall(); var callViewModel = CallViewModelFaker.GenerateCallViewModel(call); var fromAreaCode = call.FromAreaCode; var toAreaCode = call.ToAreaCode; callsRepository.Setup(x => x.FindByFromToAreaCode(fromAreaCode, toAreaCode)) .Returns(call); mapper.Setup(x => x.Map <CallViewModel>(call)).Returns(callViewModel); var response = callServices.GetCallPriceFromTo(fromAreaCode, toAreaCode); Assert.NotNull(response); }