Beispiel #1
0
 public RoatpWebsiteDataSource(
     HttpClient httpClient,
     IStateStore stateStore,
     SourceDataConfiguration configuration,
     ILogger <RoatpWebsiteDataSource> logger)
 {
     _httpClient    = httpClient;
     _stateStore    = stateStore;
     _configuration = configuration;
     _logger        = logger;
 }
        public void Arrange()
        {
            _configuration = new SourceDataConfiguration
            {
                RoatpDownloadPageUrl = "https://roatp.website.url/place"
            };
            _absoluteDownloadUri = new Uri(new Uri(_configuration.RoatpDownloadPageUrl, UriKind.Absolute),
                                           new Uri("/data.csv", UriKind.Relative));

            _httpClientMock = new HttpClientMock();
            _httpClientMock
            .When(req => req.RequestUri.AbsoluteUri.StartsWith(_configuration.RoatpDownloadPageUrl, StringComparison.InvariantCultureIgnoreCase))
            .Then(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("<html><head></head><body><div class=\"attachment-details\"><a href=\"/data.csv\">download link</a></div></body></html>")
            });
            _httpClientMock
            .When(req => req.RequestUri.AbsoluteUri.Equals(_absoluteDownloadUri.AbsoluteUri, StringComparison.InvariantCultureIgnoreCase))
            .Then(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(
                    "Ukprn,Name,ProviderType,ParentCompanyGuarantee,NewOrganisationWithoutFinancialTrackRecord,StartDate,ProviderNotCurrentlyStartingNewApprentices,ApplicationDeterminedDate\n" +
                    "10001001,Provider One,Main provider,False,False,10/12/2020,,30/07/2020\n" +
                    "10001002,Provider One,Main provider,False,False,13/03/2017,,28/08/2019")
            });

            _stateStoreMock = new Mock <IStateStore>();

            _loggerMock = new Mock <ILogger <RoatpWebsiteDataSource> >();

            _dataSource = new RoatpWebsiteDataSource(
                _httpClientMock.AsHttpClient(),
                _stateStoreMock.Object,
                _configuration,
                _loggerMock.Object);
        }