GivenPayerPayeeServiceReturnsPayers_WhenGetAutocompletePayerInvoked_ThenReturns200OKWithCorrectList() { var inputName = "test"; var payers = new List <PayerPayeeViewModel> { new() { PayerPayeeId = Guid.NewGuid(), ExternalId = "id123", PayerPayeeName = "test123" }, new() { PayerPayeeId = Guid.NewGuid(), ExternalId = "id1234", PayerPayeeName = "test1234" } }; _mockService.Setup(service => service.AutocompletePayer(inputName)).ReturnsAsync(() => payers); var controller = new PayersPayeesController(_mockService.Object); var response = await controller.GetAutocompletePayer(inputName); var objectResponse = Assert.IsType <OkObjectResult>(response); Assert.Equal(StatusCodes.Status200OK, objectResponse.StatusCode); Assert.Equal(payers, objectResponse.Value); }
public async Task GivenWhitespaceInputName_WhenGetAutocompletePayerInvoked_ThenReturns400BadRequest() { var controller = new PayersPayeesController(_mockService.Object); var response = await controller.GetAutocompletePayer(""); Assert.IsType <BadRequestResult>(response); }