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 Handle_TerritoryFilter_ReturnSalesPersons(
            List <Core.Entities.SalesPerson> salesPersons,
            [Frozen] Mock <IRepository <Core.Entities.SalesPerson> > salesPersonRepoMock,
            GetSalesPersonsQueryHandler sut,
            GetSalesPersonsQuery query
            )
        {
            //Arrange
            salesPersonRepoMock.Setup(x => x.ListAsync(
                                          It.IsAny <GetSalesPersonsSpecification>(),
                                          It.IsAny <CancellationToken>()
                                          ))
            .ReturnsAsync(salesPersons);

            //Act
            var result = await sut.Handle(query, CancellationToken.None);

            //Assert
            result.Should().NotBeNull();
            salesPersonRepoMock.Verify(x => x.ListAsync(
                                           It.IsAny <GetSalesPersonsSpecification>(),
                                           It.IsAny <CancellationToken>()
                                           ));

            for (int i = 0; i < result.Count; i++)
            {
                result[i].FullName().Should().Be(salesPersons[i].FullName);
            }
        }
        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();
        }
        public void Handle_SalesPersonsNull_ThrowsArgumentNullException(
            [Frozen] Mock <IRepository <Core.Entities.SalesPerson> > salesPersonRepoMock,
            GetSalesPersonsQueryHandler sut,
            GetSalesPersonsQuery query
            )
        {
            //Arrange
            salesPersonRepoMock.Setup(x => x.ListAsync(
                                          It.IsAny <GetSalesPersonsSpecification>(),
                                          It.IsAny <CancellationToken>()
                                          ))
            .ReturnsAsync((List <Core.Entities.SalesPerson>)null);

            //Act
            Func <Task> func = async() => await sut.Handle(query, CancellationToken.None);

            //Assert
            func.Should().ThrowAsync <ArgumentNullException>()
            .WithMessage("Value cannot be null. (Parameter 'salesPersons')");
        }