public void HttpStatusError(System.Net.HttpStatusCode status)
        {
            string TestFilePath = "CDEPubContentListingService.ListAvailablePaths.json";

            //Setup a mock handler, which is what HttpClient uses under the hood to fetch
            //data.
            var mockHttp = new MockHttpMessageHandler();

            string filePath = TestFilePath;

            ByteArrayContent content = new ByteArrayContent(TestingTools.GetTestFileAsBytes(filePath));

            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

            mockHttp
            .When("https://www.cancer.gov/PublishedContent/List")
            .Respond(status, content);

            // Setup the mocked Options
            Mock <IOptions <PublishedContentListingServiceOptions> > clientOptions = new Mock <IOptions <PublishedContentListingServiceOptions> >();

            clientOptions
            .SetupGet(opt => opt.Value)
            .Returns(new PublishedContentListingServiceOptions()
            {
                Host     = "https://www.cancer.gov",
                ListRoot = "/PublishedContent/List"
            }
                     );

            IPublishedContentListingService listClient = new CDEPubContentListingService(new HttpClient(mockHttp),
                                                                                         clientOptions.Object,
                                                                                         NullLogger <CDEPubContentListingService> .Instance);

            Exception ex = Assert.Throws <NCI.OCPL.Services.CDE.PublishedContentListing.APIErrorException>(
                // We don't care about the return value, only that an exception occured.
                () => listClient.ListAvailablePaths()
                );

            // All errors should return a status 500.
            Assert.Equal(500, ((NCI.OCPL.Services.CDE.PublishedContentListing.APIErrorException)ex).HttpStatusCode);
        }
        public void BestBetsEntry()
        {
            CancerResearchIdeas testData = new CancerResearchIdeas();


            // TODO: Create a TestData object.
            string TestFilePath = testData.TestFilePath;

            //Setup a mock handler, which is what HttpClient uses under the hood to fetch
            //data.
            var mockHttp = new MockHttpMessageHandler();

            string filePath = TestFilePath;

            ByteArrayContent content = new ByteArrayContent(TestingTools.GetTestFileAsBytes(filePath));

            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/xml");

            mockHttp
            .When(string.Format("https://www.cancer.gov/PublishedContent/BestBets/{0}", filePath))
            .Respond(System.Net.HttpStatusCode.OK, content);

            // Setup the mocked Options
            Mock <IOptions <PublishedContentListingServiceOptions> > clientOptions = new Mock <IOptions <PublishedContentListingServiceOptions> >();

            clientOptions
            .SetupGet(opt => opt.Value)
            .Returns(new PublishedContentListingServiceOptions()
            {
                Host = "https://www.cancer.gov"
            }
                     );


            IPublishedContentListingService publishedContentClient = new CDEPubContentListingService(new HttpClient(mockHttp),
                                                                                                     clientOptions.Object,
                                                                                                     NullLogger <CDEPubContentListingService> .Instance);

            CancerGovBestBet actualReturn = publishedContentClient.GetPublishedFile <CancerGovBestBet>(String.Format("/PublishedContent/BestBets/{0}", filePath));

            Assert.Equal(testData.ExpectedData, actualReturn, new IBestBetDisplayComparer());
        }
        public void DataLoading(string rootName, string dataPath)
        {
            // TODO: Create a TestData object.
            string TestFilePath = "CDEPubContentListingService.BestBets.json";

            //Setup a mock handler, which is what HttpClient uses under the hood to fetch
            //data.
            var mockHttp = new MockHttpMessageHandler();

            string filePath = TestFilePath;

            ByteArrayContent content = new ByteArrayContent(TestingTools.GetTestFileAsBytes(filePath));

            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

            mockHttp
            .When(string.Format("https://www.cancer.gov/PublishedContent/List?root={0}&path={1}&fmt=json", rootName, dataPath))
            .Respond(System.Net.HttpStatusCode.OK, content);

            // Setup the mocked Options
            Mock <IOptions <PublishedContentListingServiceOptions> > clientOptions = new Mock <IOptions <PublishedContentListingServiceOptions> >();

            clientOptions
            .SetupGet(opt => opt.Value)
            .Returns(new PublishedContentListingServiceOptions()
            {
                Host     = "https://www.cancer.gov",
                ListRoot = "/PublishedContent/List",
                SpecificListPathFormatter = "?root={0}&path={1}&fmt=json"
            }
                     );

            IPublishedContentListingService listClient = new CDEPubContentListingService(new HttpClient(mockHttp),
                                                                                         clientOptions.Object,
                                                                                         NullLogger <CDEPubContentListingService> .Instance);

            IPublishedContentListing actualList = listClient.GetItemsForPath(rootName, dataPath);

            /// TODO: Make this a list comparison.
            Assert.NotNull(actualList);
        }
        public void DataLoading()
        {
            string TestFilePath = "CDEPubContentListingService.ListAvailablePaths.json";

            //Setup a mock handler, which is what HttpClient uses under the hood to fetch
            //data.
            var mockHttp = new MockHttpMessageHandler();

            string filePath = TestFilePath;

            ByteArrayContent content = new ByteArrayContent(TestingTools.GetTestFileAsBytes(filePath));

            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

            mockHttp
            .When("https://www.cancer.gov/PublishedContent/List")
            .Respond(System.Net.HttpStatusCode.OK, content);

            // Setup the mocked Options
            Mock <IOptions <PublishedContentListingServiceOptions> > clientOptions = new Mock <IOptions <PublishedContentListingServiceOptions> >();

            clientOptions
            .SetupGet(opt => opt.Value)
            .Returns(new PublishedContentListingServiceOptions()
            {
                Host     = "https://www.cancer.gov",
                ListRoot = "/PublishedContent/List"
            }
                     );

            IPublishedContentListingService listClient = new CDEPubContentListingService(new HttpClient(mockHttp),
                                                                                         clientOptions.Object,
                                                                                         NullLogger <CDEPubContentListingService> .Instance);

            IEnumerable <IPathListInfo> actualList = listClient.ListAvailablePaths();

            /// TODO: Make this a list comparison.
            Assert.NotNull(actualList);
        }