Ejemplo n.º 1
0
        public async Task LmiOrchestrationTriggerGetGraphSummaryItemsActivityIsSuccessful()
        {
            // Arrange
            const int summariesCount = 2;
            var       dummySummaries = A.CollectionOfDummy <SummaryItem>(summariesCount);

            A.CallTo(() => fakeCmsApiService.GetSummaryAsync <SummaryItem>()).Returns(dummySummaries);

            // Act
            var results = await lmiOrchestrationTrigger.GetGraphSummaryItemsActivity(null).ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeCmsApiService.GetSummaryAsync <SummaryItem>()).MustHaveHappenedOnceExactly();
            Assert.Equal(dummySummaries, results);
        }
Ejemplo n.º 2
0
        public async Task <IList <CmsApiSummaryItemModel>?> GetSummaryListAsync()
        {
            logger.LogInformation("Get summary list");

            var summaryList = await cmsApiService.GetSummaryAsync <CmsApiSummaryItemModel>().ConfigureAwait(false);

            logger.LogInformation("Get summary list completed");

            return(summaryList);
        }
Ejemplo n.º 3
0
        public async Task CacheReloadServiceReloadIsSuccessfulForCreate()
        {
            // arrange
            const int NumerOfSummaryItems           = 2;
            const int NumberOfDeletions             = 3;
            var       cancellationToken             = new CancellationToken(false);
            var       expectedValidContentPageModel = BuildValidContentPageModel();
            var       fakePagesSummaryItemModels    = BuldFakePagesSummaryItemModel(NumerOfSummaryItems);
            var       fakeCachedContentPageModels   = BuldFakeContentPageModels(NumberOfDeletions);

            A.CallTo(() => fakeCmsApiService.GetSummaryAsync <CmsApiSummaryItemModel>()).Returns(fakePagesSummaryItemModels);
            A.CallTo(() => fakeCmsApiService.GetItemAsync <CmsApiDataModel>(A <Uri> .Ignored)).Returns(A.Fake <CmsApiDataModel>());
            A.CallTo(() => fakeMapper.Map <ContentPageModel>(A <CmsApiDataModel> .Ignored)).Returns(expectedValidContentPageModel);
            A.CallTo(() => fakeEventMessageService.UpdateAsync(A <ContentPageModel> .Ignored)).Returns(HttpStatusCode.NotFound);
            A.CallTo(() => fakeEventMessageService.CreateAsync(A <ContentPageModel> .Ignored)).Returns(HttpStatusCode.Created);
            A.CallTo(() => fakeEventMessageService.GetAllCachedItemsAsync()).Returns(fakeCachedContentPageModels);
            A.CallTo(() => fakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).Returns(HttpStatusCode.OK);
            A.CallTo(() => fakeContentCacheService.AddOrReplace(A <Guid> .Ignored, A <List <Guid> > .Ignored, A <string> .Ignored));

            var cacheReloadService = new CacheReloadService(fakeLogger, fakeMapper, fakeEventMessageService, fakeCmsApiService, fakeContentCacheService, fakeAppRegistryService, fakeContentTypeMappingService, fakeApiCacheService);

            // act
            await cacheReloadService.Reload(cancellationToken).ConfigureAwait(false);

            // assert
            A.CallTo(() => fakeContentTypeMappingService.AddMapping(A <string> .Ignored, A <Type> .Ignored)).MustHaveHappenedOnceOrMore();
            A.CallTo(() => fakeCmsApiService.GetSummaryAsync <CmsApiSummaryItemModel>()).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeContentCacheService.Clear()).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeCmsApiService.GetItemAsync <CmsApiDataModel>(A <Uri> .Ignored)).MustHaveHappened(NumerOfSummaryItems, Times.Exactly);
            A.CallTo(() => fakeMapper.Map <ContentPageModel>(A <CmsApiDataModel> .Ignored)).MustHaveHappened(NumerOfSummaryItems, Times.Exactly);
            A.CallTo(() => fakeEventMessageService.UpdateAsync(A <ContentPageModel> .Ignored)).MustHaveHappened(NumerOfSummaryItems, Times.Exactly);
            A.CallTo(() => fakeEventMessageService.CreateAsync(A <ContentPageModel> .Ignored)).MustHaveHappened(NumerOfSummaryItems, Times.Exactly);
            A.CallTo(() => fakeEventMessageService.GetAllCachedItemsAsync()).MustHaveHappenedTwiceExactly();
            A.CallTo(() => fakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustHaveHappened(NumberOfDeletions, Times.Exactly);
            A.CallTo(() => fakeContentCacheService.AddOrReplace(A <Guid> .Ignored, A <List <Guid> > .Ignored, A <string> .Ignored)).MustHaveHappened(NumerOfSummaryItems, Times.Exactly);
            A.CallTo(() => fakeAppRegistryService.PagesDataLoadAsync()).MustHaveHappenedOnceExactly();
        }
        public async Task <IList <SummaryItem>?> GetGraphSummaryItemsActivity([ActivityTrigger] string?name)
        {
            logger.LogInformation("Getting LMI Graph summaries");

            return(await cmsApiService.GetSummaryAsync <SummaryItem>().ConfigureAwait(false));
        }