public void ClearPages_Should_Set_TempData_Message_And_Clear_Cache_And_Clear_All_Pages()
        {
            // Arrange
            _repository.AddNewPage(new Page()
            {
                Id = 1
            }, "text", "admin", DateTime.UtcNow);
            _repository.AddNewPage(new Page()
            {
                Id = 2
            }, "text", "admin", DateTime.UtcNow);

            _pageCache.Add(1, new PageViewModel());
            _listCache.Add("list.somekey", new List <string>());
            _siteCache.AddMenu("should not be cleared");

            // Act
            RedirectToRouteResult result = _toolsController.ClearPages() as RedirectToRouteResult;

            // Assert
            Assert.That(result, Is.Not.Null, "RedirectToRouteResult");
            Assert.That(result.RouteValues["action"], Is.EqualTo("Index"));

            Assert.That(_toolsController.TempData["SuccessMessage"], Is.EqualTo(SiteStrings.SiteSettings_Tools_ClearDatabase_Message));
            Assert.That(_cache.Count(), Is.EqualTo(1));
            Assert.That(_repository.AllPages().Count(), Is.EqualTo(0));
        }
Beispiel #2
0
        public void ClearPageTables_Should_Remove_All_Pages_And_Content()
        {
            // Arrange
            _repository.AddNewPage(new Page(), "test1", "test1", DateTime.UtcNow);
            _repository.AddNewPage(new Page(), "test2", "test2", DateTime.UtcNow);

            // Act
            _pageService.ClearPageTables();

            // Assert
            Assert.That(_repository.AllPages().Count(), Is.EqualTo(0));
            Assert.That(_repository.AllPageContents().Count(), Is.EqualTo(0));
        }