コード例 #1
0
        public void Get_EnglishTerm(string searchTerm, BaseCategoryTestData data)
        {
            Mock <IBestBetsDisplayService> displayService = new Mock <IBestBetsDisplayService>();

            displayService
            .Setup(
                dispSvc => dispSvc.GetBestBetForDisplay(
                    It.Is <string>(catID => catID == data.ExpectedData.ID)
                    )
                )
            .Returns(TestingTools.DeserializeXML <CancerGovBestBet>(data.TestFilePath));

            Mock <IBestBetsMatchService> matchService = new Mock <IBestBetsMatchService>();

            matchService
            .Setup(
                matchSvc => matchSvc.GetMatches(
                    It.Is <string>(lang => lang == "en"),
                    It.Is <string>(term => term == searchTerm)
                    )
                )
            .Returns(new string[] { data.ExpectedData.ID });

            // Create instance of controller
            BestBetsController controller = new BestBetsController(
                matchService.Object,
                displayService.Object,
                NullLogger <BestBetsController> .Instance
                );

            IBestBetDisplay[] actualItems = controller.Get("en", searchTerm);

            Assert.Equal(actualItems, new IBestBetDisplay[] { data.ExpectedData }, new IBestBetDisplayComparer());
        }
コード例 #2
0
        void SynonymsMappedCorrectly(SynonymTestData data)
        {
            // Load test BestBet object
            string           filePath = data.TestFilePath;
            CancerGovBestBet testData = TestingTools.DeserializeXML <CancerGovBestBet>(filePath);

            // Put the expected matches into a dictionary for fast lookup.
            Dictionary <string, BestBetsMatch> dictExpectedMatches = new Dictionary <string, BestBetsMatch>();

            foreach (BestBetsMatch item in data.ExpectedMatches)
            {
                dictExpectedMatches.Add(item.Synonym, item);
            }

            // Create a BestBetMapper from a test BestBet.
            BestBetSynonymMapper mapper = new BestBetSynonymMapper(
                GetTokenizerServiceForData(data),
                testData
                );

            Assert.All(mapper, match => {
                string synonym = match.Synonym;
                Assert.True(dictExpectedMatches.ContainsKey(synonym));
                Assert.Equal(dictExpectedMatches[synonym], match, new BestBetsMatchComparer());
            });
        }
コード例 #3
0
        public void Can_Deserialize_XML(BaseCategoryTestData data)
        {
            //Setup the expected object.
            CancerGovBestBet actCat = TestingTools.DeserializeXML <CancerGovBestBet>(data.TestFilePath);

            //Compare Object
            Assert.Equal(data.ExpectedData, actCat, new IBestBetCategoryComparer());
        }
コード例 #4
0
        void CorrectNumberOfSynonymsFound(SynonymTestData data)
        {
            // Load test BestBet object
            string           filePath = data.TestFilePath;
            CancerGovBestBet testData = TestingTools.DeserializeXML <CancerGovBestBet>(filePath);

            int expectedCount = data.ExpectedMatches.Count();

            // Create a BestBetMapper from a test BestBet.
            BestBetSynonymMapper mapper = new BestBetSynonymMapper(
                GetTokenizerServiceForData(data),
                testData
                );

            int actualCount = mapper.Count();

            // Verify that returned list of BestBetMatch objects matches what's expected.
            Assert.Equal(expectedCount, actualCount);
        }