Beispiel #1
0
            public async Task GetSalesOrders_ShouldReturnSalesOrders_WhenGivenSalesOrders(
                [Frozen] Mock <IMediator> mockMediator,
                List <Core.Handlers.GetSalesOrders.SalesOrderDto> salesOrders,
                [Greedy] SalesOrderController sut,
                GetSalesOrdersQuery query
                )
            {
                //Arrange
                var dto = new GetSalesOrdersDto
                {
                    SalesOrders      = salesOrders,
                    TotalSalesOrders = salesOrders.Count
                };

                mockMediator.Setup(x => x.Send(
                                       It.IsAny <GetSalesOrdersQuery>(),
                                       It.IsAny <CancellationToken>()
                                       ))
                .ReturnsAsync(dto);

                //Act
                var actionResult = await sut.GetSalesOrders(query);

                //Assert
                var okObjectResult = actionResult as OkObjectResult;

                okObjectResult.Should().NotBeNull();

                var result = okObjectResult.Value as Core.Models.SalesOrdersResult;

                result.SalesOrders.Count.Should().Be(salesOrders.Count);
            }
Beispiel #2
0
            public async Task GetSalesOrders_ShouldReturnNotFound_WhenGivenNoSalesOrders(
                [Greedy] SalesOrderController sut,
                GetSalesOrdersQuery query
                )
            {
                //Act
                var actionResult = await sut.GetSalesOrders(query);

                //Assert
                var notFoundResult = actionResult as NotFoundResult;

                notFoundResult.Should().NotBeNull();
            }