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()); }
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()); }); }
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()); }
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); }