public DatabaseScanner(ListMaker lm)
     : this()
 {
     listMaker = lm;
     if (lm != null)
         AWBListbox = lm.Items;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="lmMain"></param>
        public ListComparer(ListMaker lmMain)
        {
            InitializeComponent();

            if (lmMain != null)
            {
                btnMoveOnly1.Enabled = btnMoveOnly2.Enabled = btnMoveCommon.Enabled = true;
                _mainFormListMaker = lmMain;
            }

            listMaker1.MakeListEnabled = true;
            listMaker2.MakeListEnabled = true;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="lmMain"></param>
        public ListComparer(ListMaker lmMain)
        {
            InitializeComponent();

            if (lmMain != null)
                _mainFormListMaker = lmMain;

            listMaker1.MakeListEnabled = true;
            listMaker2.MakeListEnabled = true;
            listMaker1.NoOfArticlesChanged +=UpdateButtons;
            listMaker2.NoOfArticlesChanged +=UpdateButtons;

            // ensure button enablement of Remove, Filter correct in list maker when opened with no articles in
            listMaker1.UpdateNumberOfArticles();
            listMaker2.UpdateNumberOfArticles();
        }
Exemple #4
0
        public void RemoveListDuplicatesSimple()
        {
            ListMaker LMakerRLD = new ListMaker();
            LMakerRLD.Add(new Article("A"));
            LMakerRLD.Add(new Article("B"));
            LMakerRLD.Add(new Article("C"));
            LMakerRLD.Add(new Article("A"));

            LMakerRLD.RemoveListDuplicates();

            Assert.AreEqual(LMakerRLD.Count, 3, "Duplicate removed");
            foreach(Article a in LMakerRLD)
            {
                Assert.AreEqual(a, "A", "Duplicates removed from end of list");
                break;
            }
        }
Exemple #5
0
        public void RemoveListDuplicates10K()
        {
            const int big = 10000;
            ListMaker LMakerLarge = new ListMaker();
            LMakerLarge.Clear();
            for(int i=1; i<big; i++)
                LMakerLarge.Add(new Article(i.ToString()));

            LMakerLarge.Add(new Article("1"));

            Assert.AreEqual(LMakerLarge.Count, big);

            LMakerLarge.RemoveListDuplicates();

            Assert.AreEqual(LMakerLarge.Count, big-1, "Duplicate removed");
            Assert.IsTrue(LMakerLarge.Contains(new Article("1")), "First instance of article retained");
        }
Exemple #6
0
        public void GetArticleList()
        {
            ListMaker LMaker = new ListMaker();
            LMaker.Add("A");
            LMaker.Add("B");

            Assert.AreEqual(2, LMaker.GetArticleList().Count);

            LMaker.Items.SetSelected(0, true);
            LMaker.Items.SetSelected(1, true);

            Assert.AreEqual(2, LMaker.GetSelectedArticleList().Count);

            LMaker.Items.SetSelected(1, false);

            Assert.AreEqual(1, LMaker.GetSelectedArticleList().Count);
            Assert.AreEqual(2, LMaker.GetArticleList().Count);
        }
Exemple #7
0
        public void FilterNonMainArticlesVolume()
        {
            const int big = 500;
            ListMaker LMakerLarge = new ListMaker();
            LMakerLarge.Clear();
            for(int i=1; i<big; i++)
                LMakerLarge.Add(i.ToString());

            LMakerLarge.Add("Talk:Me");

            LMakerLarge.FilterNonMainArticles();
            Assert.AreEqual(LMakerLarge.Count, big-1, "Non-mainspace article removed");
        }
        public void NormalizeTitle()
        {
            ListMaker LMaker = new ListMaker();
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&diff=3&oldid=4"));
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&diff=3&curid=4"));
            Assert.AreEqual("Health effects of chocolate", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Health_effects_of_chocolate&diff=4018&oldid=40182"));
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&action=history"));
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&action=edit"));
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&oldid=5"));
            Assert.AreEqual("Science (journal)", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Science%20%28journal%29&action=history"));
            Assert.AreEqual(@"Wikipedia:AutoWikiBrowser/Sandbox", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Wikipedia:AutoWikiBrowser/Sandbox&action=edit"));
            Assert.AreEqual(@"Wikipedia:AutoWikiBrowser/Sandbox", LMaker.NormalizeTitle(@"en.wikipedia.org/w/index.php?title=Wikipedia:AutoWikiBrowser/Sandbox&action=edit"));
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo#References"));

            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"   Foo"), "cleans spacing from Firefox Category paste");

            Assert.AreEqual(@"Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&pe=1&#Date_on"));
            Assert.AreEqual(@"Foo", LMaker.NormalizeTitle(@"Foo‎"), "title has left-to-right mark at the end");

            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&offset=20130214190000&action=history"), "cleans spacing from Firefox Category paste");
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/?title=Foo"));
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/wiki/Foo"));
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"http://en.wikipedia.org/wiki/Foo"), "HTTP not HTTPS support");
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"//en.wikipedia.org/w/index.php?title=Foo&action=history"), "Protocol-relative support");
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&redirect=no"));

            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&type=revision&diff=75558108&oldid=65316243"));

            Assert.AreEqual("#[[Foo]]", LMaker.NormalizeTitle(@"#[[Foo]]"), "#wikilinked");
            Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"Foo#bar"), "#wikilinked");
        }
 public void Initialise(ListMaker rlistMaker)
 {
     listMaker = rlistMaker;
     resizeListView(lvIgnored);
     resizeListView(lvSaved);
 }
Exemple #10
0
        public void ListComparerSimple()
        {
            ListMaker LMaker = new ListMaker();
            LMaker.Add(new Article("A"));
            LMaker.Add(new Article("B"));
            LMaker.Add(new Article("C"));
            LMaker.Add(new Article("C")); // duplicate, removed during compare
            System.Windows.Forms.ListBox lb1 = new System.Windows.Forms.ListBox();
            System.Windows.Forms.ListBox lb2 = new System.Windows.Forms.ListBox();
            System.Windows.Forms.ListBox lb3 = new System.Windows.Forms.ListBox();

            List<Article> articles = new List<Article>();
            articles.Add(new Article("A"));
            articles.Add(new Article("D"));
            articles.Add(new Article("E"));

            ListComparer.CompareLists(LMaker, articles, lb1, lb2, lb3);

            // unique in 1
            Assert.IsTrue(lb1.Items.Contains("B"));
            Assert.IsTrue(lb1.Items.Contains("C"));
            Assert.IsFalse(lb1.Items.Contains("A"));
            Assert.AreEqual(lb1.Items.Count, 2);

            // unique in 2
            Assert.IsFalse(lb2.Items.Contains("A"));
            Assert.IsTrue(lb2.Items.Contains("D"));
            Assert.IsTrue(lb2.Items.Contains("E"));
            Assert.AreEqual(lb2.Items.Count, 2);

            // common to both
            Assert.IsTrue(lb3.Items.Contains("A"));
            Assert.AreEqual(lb3.Items.Count, 1);
        }
Exemple #11
0
        public void ListComparer10K()
        {
            const int big = 10000;
            ListMaker LMakerC10K = new ListMaker();

            for(int i=0; i<big; i++)
                LMakerC10K.Add(new Article(i.ToString()));

            LMakerC10K.Add(new Article("A"));
            LMakerC10K.Add(new Article("B"));

            System.Windows.Forms.ListBox lb1 = new System.Windows.Forms.ListBox();
            System.Windows.Forms.ListBox lb2 = new System.Windows.Forms.ListBox();
            System.Windows.Forms.ListBox lb3 = new System.Windows.Forms.ListBox();

            List<Article> articlesC = new List<Article>();
            for(int i=0; i<big; i++)
                articlesC.Add(new Article(i.ToString()));

            articlesC.Add(new Article("C"));
            articlesC.Add(new Article("D"));

            ListComparer.CompareLists(LMakerC10K, articlesC, lb1, lb2, lb3);

            // unique in 1
            Assert.IsTrue(lb1.Items.Contains("A"));
            Assert.IsTrue(lb1.Items.Contains("B"));

            // unique in 2
            Assert.IsTrue(lb2.Items.Contains("C"));
            Assert.IsTrue(lb2.Items.Contains("D"));

            // common to both
            Assert.IsTrue(lb3.Items.Contains("1"));
            Assert.AreEqual(lb3.Items.Count, big);
        }
 public void Initialise(ListMaker rlistMaker)
 {
     _listMaker = rlistMaker;
     ResizeListView(lvFailed);
     ResizeListView(lvSuccessful);
 }
 private void AddListToListMaker(ListMaker lm, IEnumerable<Article> lb)
 {
     List<Article> articles = new List<Article>();
     articles.AddRange(lb);
     lm.Add(articles);
 }
 public void NormalizeTitleSecure()
 {
     ListMaker LMaker = new ListMaker();
     Assert.AreEqual("Foo", LMaker.NormalizeTitle(@"https://en.wikipedia.org/w/index.php?title=Foo&diff=3&oldid=4"));
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lmMain"></param>
 /// <param name="list"></param>
 public ListComparer(ListMaker lmMain, List<Article> list)
     : this(lmMain)
 {
     listMaker1.Add(list);
 }
Exemple #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lmMain"></param>
 /// <param name="list"></param>
 public ListComparer(ListMaker lmMain, List <Article> list)
     : this(lmMain)
 {
     listMaker1.Add(list);
 }
Exemple #17
0
        public void AddList()
        {
            ListMaker LMaker = new ListMaker();
            List<Article> l = new List<Article>();

            l.Add(new Article("A"));
            l.Add(new Article("B"));

            LMaker.Add("A");
            LMaker.Add("B");

            LMaker.FilterDuplicates = true;

            LMaker.Add(l);
            Assert.AreEqual(2, LMaker.NumberOfArticles);

            l.Add(new Article("C"));
            LMaker.Add(l);
            Assert.AreEqual(3, LMaker.NumberOfArticles);

            l.Add(new Article("C"));
            l.Add(new Article("C"));
            l.Add(new Article("C"));
            l.Add(new Article("C"));
            LMaker.Add("D");
            LMaker.Add(l);
            Assert.AreEqual(4, LMaker.NumberOfArticles);
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="lm">ListMaker for DBScanner to add articles to</param>
 public DatabaseScannerListProvider(ListMaker lm)
 {
     LMaker = lm;
 }
Exemple #19
0
        public void FilterNonMainArticles()
        {
            ListMaker LMaker = new ListMaker();
            LMaker.Add("One");
            LMaker.Add("Two");
            LMaker.Add("Talk:Three");
            LMaker.Add("Four");
            LMaker.Add("Talk:Five");
            LMaker.Add("Talk:Five2");
            LMaker.Add("Six");

            LMaker.FilterNonMainArticles();
            Assert.AreEqual(4, LMaker.NumberOfArticles);
        }