public void ProductsToUninstall() { var tempFilePath = "X:\\temp\\"; var products = new ProductCollection(); products.AddRange(new List <string> { "https://download/from/here/p1.msi", "https://download/from/here/p2.msi", "https://download/from/there/p3.msi", "https://download/from/somewhere/p4.msi", }.Aggregate(new ProductCollection(), (ps, s) => { ps.Add(new ProductInfo { Name = Path.GetFileNameWithoutExtension(s), Uri = new Uri(s), LocalPath = new Uri(s).MapToLocalPath(tempFilePath) }); return(ps); })); Assert.That(products.Count, Is.EqualTo(4)); var existing = new List <string> { products[0].LocalPath, $"{tempFilePath}CrazyVirus.msi", products[3].LocalPath, $"{tempFilePath}SomethingElse.msi", }; var uninstall = products.FilesToUninstall(existing).ToList(); Assert.That(uninstall.Count(), Is.EqualTo(2)); Assert.That(uninstall[0], Is.EqualTo(existing[1])); Assert.That(uninstall[1], Is.EqualTo(existing[3])); }
public void Acc_ETL_CloneCollection() { ProductCollection coll = new ProductCollection().Where("CategoryID", 1); coll.Load(); ProductCollection coll2 = new ProductCollection(); coll2.AddRange(coll.Clone()); Assert.IsTrue(coll.Count == coll2.Count); }
/// <summary> /// Get all products or products matches with given name /// </summary> /// <param name="name">Name of a product</param> /// <returns>Products</returns> public async Task <ActionResult <ProductCollection> > Get(string name = null) { var products = await productService.RetrieveProducts(name); var productCollection = new ProductCollection(); productCollection.AddRange(products); return(productCollection); }
public void ETL_CloneCollection() { ProductCollection coll = new ProductCollection().Where("CategoryID", 1); coll.Load(); ProductCollection coll2 = new ProductCollection(); coll2.AddRange(coll.Clone()); Assert.IsTrue(coll.Count == coll2.Count); }
private void SetItemsToGrid(int totalRecords, ProductCollection productCollection, string category) { if (productCollection.Count > 0) { productsPagerBottom.PageSize = productsPager.PageSize = pageSize; productsPagerBottom.TotalRecords = productsPager.TotalRecords = totalRecords; productsPagerBottom.PageIndex = productsPager.PageIndex = CurrentPageIndex; Session.Add("productsPager", productsPager); if (productCollection.Count > countLines * rowCount && (category.Equals("живые цветы", StringComparison.CurrentCultureIgnoreCase) || category.Equals("Букеты и композиции", StringComparison.CurrentCultureIgnoreCase))) { int countFirstPart = countLines * rowCount; ProductCollection part1 = new ProductCollection(); part1.AddRange(productCollection.GetRange(0, countFirstPart)); ProductCollection part2 = new ProductCollection(); part2.AddRange(productCollection.GetRange(countFirstPart, productCollection.Count - countFirstPart)); dlProducts.DataSource = part1; dlProducts.DataBind(); dlProducts2.DataSource = part2; dlProducts2.DataBind(); } else { dlProducts.DataSource = productCollection; dlProducts.DataBind(); dlProducts2.Visible = false; indOrderBanner.Visible = false; } } else { dlProducts.Visible = false; dlProducts2.Visible = false; indOrderBanner.Visible = false; } }