public async Task UpdatesBookmarkIfPageIsNowFull()
        {
            var helper     = new TestHelper(UrlToApi);
            var repository = new InMemoryProviderAgreementStatusRepository(Mock.Of <ILog>());

            await repository.AddContractEventsForPage(new List <ContractFeedEvent> {
                new ContractFeedEvent
                {
                    FundingTypeCode = "MAIN",
                    HierarchyType   = "CONTRACT",
                    Id         = Guid.Parse("75419D76-212B-47E2-B0B0-0B46C94120E7"),
                    ProviderId = 10017566,
                    Status     = "Approved",
                    Updated    = DateTime.Parse("1998-12-07"),
                    PageNumber = 6
                }
            }, Guid.Parse("3bb5ad99-d528-4e77-af23-d7639f3dc86c"));

            var service = helper.SetUpProviderAgreementStatusService(repository);

            await service.UpdateProviderAgreementStatuses();

            helper.MockFeedProcessorClient.Verify(m => m.GetAuthorizedHttpClient(), Times.Exactly(4));
            repository.GetLatestBookmark().Result.Should().Be(Guid.Parse("985509f9-6da6-48d2-b0e1-90ad8337def9"));
        }
示例#2
0
        public ProviderAgreementStatusService SetUpProviderAgreementStatusService(
            InMemoryProviderAgreementStatusRepository repository)
        {
            MockFeedProcessorClient = GetMockFeedProcessorClient();

            var reader       = new ContractFeedReader(MockFeedProcessorClient.Object, Mock.Of <ILog>());
            var dataProvider = new ContractFeedProcessor(reader, new MockContractFeedEventValidator(), Mock.Of <ILog>());

            var service = new ProviderAgreementStatusService(dataProvider, repository, Mock.Of <ILog>());

            return(service);
        }
        public async Task FetchAllDocuments()
        {
            // Feed is set to have 13 pages
            var helper     = new TestHelper(UrlToApi);
            var repository = new InMemoryProviderAgreementStatusRepository(Mock.Of <ILog>());
            var service    = helper.SetUpProviderAgreementStatusService(repository);

            await service.UpdateProviderAgreementStatuses();

            helper.MockFeedProcessorClient.Verify(m => m.GetAuthorizedHttpClient(), Times.Exactly(26)); // reading 13 pages to find the start then back through
            repository.LastBookmarkRead.Should().Be(Guid.Parse("985509f9-6da6-48d2-b0e1-90ad8337def9"));
            repository.Data.Count.Should().Be(122);                                                     // All pages read 12 * 10 + 2(items on latest page)
        }