public void UpdateProductCategory() { NorthwindDataStore northwindDataStore = new NorthwindDataStore(); List <CategoryInfo> categoryInfos = northwindDataStore.GetCategoriesInfo(); List <Product> productsToChange = categoryInfos.FirstOrDefault().Products.Skip(2).ToList(); Category newCategory = categoryInfos.Last().Category; CategoryInfo categoryInfo = northwindDataStore.GetCategoryInfo(newCategory); northwindDataStore.UpdateProductsCategory(productsToChange, newCategory); Assert.AreNotEqual(categoryInfo.Products.Count, northwindDataStore.GetCategoryInfo(newCategory).Products.Count); }
public void AddProduct() { Random rnd = new Random(); CategoryInfo categoryInfo = new CategoryInfo(); ProductInfo productInfo = new ProductInfo(); productInfo.Product = new Product() { ProductName = "New Product", Discontinued = false }; productInfo.Supplier = new Supplier() { CompanyName = "New supplier" }; ProductInfo productInfo2 = new ProductInfo(); productInfo2.Product = new Product() { ProductName = "New Product2", Discontinued = true }; productInfo2.Supplier = new Supplier() { CompanyName = "New supplier2" }; categoryInfo.Products = new List <Product>() { productInfo.Product, productInfo2.Product }; categoryInfo.Category = new Category() { CategoryName = $"New Category{rnd.Next(150)}" }; List <CategoryInfo> categoryInfos = new List <CategoryInfo>() { categoryInfo }; List <ProductInfo> productsInfos = new List <ProductInfo>() { productInfo, productInfo2 }; categoryInfos.ForEach(c => c.Products.ForEach(p => p.CategoryID = c.Category.CategoryID)); NorthwindDataStore northwindDataStore = new NorthwindDataStore(); northwindDataStore.AddProducts(categoryInfos, productsInfos); Assert.IsTrue(northwindDataStore.GetCategoriesInfo().Any(x => x.Category.CategoryName == categoryInfo.Category.CategoryName)); }