Ejemplo n.º 1
0
        public void SaveStaticPage_IdZeroAndUrlAlreadyExists_CountIsSame()
        {
            EFBlogPostRepository repo = new EFBlogPostRepository(SharedDbContext);
            var page = new StaticPage
            {
                PageTitle    = "Static Page No 4",
                StaticPageId = 0,
                FullContent  = "content"
            };
            var countBefore = repo.StaticPages.Count();
            var result      = repo.SaveStaticPage(page);

            Assert.AreEqual(countBefore, repo.StaticPages.Count());
        }
Ejemplo n.º 2
0
        public void SaveStaticPage_IdZeroAndUrlAlreadyExists_ReturnsFalse()
        {
            EFBlogPostRepository repo = new EFBlogPostRepository(SharedDbContext);
            var page = new StaticPage
            {
                PageTitle    = "Static Page No 4",
                StaticPageId = 0,
                FullContent  = "content"
            };

            var result = repo.SaveStaticPage(page);

            Assert.IsFalse(result);
        }
Ejemplo n.º 3
0
        public void SaveStaticPage_ZeroId_ReturnsTrue()
        {
            EFBlogPostRepository repo = new EFBlogPostRepository(SharedDbContext);
            var page = new StaticPage
            {
                PageTitle    = "Title",
                StaticPageId = 0,
                FullContent  = "content"
            };

            var result = repo.SaveStaticPage(page);

            Assert.IsTrue(result);
        }
Ejemplo n.º 4
0
        public void SaveStaticPage_ZeroId_AddsNew()
        {
            EFBlogPostRepository repo = new EFBlogPostRepository(SharedDbContext);
            var page = new StaticPage
            {
                PageTitle    = "Title",
                StaticPageId = 0,
                FullContent  = "content"
            };

            var countBefore = repo.StaticPages.Count();

            repo.SaveStaticPage(page);
            Assert.IsTrue(repo.StaticPages.Count() > countBefore);
        }
Ejemplo n.º 5
0
        public void SaveStaticPage_SaveExistingPage_CountIsSame()
        {
            EFBlogPostRepository repo = new EFBlogPostRepository(SharedDbContext);
            string newFullContent     = "Some completely new full content";
            string newPageTitle       = "Some completely new page title";

            var page = repo.StaticPages.First();

            page.PageTitle   = newPageTitle;
            page.FullContent = newFullContent;

            var count = repo.StaticPages.Count();

            repo.SaveStaticPage(page);

            Assert.AreEqual(count, repo.StaticPages.Count());
        }
Ejemplo n.º 6
0
        public void SaveStaticPage_SaveExistingPage_ChangesRecorded()
        {
            EFBlogPostRepository repo = new EFBlogPostRepository(SharedDbContext);
            string newFullContent     = "Some completely new full content";
            string newPageTitle       = "Some completely new page title";

            var page = repo.StaticPages.First();

            page.PageTitle   = newPageTitle;
            page.FullContent = newFullContent;

            var count = repo.StaticPages.Count();

            repo.SaveStaticPage(page);

            var newPage = repo.StaticPages.Where(sp => sp.PageTitle == newPageTitle).FirstOrDefault();

            Assert.IsNotNull(newPage);
            Assert.AreEqual(newPage.PageTitle, newPageTitle);
            Assert.AreEqual(newPage.FullContent, newFullContent);
        }