コード例 #1
0
        public void UpdateContentPermissionSuccess()
        {
            //Arrange
            var pageContentRepository = new PageContentRepository(_container);
            var dbContext             = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pageContent           = TestDataRepository.GetPageContents(false).First();

            pageContentRepository.Create(pageContent);
            var contentPermissions = TestDataRepository.GetContentPermissions();

            foreach (var cp in contentPermissions)
            {
                cp.PageContentId = pageContent.Id;
            }
            pageContent.InheritEditPermissions = pageContent.InheritViewPermissions = true;
            pageContent.ContentPermissions     = contentPermissions;

            //Act
            pageContentRepository.UpdateContentPermission(pageContent);
            var result = pageContentRepository.Get(pageContent.Id);


            //Assert
            Assert.NotNull(result);
            Assert.True(result.ContentPermissions.Count > 1);
            Assert.True(result.InheritViewPermissions);
            Assert.True(result.InheritEditPermissions);

            //Clean
            dbContext.ContentPermission.RemoveRange(dbContext.ContentPermission);
        }
コード例 #2
0
        public void AddOrUpdateSuccess()
        {
            //Arrange
            var pageContentRepository = new PageContentRepository(_container);
            var pageContents          = TestDataRepository.GetPageContents(false);
            var dbContext             = _serviceProvider.GetRequiredService <DeviserDbContext>();

            foreach (var item in pageContents)
            {
                item.ContentType.Properties = null;
                pageContentRepository.Create(item);
            }

            var itemToUpdate = pageContents.First();

            itemToUpdate.SortOrder = 10;
            var pageContentsToUpdate = TestDataRepository.GetPageContents().First();

            pageContents.Add(pageContentsToUpdate);

            //Act
            var initialCount = dbContext.PageContent.Count();

            pageContentRepository.AddOrUpdate(pageContents);
            var afterCount  = dbContext.PageContent.Count();
            var updatedItem = pageContentRepository.Get(itemToUpdate.Id);

            //Assert
            Assert.True(afterCount > initialCount);
            Assert.True(updatedItem.SortOrder == itemToUpdate.SortOrder);

            //Clean
            dbContext.PageContent.RemoveRange(dbContext.PageContent);
        }
コード例 #3
0
        public void GetOptionListFail()
        {
            //Arrange
            var pageContentRepository = new PageContentRepository(_container);
            var pageContents          = TestDataRepository.GetPageContents();
            var dbContext             = _serviceProvider.GetRequiredService <DeviserDbContext>();

            foreach (var item in pageContents)
            {
                pageContentRepository.Create(item);
            }
            var pageContentId = Guid.NewGuid();

            //Act
            var result = pageContentRepository.Get(pageContentId);

            //Assert
            Assert.Null(result);
        }
コード例 #4
0
        public void GetByPageLocaleFail()
        {
            //Arrange
            var pageContentRepository = new PageContentRepository(_container);
            var pageContents          = TestDataRepository.GetPageContents();
            var dbContext             = _serviceProvider.GetRequiredService <DeviserDbContext>();

            foreach (var item in pageContents)
            {
                pageContentRepository.Create(item);
            }
            var pageId = Guid.NewGuid();

            //Act
            var result = pageContentRepository.Get(pageId, "");

            //Assert
            Assert.NotNull(result);
            Assert.True(result.Count == 0);
        }
コード例 #5
0
        public void GetByPageLocaleSuccess()
        {
            //Arrange
            var pageContentRepository = new PageContentRepository(_container);
            var pageContents          = TestDataRepository.GetPageContents();
            var dbContext             = _serviceProvider.GetRequiredService <DeviserDbContext>();

            foreach (var item in pageContents)
            {
                pageContentRepository.Create(item);
            }
            var pageContentId = pageContents.First().PageId;
            var locale        = pageContents.First().PageContentTranslation.First().CultureCode;

            //Act
            var result     = pageContentRepository.Get(pageContentId, locale);
            var resultItem = result.First();

            //Assert
            Assert.NotNull(result);
            Assert.True(result.Count > 0);
            Assert.NotNull(resultItem);
            Assert.NotEqual(resultItem.Id, Guid.Empty);
            Assert.NotNull(resultItem.PageContentTranslation);
            Assert.NotNull(resultItem.ContentType);
            //Assert.NotNull(resultItem.ContentType.ContentDataType);
            Assert.NotNull(resultItem.ContentType.Properties);
            Assert.True(resultItem.ContentType.Properties.Count > 0);
            Assert.NotNull(resultItem.ContentPermissions);
            Assert.True(resultItem.ContentPermissions.Count > 0);
            Assert.NotNull(resultItem.Properties);
            Assert.True(resultItem.Properties.Count > 0);
            Assert.True(resultItem.SortOrder > 0);
            Assert.NotEqual(resultItem.ContainerId, Guid.Empty);
            Assert.True(resultItem.CreatedDate > DateTime.MinValue);
            Assert.True(resultItem.LastModifiedDate > DateTime.MinValue);

            //Clean
            dbContext.PageContent.RemoveRange(dbContext.PageContent);
        }
コード例 #6
0
        public void UpdatePageContentSuccess()
        {
            //Arrange
            var pageContentRepository = new PageContentRepository(_container);
            var pageContents          = TestDataRepository.GetPageContents(false);
            var dbContext             = _serviceProvider.GetRequiredService <DeviserDbContext>();

            foreach (var item in pageContents)
            {
                item.ContentType.Properties = null;
                item.ContentPermissions     = null;
                item.PageContentTranslation = null;
                pageContentRepository.Create(item);
            }
            var pageContent = pageContents.First();

            var itemToUpdate = pageContentRepository.Get(pageContent.Id);

            itemToUpdate.IsDeleted = true;


            //Act
            var result = pageContentRepository.Update(itemToUpdate);

            //Assert
            Assert.NotNull(result);
            Assert.NotEqual(result.Id, Guid.Empty);
            Assert.NotNull(result.Properties);
            Assert.True(result.Properties.Count > 0);
            Assert.True(result.SortOrder > 0);
            Assert.NotEqual(result.ContainerId, Guid.Empty);
            Assert.True(result.CreatedDate > DateTime.MinValue);
            Assert.True(result.LastModifiedDate > DateTime.MinValue);
            Assert.True(result.IsDeleted == itemToUpdate.IsDeleted);

            //Clean
            dbContext.PageContent.RemoveRange(dbContext.PageContent);
        }