public async Task Action_GetCustomerByIdAndEmailWhenDoNotPassParameters_ReturnsBadRequestAndMessage() { //Arrange var customerEmail = ""; var customerId = ""; var messageValue = "No inquiry criteria"; //_mockCustomerService.; var controller = new CustomersController(_mockCustomerService.Object); //Act var result = await controller.GetByIdAndEmail(customerId, customerEmail); var message = (result as BadRequestObjectResult).Value; //Assert Assert.IsType <BadRequestObjectResult>(result); Assert.Equal(messageValue, message); }
public async Task Action_GetCustomerByIdAndEmail_ReturnsJsonResult_Code200AndData() { //Arrange var customerEmail = _email; var customerId = _customerId; int code200 = StatusCodes.Status200OK; _mockCustomerService.Setup(serv => serv.GetDataByIdAndEmailAsync(int.Parse(customerId), customerEmail)) .ReturnsAsync(GetCustomer); _mockCustomerService.Setup(serv => serv.IsEmailValid(customerEmail)) .Returns(PropertyIsValid); _mockCustomerService.Setup(serv => serv.IsCustomerIdValid(customerId)) .Returns(PropertyIsValid); var controller = new CustomersController(_mockCustomerService.Object); //Act var result = await controller.GetByIdAndEmail(customerId, customerEmail); var code = (result as JsonResult).Value.GetType().GetProperty("StatusCode").GetValue((result as JsonResult).Value); //Assert Assert.IsType <JsonResult>(result); Assert.Equal(code200, code); }