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()); }
public void Get_Error_SearchTermBad() { Mock <IBestBetsDisplayService> displayService = new Mock <IBestBetsDisplayService>(); Mock <IBestBetsMatchService> matchService = new Mock <IBestBetsMatchService>(); // Create instance of controller BestBetsController controller = new BestBetsController( matchService.Object, displayService.Object, NullLogger <BestBetsController> .Instance ); APIErrorException ex = Assert.Throws <APIErrorException>(() => controller.Get("en", null)); }
public async void Get_Error_LanguageBad() { Mock <IBestBetsDisplayService> displayService = new Mock <IBestBetsDisplayService>(); Mock <IBestBetsMatchService> matchService = new Mock <IBestBetsMatchService>(); Mock <IHealthCheckService> healthService = new Mock <IHealthCheckService>(); // Create instance of controller BestBetsController controller = new BestBetsController( matchService.Object, displayService.Object, healthService.Object, NullLogger <BestBetsController> .Instance ); await Assert.ThrowsAsync <APIErrorException>(() => controller.Get("live", "Chicken", null)); }
public async void Get_EnglishTerm(string searchTerm, BaseDisplayTestData displayData) { Mock <IBestBetsDisplayService> displayService = new Mock <IBestBetsDisplayService>(); displayService .Setup( dispSvc => dispSvc.GetBestBetForDisplay( It.Is <string>(coll => coll == "live"), It.Is <string>(catID => catID == displayData.ExpectedData.ID) ) ) .Returns(Task.FromResult <IBestBetDisplay>(displayData.ExpectedData)); Mock <IBestBetsMatchService> matchService = new Mock <IBestBetsMatchService>(); matchService .Setup( matchSvc => matchSvc.GetMatches( It.Is <string>(coll => coll == "live"), It.Is <string>(lang => lang == "en"), It.Is <string>(term => term == searchTerm) ) ) .Returns(Task.FromResult(new string[] { displayData.ExpectedData.ID })); Mock <IHealthCheckService> healthService = new Mock <IHealthCheckService>(); healthService .Setup( healthSvc => healthSvc.IsHealthy( ) ) .Returns(Task.FromResult(true)); // Create instance of controller BestBetsController controller = new BestBetsController( matchService.Object, displayService.Object, healthService.Object, NullLogger <BestBetsController> .Instance ); IBestBetDisplay[] actualItems = await controller.Get("live", "en", searchTerm); Assert.Equal(actualItems, new IBestBetDisplay[] { displayData.ExpectedData }, new IBestBetDisplayComparer()); }
public async void Get_Error_CollectionEmpty() { Mock <IBestBetsDisplayService> displayService = new Mock <IBestBetsDisplayService>(); Mock <IBestBetsMatchService> matchService = new Mock <IBestBetsMatchService>(); Mock <IHealthCheckService> healthService = new Mock <IHealthCheckService>(); // Create instance of controller BestBetsController controller = new BestBetsController( matchService.Object, displayService.Object, healthService.Object, NullLogger <BestBetsController> .Instance ); APIErrorException ex = await Assert.ThrowsAsync <APIErrorException>(() => controller.Get(null, null, null)); }
public HttpResponseMessage Get(string id) { return(_wrappedObject.Get(id)); }