示例#1
0
        public void TestLocationString()
        {
            MountainProjectDataSearch.InitMountainProjectData(@"..\..\MountainProjectDBBuilder\bin\MountainProjectAreas.xml");

            for (int i = 0; i < testCriteria_location.GetLength(0); i++)
            {
                string query            = testCriteria_location[i, 0];
                string expectedLocation = testCriteria_location[i, 1];
                string resultLocation   = BotReply.GetLocationString(MountainProjectDataSearch.SearchMountainProject(query));
                resultLocation = resultLocation.Replace("\n\n", "");        //Remove markdown newline
                resultLocation = resultLocation.Replace("Located in ", ""); //Simplify results for unit test

                Assert.AreEqual(expectedLocation, resultLocation);
            }
        }
        public void TestLocationString()
        {
            InitMPData();

            for (int i = 0; i < testCriteria_location.GetLength(0); i++)
            {
                string       query            = testCriteria_location[i, 0];
                string       expectedLocation = testCriteria_location[i, 1];
                SearchResult searchResult     = MountainProjectDataSearch.Search(query);
                string       resultLocation   = BotReply.GetLocationString(searchResult.FilteredResult);
                resultLocation = resultLocation.Replace(Markdown.NewLine, "");       //Remove markdown newline
                resultLocation = resultLocation.Replace("Located in ", "");          //Simplify results for unit test
                resultLocation = Regex.Replace(resultLocation, @"\[|\]\(.*?\)", ""); //Remove markdown link formatting

                Assert.AreEqual(expectedLocation, resultLocation, "Failed for " + testCriteria_location[i, 0]);
                Assert.IsTrue(searchResult.TimeSpanTaken().TotalSeconds < 5, $"{query} took too long ({searchResult.TimeTakenMS} ms)");
            }
        }