public async Task GetSalesPersons_ShouldReturnSalesPersons_WhenGivenSalesPersons( [Frozen] Mock <IMediator> mockMediator, List <Core.Handlers.GetSalesPersons.SalesPersonDto> salesPersons, [Greedy] SalesPersonController sut, GetSalesPersonsQuery query ) { //Arrange mockMediator.Setup(x => x.Send( It.IsAny <GetSalesPersonsQuery>(), It.IsAny <CancellationToken>() )) .ReturnsAsync(salesPersons); //Act var actionResult = await sut.GetSalesPersons(query); //Assert var okObjectResult = actionResult as OkObjectResult; okObjectResult.Should().NotBeNull(); var result = okObjectResult.Value as List <Core.Models.SalesPerson>; result.Count.Should().Be(salesPersons.Count); }
public async Task GetSalesPersons_ShouldReturnNotFound_WhenGivenNoSalesPersons( [Greedy] SalesPersonController sut, GetSalesPersonsQuery query ) { //Act var actionResult = await sut.GetSalesPersons(query); //Assert var notFoundResult = actionResult as NotFoundResult; notFoundResult.Should().NotBeNull(); }