public async Task Get_products_by_ids_returns_expected_values() { // Arrange var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/inventory/products/1,2"); var stockItems = await response.Content.As <StockItem[]>(); // Assert Assert.Collection(stockItems, item => { Assert.Equal(1, item.Id); Assert.Equal(1, item.ProductId); Assert.Equal(4, item.Inventory); }, item => { Assert.Equal(2, item.Id); Assert.Equal(2, item.ProductId); Assert.Equal(0, item.Inventory); }); }
public async Task Get_product_should_return_200() { // Arrange var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/product-details/product/1"); // Assert response.EnsureSuccessStatusCode(); }
public async Task Get_available_products_returns_expected_ids() { // Arrange var expectedIds = new[] { 1, 2 }; var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/available/products"); var availableProducts = await response.Content.As <int[]>(); // Assert Assert.Equal(expectedIds, availableProducts); }
public async Task Get_product_should_return_expected_ProductPrice() { // Arrange var expectedProductPrice = new ProductPrice() { Id = 1, Price = 10.00m }; var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/prices/product/1"); var productPrice = await response.Content.As <ProductPrice>(); // Assert Assert.Equal(expectedProductPrice.Id, productPrice.Id); Assert.Equal(expectedProductPrice.Price, productPrice.Price); }
public async Task Get_product_should_return_expected_ProductDetails() { // Arrange var expectedProductDetails = new ProductDetails() { Id = 1, Name = "Banana Holder", Description = "Outdoor travel cute banana protector storage box" }; var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/product-details/product/1"); var productDetails = await response.Content.As <ProductDetails>(); // Assert Assert.Equal(expectedProductDetails.Id, productDetails.Id); Assert.Equal(expectedProductDetails.Name, productDetails.Name); Assert.Equal(expectedProductDetails.Description, productDetails.Description); }
public async Task Get_product_should_return_expected_StockItem() { // Arrange var expectedStockItem = new StockItem() { Id = 1, ProductId = 1, Inventory = 4, }; var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/inventory/product/1"); var stockItem = await response.Content.As <StockItem>(); // Assert Assert.Equal(expectedStockItem.Id, stockItem.Id); Assert.Equal(expectedStockItem.Inventory, stockItem.Inventory); Assert.Equal(expectedStockItem.ProductId, stockItem.ProductId); }
public When_Invoking_home_page() { Warehouse.Api.Data.WarehouseContext.CreateSeedData(Guid.NewGuid().ToString()); var warehouseApi = new WebApplicationFactoryWithWebHost <Warehouse.Api.Startup>(); _warehouseApiClient = warehouseApi.CreateClient(); Shipping.Api.Data.ShippingContext.CreateSeedData(Guid.NewGuid().ToString()); var shippingApi = new WebApplicationFactoryWithWebHost <Shipping.Api.Startup>(); _shippingApiClient = shippingApi.CreateClient(); Sales.Api.Data.SalesContext.CreateSeedData(Guid.NewGuid().ToString()); var salesApi = new WebApplicationFactoryWithWebHost <Sales.Api.Startup>(); _salesApiClient = salesApi.CreateClient(); Catalog.Api.Data.MarketingContext.CreateSeedData(Guid.NewGuid().ToString()); var catalogApi = new WebApplicationFactoryWithWebHost <Catalog.Api.Startup>(); _catalogApiClient = catalogApi.CreateClient(); }
public async Task Get_product_should_return_expected_StockItem() { // Arrange var expectedProductShippingOptions = new ProductShippingOptions() { Id = 1, ProductId = 1, }; expectedProductShippingOptions.Options.Add(new ShippingOption() { Id = 1, ProductShippingOptionsId = 1, Option = "Express Delivery", EstimatedMinDeliveryDays = 1, EstimatedMaxDeliveryDays = 3, }); expectedProductShippingOptions.Options.Add(new ShippingOption() { Id = 2, ProductShippingOptionsId = 1, Option = "Regular mail", EstimatedMinDeliveryDays = 4, EstimatedMaxDeliveryDays = 12, }); var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/shipping-options/product/1"); var shippingOption = await response.Content.As <ProductShippingOptions>(); // Assert Assert.Equal(expectedProductShippingOptions.Id, shippingOption.Id); Assert.Equal(expectedProductShippingOptions.ProductId, shippingOption.ProductId); Assert.Equal(expectedProductShippingOptions.Options.Count, shippingOption.Options.Count); }
public async Task Get_products_by_ids_returns_expected_values() { // Arrange var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/prices/products/1,2"); var productPrices = await response.Content.As <ProductPrice[]>(); // Assert Assert.Collection(productPrices, item => { Assert.Equal(1, item.Id); Assert.Equal(10.00m, item.Price); }, item => { Assert.Equal(2, item.Id); Assert.Equal(100.00m, item.Price); }); }