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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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());
        }
예제 #5
0
        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));
        }
예제 #6
0
 public HttpResponseMessage Get(string id)
 {
     return(_wrappedObject.Get(id));
 }