Esempio n. 1
0
        public async Task GetById_SpecificSupplier_ShouldReturnASupplier()
        {
            // Arrange
            var supplier   = _supplierFixture.GetValidSupplier();
            var supplierId = supplier.Id;

            var mock = new Mock <ISupplierService>();

            mock.Setup(service => service.GetSupplierAndAddressAndProducts(supplierId)).ReturnsAsync(supplier);

            // Act
            SupplierController controller = new SupplierController(mock.Object);

            var actionResult = await controller.GetById(supplierId);

            var result   = Assert.IsType <ActionResult <SupplierDTO> >(actionResult).Result;
            var okResult = result as OkObjectResult;

            // Assert
            okResult.Value.Should().BeSameAs(supplier);
            okResult.StatusCode.Equals(HttpStatusCode.OK);
        }