public async void RemoveRecipe_FromInitializedDbTable_RemovedRecipeNotFoundInDb() { // arrange var productCatalog = GetProductCatalog(); var products = GetProducts(); fixture.db.Add(productCatalog); fixture.db.Product.AddRange(products); await fixture.db.SaveChangesAsync(); var expected = new ProductsDataModel[] { new ProductsDataModel { Id = 44440, Uid = 44440, Price = 22.1M, Quantity = 5, QuantityUnit = "mg.", Name = productCatalog.Name }, new ProductsDataModel { Id = 44441, Uid = 44440, Price = 14.1M, Quantity = 6, QuantityUnit = "mg.", Name = productCatalog.Name }, }; int storageId = 44440; // act var actual = await logic.GetAllDataModelAsync(storageId); // assert foreach (var expectedItem in expected) { Assert.Contains(actual, actualItem => expectedItem.Id == actualItem.Id && expectedItem.Name == actualItem.Name && expectedItem.Uid == actualItem.Uid && expectedItem.Price == actualItem.Price && expectedItem.Quantity == actualItem.Quantity && expectedItem.QuantityUnit == actualItem.QuantityUnit); } }
public IEnumerable <ProductsDataModel> CheckStockStatus(List <string> items) { Random randomNumbers = new Random(); List <ProductsDataModel> products = new List <ProductsDataModel>(); for (int i = 0; i < items.Count; i++) { ProductsDataModel product = new ProductsDataModel(); product.Name = items[i]; product.Price = randomNumbers.Next(100, 1000); //pseudo logic to assign random price if (randomNumbers.Next(0, 10) % 3 != 0) //some pseudo logic to recreate in-stock / out-of-stock scenario { products.Add(product); } } return(products); }
public IEnumerable <ProductsDataModel> CheckStockStatus(List <string> items) { Random randomNumbers = new Random(); List <ProductsDataModel> products = new List <ProductsDataModel>(); for (int i = 0; i < items.Count; i++) { ProductsDataModel product = new ProductsDataModel(); product.Name = items[i]; product.Price = randomNumbers.Next(100, 1000); if (randomNumbers.Next(0, 10) % 3 != 0) { products.Add(product); } } return(products); }
public async Task PublishProductMessage([FromBody] ProductsDataModel product) { await messagePublisher.PublisherMessage(product); }