public void RemoveSelected() { WikiFunctions.Controls.Lists.ListBoxArticle lbArticles = new WikiFunctions.Controls.Lists.ListBoxArticle(); const int big = 70000, sel=5000; for(int i=0; i<big; i++) lbArticles.Items.Add(new Article(i.ToString())); for(int j=sel; j>0; j--) lbArticles.SetSelected(big-j, true); lbArticles.RemoveSelected(); Assert.AreEqual(lbArticles.Items.Count, big-sel); // non-sequential deletion lbArticles.Items.Clear(); for(int i=0; i<10; i++) lbArticles.Items.Add(new Article(i.ToString())); lbArticles.SetSelected(1, true); lbArticles.SetSelected(3, true); lbArticles.RemoveSelected(); Assert.IsFalse(lbArticles.Items.Contains(new Article("1"))); Assert.IsFalse(lbArticles.Items.Contains(new Article("3"))); Assert.IsTrue(lbArticles.Items.Contains(new Article("2"))); lbArticles.Items.Clear(); for(int i=0; i<10; i++) lbArticles.Items.Add(new Article(i.ToString())); lbArticles.SetSelected(1, true); lbArticles.SetSelected(5, true); lbArticles.RemoveSelected(); Assert.IsFalse(lbArticles.Items.Contains(new Article("1"))); Assert.IsFalse(lbArticles.Items.Contains(new Article("5"))); Assert.IsTrue(lbArticles.Items.Contains(new Article("2"))); }
public void RemoveSelected() { WikiFunctions.Controls.Lists.ListBoxArticle lbArticles = new WikiFunctions.Controls.Lists.ListBoxArticle(); const int big = 70000, sel=5000; // sequential block deletion performance for(int i=0; i<big; i++) lbArticles.Items.Add(new Article(i.ToString())); for(int j=sel; j>0; j--) lbArticles.SetSelected(big-j, true); lbArticles.RemoveSelected(true); if(Globals.UsingMono) // Mono implementation of SetSelected does not seem to honour second input to multi-select Assert.AreEqual(lbArticles.Items.Count, big-1); else Assert.AreEqual(lbArticles.Items.Count, big-sel); // single selected item deletion performance lbArticles.Items.Clear(); for(int i=0; i<big*3; i++) lbArticles.Items.Add(new Article(i.ToString())); lbArticles.SetSelected((int)big/2, true); lbArticles.RemoveSelected(true); Assert.AreEqual(lbArticles.Items.Count, big*3-1); // non-sequential deletion lbArticles.Items.Clear(); for(int i=0; i<10; i++) lbArticles.Items.Add(new Article(i.ToString())); lbArticles.SetSelected(1, true); lbArticles.SetSelected(3, true); lbArticles.RemoveSelected(true); if(Globals.UsingMono) { lbArticles.SetSelected(1, true); lbArticles.RemoveSelected(true); } Assert.IsFalse(lbArticles.Items.Contains(new Article("1"))); Assert.IsFalse(lbArticles.Items.Contains(new Article("3"))); Assert.IsTrue(lbArticles.Items.Contains(new Article("2"))); lbArticles.Items.Clear(); for(int i=0; i<10; i++) lbArticles.Items.Add(new Article(i.ToString())); lbArticles.SetSelected(1, true); lbArticles.SetSelected(5, true); lbArticles.RemoveSelected(true); if(Globals.UsingMono) { lbArticles.SetSelected(1, true); lbArticles.RemoveSelected(true); } Assert.IsFalse(lbArticles.Items.Contains(new Article("1"))); Assert.IsFalse(lbArticles.Items.Contains(new Article("5"))); Assert.IsTrue(lbArticles.Items.Contains(new Article("2"))); lbArticles.Items.Clear(); lbArticles.Items.Add(new Article("A")); lbArticles.Items.Add(new Article("A")); lbArticles.Items.Add(new Article("B")); lbArticles.SetSelected(2, true); lbArticles.RemoveSelected(false); Assert.AreEqual(lbArticles.Items.Count, 2, "Duplicates not removed if not in duplicate mode"); }
public void RemoveSelected() { WikiFunctions.Controls.Lists.ListBoxArticle lbArticles = new WikiFunctions.Controls.Lists.ListBoxArticle(); const int big = 70000, sel=5000; for(int i=0; i<big; i++) lbArticles.Items.Add(new Article(i.ToString())); for(int j=sel; j>0; j--) lbArticles.SetSelected(big-j, true); lbArticles.RemoveSelected(); Assert.AreEqual(lbArticles.Items.Count, big-sel); }