예제 #1
0
        public void ContentCacheServiceGetContentIdsContainingContentItemIdReturnsListWhenMatch()
        {
            // arrange
            var         contentId1     = Guid.NewGuid();
            var         contentId2     = Guid.NewGuid();
            var         contentItemId  = Guid.NewGuid();
            List <Guid> expectedResult = new List <Guid> {
                contentId1, contentId2
            };

            var contentCacheService = new ContentCacheService(A.Fake <ILogger <ContentCacheService> >());

            contentCacheService.AddOrReplace(contentId1, new List <Guid> {
                Guid.NewGuid(), contentItemId, Guid.NewGuid(),
            });
            contentCacheService.AddOrReplace(contentId2, new List <Guid> {
                Guid.NewGuid(), contentItemId, Guid.NewGuid(),
            });

            // act
            var result = contentCacheService.GetContentIdsContainingContentItemId(contentItemId);

            // assert
            Assert.Equal(expectedResult, result);
        }
예제 #2
0
        public void ContentCacheServiceGetContentCacheStatusReturnsStatusContentAndContentItem()
        {
            // arrange
            var contentItemId = Guid.NewGuid();
            var contentId     = Guid.NewGuid();
            IEnumerable <ContentCacheResult> expectedResult = new List <ContentCacheResult>()
            {
                new ContentCacheResult {
                    ContentType = "default", Result = ContentCacheStatus.Content
                }, new ContentCacheResult {
                    ContentType = "default", ParentContentId = contentId, Result = ContentCacheStatus.ContentItem
                }
            };

            var contentCacheService = new ContentCacheService(A.Fake <ILogger <ContentCacheService> >());

            contentCacheService.AddOrReplace(contentId, new List <Guid> {
                Guid.NewGuid(), contentItemId, Guid.NewGuid(),
            });
            contentCacheService.AddOrReplace(contentItemId, new List <Guid> {
                Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(),
            });

            // act
            var result = contentCacheService.GetContentCacheStatus(contentItemId);

            // assert
            Assert.Equal(JsonConvert.SerializeObject(expectedResult), JsonConvert.SerializeObject(result));
        }
예제 #3
0
        public void ContentCacheServiceClearNoReturns()
        {
            // arrange
            var contentCacheService = new ContentCacheService(A.Fake <ILogger <ContentCacheService> >());

            // act
            contentCacheService.Clear();

            // assert
            Assert.True(true);      // nothing can be asserted here
        }
예제 #4
0
        public void ContentCacheServiceAddOrReplaceAdd()
        {
            // arrange
            var contentId     = Guid.NewGuid();
            var contentItemId = Guid.NewGuid();

            var contentCacheService = new ContentCacheService(A.Fake <ILogger <ContentCacheService> >());

            // act
            contentCacheService.AddOrReplace(contentId, new List <Guid> {
                Guid.NewGuid(), contentItemId, Guid.NewGuid(),
            });

            // assert
            Assert.True(true);      // nothing can be asserted here
        }
예제 #5
0
        public void ContentCacheServiceCheckIsContentItemReturnsFalse()
        {
            // arrange
            const ContentCacheStatus expectedResult = ContentCacheStatus.NotFound;
            var contentItemId = Guid.NewGuid();

            var contentCacheService = new ContentCacheService(A.Fake <ILogger <ContentCacheService> >());

            contentCacheService.AddOrReplace(Guid.NewGuid(), new List <Guid> {
                Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(),
            });

            // act
            var result = contentCacheService.CheckIsContentItem(contentItemId);

            // assert
            Assert.Equal(expectedResult, result);
        }
예제 #6
0
        public void ContentCacheServiceGetContentCacheStatusReturnsStatusNotFound()
        {
            // arrange
            IEnumerable <ContentCacheResult> expectedResult = new List <ContentCacheResult>()
            {
                new ContentCacheResult {
                    ContentType = string.Empty, Result = ContentCacheStatus.NotFound
                }
            };
            var contentItemId = Guid.NewGuid();

            var contentCacheService = new ContentCacheService(A.Fake <ILogger <ContentCacheService> >());

            // act
            var result = contentCacheService.GetContentCacheStatus(contentItemId);

            // assert
            Assert.Equal(JsonConvert.SerializeObject(expectedResult), JsonConvert.SerializeObject(result));
            Assert.Single(result);
        }
예제 #7
0
 public ContentCacheController(ILogger logger, ContentCacheService service)
 {
     _logger  = logger;
     _service = service;
 }