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 IBestBetsController CreateController()
        {
            var bestBetsController = new BestBetsController
            {
                Request = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            return new BestBetsControllerWrapper(bestBetsController);
        }
Beispiel #3
0
        public IBestBetsController CreateController()
        {
            var bestBetsController = new BestBetsController
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            return(new BestBetsControllerWrapper(bestBetsController));
        }
        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));
        }
Beispiel #5
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));
        }
Beispiel #6
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));
        }
Beispiel #7
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());
        }
Beispiel #8
0
        public async void IsHealthy_Healthy()
        {
            IBestBetsDisplayService displayService = null;
            IBestBetsMatchService   matchService   = null;
            IHealthCheckService     healthService  = GetMockedHealthSvc <IHealthCheckService>(true);

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

            var actual = await controller.GetStatus();

            Assert.Equal(BestBetsController.HEALTHY_STATUS, actual, ignoreCase: true);
        }
Beispiel #9
0
        public async void IsHealthy_Unhealthy()
        {
            IBestBetsDisplayService displayService = null;
            IBestBetsMatchService   matchService   = null;
            IHealthCheckService     healthService  = GetMockedHealthSvc <IHealthCheckService>(false);

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

            // If the health check service is unhealthy, verify that GetStatus() throws APIErrorException
            // with a status of 500.
            APIErrorException ex = await Assert.ThrowsAsync <APIErrorException>(() => controller.GetStatus());

            Assert.Equal(500, ex.HttpStatusCode);
        }
 public BestBetsControllerWrapper(BestBetsController wrappedObject)
 {
     _wrappedObject = wrappedObject;
 }
Beispiel #11
0
 public BestBetsControllerWrapper(BestBetsController wrappedObject)
 {
     _wrappedObject = wrappedObject;
 }