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 async Task Should_Return_404_Status_Code_If_Call_Not_Exist() { var data = CallViewModelFaker.GenerateCallViewModel(); data.FromAreaCode = 1; data.ToAreaCode = 28; var response = await factory.PerformRequest(client, action, route, data); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); }
public async Task Should_Return_200_Status_Code_If_Call_Price_Updated() { var data = CallViewModelFaker.GenerateCallViewModel(); data.FromAreaCode = 68; data.ToAreaCode = 82; var response = await factory.PerformRequest(client, action, route, data); Assert.Equal(HttpStatusCode.OK, response.StatusCode); }
public void Should_Not_Update_If_Call_Not_Exist() { var data = CallViewModelFaker.GenerateCallViewModel(); callsRepository.Setup(x => x.FindByFromToAreaCode(data.FromAreaCode, data.ToAreaCode) ).Returns((Call)null); Assert.Throws <FaleMaisException>( () => callServices.UpdateCallPrice(data) ); }
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); }
public void Should_Return_200_Status_Code_If_Call_Call_Updated() { var data = CallViewModelFaker.GenerateCallViewModel(); var updated = data; updated.PricePerMinute = data.PricePerMinute - 0.50m; callServices.Setup(x => x.UpdateCallPrice(data)).Returns(updated); var response = callsController.Update(callServices.Object, data); var actionResult = Assert.IsType <OkObjectResult>(response.Result); var actionValue = Assert.IsType <CallViewModel>(actionResult.Value); Assert.NotNull(actionResult); Assert.Equal(StatusCodes.Status200OK, actionResult.StatusCode); }
public void Should_Return_200_Status_Code_If_Query_Values_Valid() { var rnd = new Random(); var call = CallViewModelFaker.GenerateCallViewModel(); byte fromAreaCode = (byte)rnd.Next(1, 101); byte toAreaCode = (byte)rnd.Next(1, 101); callServices.Setup(x => x.GetCallPriceFromTo(fromAreaCode, toAreaCode)) .Returns(call); var response = callsController.GetPrice( callServices.Object, fromAreaCode, toAreaCode ); var actionResult = Assert.IsType <OkObjectResult>(response.Result); var actionValue = Assert.IsType <CallViewModel>(actionResult.Value); Assert.NotNull(actionResult); Assert.Equal(StatusCodes.Status200OK, actionResult.StatusCode); }