public void searchStringTest()
        {
            FakeMainWindow fakeView = new FakeMainWindow();
            FakePresenter fakePresenter = new FakePresenter();
            fakePresenter.Backend = backEnd;
            SearchParsing target = new SearchParsing(fakePresenter);

            // test book suggest
            string originalSearch = "Jud";
            List<string> expected = new List<string>();
            expected.Add("Judges");
            expected.Add("Jude");
            target.searchString(originalSearch, backEnd, fakeView);
            Assert.IsTrue(areArraysEqual(expected.ToArray(), fakeView.getSuggestionsList().ToArray()));
            expected.Clear();
            fakeView.reset();

            // test word suggest
            originalSearch = "Horselea";
            expected.Add("horseleach");
            target.searchString(originalSearch, backEnd, fakeView);
            Assert.IsTrue(areArraysEqual(expected.ToArray(), fakeView.getSuggestionsList().ToArray()));
            expected.Clear();
            fakeView.reset();

            //test chapter suggest
            originalSearch = "Jude";
            expected.Add("Jude 1");
            target.searchString(originalSearch, backEnd, fakeView);
            Assert.IsTrue(areArraysEqual(expected.ToArray(), fakeView.getSuggestionsList().ToArray()));
            expected.Clear();
            fakeView.reset();

            //test verse suggest
            originalSearch = "1 John 1:";
            expected.AddRange(new string[] { "1 John 1:1", "1 John 1:2", "1 John 1:3", "1 John 1:4", "1 John 1:5", "1 John 1:6", "1 John 1:7", "1 John 1:8", "1 John 1:9", "1 John 1:10" });
            target.searchString(originalSearch, backEnd, fakeView);
            Assert.IsTrue(areArraysEqual(expected.ToArray(), fakeView.getSuggestionsList().ToArray()));
            expected.Clear();
            fakeView.reset();

            // tests that break program:

            ////test book range suggest with space before hyphen
            //originalSearch = "1 John -";
            //expected.AddRange(new string[] { "2 John", "3 John", "Jude", "Revelations"});
            //target.searchString(originalSearch, backEnd, fakeView);
            //Assert.IsTrue(areArraysEqual(expected.ToArray(), fakeView.getSuggestionsList().ToArray()));
            //expected.Clear();
            //fakeView.reset();

            ////test chapter range suggest with space before hyphen
            //originalSearch = "1 John 1 -";
            //expected.AddRange(new string[] { "1 John 1:1", "1 John 1:2", "1 John 1:3", "1 John 1:4", "1 John 1:5", "1 John 1:6", "1 John 1:7", "1 John 1:8", "1 John 1:9", "1 John 1:10" });
            //target.searchString(originalSearch, backEnd, fakeView);
            //Assert.IsTrue(areArraysEqual(expected.ToArray(), fakeView.getSuggestionsList().ToArray()));
            //expected.Clear();
            //fakeView.reset();

            ////test verse range suggest
            //originalSearch = "1 John 1-";
            //expected.AddRange(new string[] { "1 John 1:1", "1 John 1:2", "1 John 1:3", "1 John 1:4", "1 John 1:5", "1 John 1:6", "1 John 1:7", "1 John 1:8", "1 John 1:9", "1 John 1:10" });
            //target.searchString(originalSearch, backEnd, fakeView);
            //Assert.IsTrue(areArraysEqual(expected.ToArray(), fakeView.getSuggestionsList().ToArray()));
            //expected.Clear();
            //fakeView.reset();
        }
Beispiel #2
0
 public Presenter(MainWindow view)
 {
     _backend = new BackEndInitializer(this);
     _view = view;
     _ParseSearch = new PresenterFolder.Searching.SearchParsing(this);
 }