Example #1
0
        public ActionResult EditPage(int id)
        {
            var page = _repo.GetPage(id);

            if (page == null)
            {
                return(Content("The Page doesnot exists."));
            }
            var model = Mapper.Map <PageVM>(page);

            return(View(model));
        }
        public void GetPageSuccess()
        {
            //Arrange
            var pageRepository = new PageRepository(_container);
            var dbContext      = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pages          = TestDataRepository.GetPages();
            var page           = pages.First();

            pageRepository.CreatePage(page);


            //Act
            var result = pageRepository.GetPage(page.Id);
            var resultPageTranslation = result.PageTranslation.First();

            //Assert
            Assert.NotNull(result);
            Assert.NotEqual(result.Id, Guid.Empty);
            Assert.NotNull(result.PageTranslation);
            Assert.True(result.PageTranslation.Count > 0);
            Assert.NotNull(result.PagePermissions);
            Assert.True(result.PagePermissions.Count > 0);
            Assert.True(result.CreatedDate > DateTime.MinValue);
            Assert.True(result.LastModifiedDate > DateTime.MinValue);
            Assert.NotNull(resultPageTranslation);
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.Name));
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.Description));
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.Locale));
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.Title));
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.URL));

            //Clean
            dbContext.Page.RemoveRange(dbContext.Page);
        }
Example #3
0
        public ActionResult Index(string title)
        {
            //vraagt titel op om te kijken welke pagina het is
            Page page = repo.GetPage(title);

            //als de pagina niet bestaat return to home
            if (page == null)
            {
                return(RedirectToAction("index", "Home", null));
            }
            return(View(page.Title, page));
        }
        public void GetPageFail()
        {
            //Arrange
            var pageRepository = new PageRepository(_container);
            var dbContext      = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pages          = TestDataRepository.GetPages();
            var page           = pages.First();

            dbContext.Page.RemoveRange(dbContext.Page);


            //Act
            var result = pageRepository.GetPage(Guid.NewGuid());

            //Assert
            Assert.Null(result);
        }
        public void UpdatePagePermissionRemoveSuccess()
        {
            //Arrange
            var pageRepository  = new PageRepository(_container);
            var dbContext       = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pages           = TestDataRepository.GetPages();
            var page            = pages.First();
            var pageToUpdate    = pageRepository.CreatePage(page);
            var pagePermissions = pageToUpdate.PagePermissions;

            pagePermissions.Add(new PagePermission
            {
                Id           = Guid.NewGuid(),
                PermissionId = Guid.NewGuid(),
                RoleId       = Guid.NewGuid(),
                PageId       = pageToUpdate.Id
            });

            var initialCount = pageToUpdate.PagePermissions.Count;

            //Act
            pageToUpdate.PagePermissions.Remove(pageToUpdate.PagePermissions.First());
            pageRepository.UpdatePage(pageToUpdate);
            var result     = pageRepository.GetPage(pageToUpdate.Id);
            var afterCount = result.PagePermissions.Count;

            //Assert
            Assert.NotNull(result);
            Assert.NotEqual(result.Id, Guid.Empty);
            Assert.NotNull(result.PageTranslation);
            Assert.True(result.PageTranslation.Count > 0);
            Assert.NotNull(result.PagePermissions);
            Assert.True(result.PagePermissions.Count > 0);
            Assert.True(result.CreatedDate > DateTime.MinValue);
            Assert.True(result.LastModifiedDate > DateTime.MinValue);
            Assert.True(afterCount < initialCount);

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