예제 #1
0
        public void CanGetAllStaticPages()
        {
            var repo = new InMemoryStaticPageRepository();

            var list = repo.GetAll();

            Assert.AreEqual(4, list.Count);
        }
예제 #2
0
        public void CanGetStaticPageById()
        {
            var repo = new InMemoryStaticPageRepository();

            var sp = repo.Get(1);

            Assert.AreEqual(sp.Id, 1);
            Assert.AreEqual(sp.StaticPageTitle, "a page with a picture of master chief");
            Assert.AreEqual(sp.StaticPageContent, "video game blog faq");
            Assert.AreEqual(sp.StaticPageImageFileName, "masterchief.jpg");
        }
예제 #3
0
        public void CanUpdateStaticPage()
        {
            var repo = new InMemoryStaticPageRepository();

            var sp = repo.Get(4);

            sp.StaticPageContent       = "This static page has been updated.";
            sp.StaticPageImageFileName = "placeholderUpdate.png";
            sp.StaticPageTitle         = "Updated Static Page";

            repo.Edit(sp);

            Assert.AreEqual(repo.Get(4).StaticPageContent, "This static page has been updated.");
            Assert.AreEqual(repo.Get(4).StaticPageTitle, "Updated Static Page");
            Assert.AreEqual(repo.Get(4).StaticPageImageFileName, "placeholderUpdate.png");
        }
예제 #4
0
        public void CanDeleteStaticPage()
        {
            var        repo = new InMemoryStaticPageRepository();
            StaticPage sp   = new StaticPage();

            sp.StaticPageTitle         = "Test Page Title Two";
            sp.StaticPageImageFileName = "placeholder2.png";
            sp.StaticPageContent       = "This is content for a second test static page.";

            repo.Add(sp);

            Assert.IsNotNull(repo.Get(5));
            Assert.AreEqual(repo.Get(5).StaticPageContent, "This is content for a second test static page.");

            repo.Delete(5);

            Assert.IsNull(repo.Get(5));
        }
예제 #5
0
        public void CanAddStaticPage()
        {
            var        repo = new InMemoryStaticPageRepository();
            StaticPage sp   = new StaticPage();

            sp.StaticPageTitle         = "Test Page Title";
            sp.StaticPageImageFileName = "placeholder.png";
            sp.StaticPageContent       = "This is content for a static page.";

            repo.Add(sp);

            var list       = repo.GetAll();
            var staticPage = repo.Get(4);

            Assert.AreEqual(list.Count, 4);
            Assert.AreEqual(staticPage.Id, 4);
            Assert.AreEqual(staticPage.StaticPageTitle, "Test Page Title");
            Assert.AreEqual(staticPage.StaticPageImageFileName, "placeholder.png");
            Assert.AreEqual(staticPage.StaticPageContent, "This is content for a static page.");
        }
예제 #6
0
        protected override void Seed(VideoGameBlog.Data.EntityFramework.InitDbContext context)
        {
            var userMgr = new UserManager <BlogUser>(new UserStore <BlogUser>(context));
            var roleMgr = new RoleManager <BlogRole>(new RoleStore <BlogRole>(context));

            if (!roleMgr.RoleExists("Admin"))
            {
                roleMgr.Create(new BlogRole()
                {
                    Name = "Admin"
                });
            }
            if (!roleMgr.RoleExists("Marketing"))
            {
                roleMgr.Create(new BlogRole()
                {
                    Name = "Marketing"
                });
            }
            if (!roleMgr.RoleExists("Disabled"))
            {
                roleMgr.Create(new BlogRole()
                {
                    Name = "Disabled"
                });
            }

            // create the default user
            var admin = new BlogUser()
            {
                UserName    = "******",
                Email       = "*****@*****.**",
                PhoneNumber = "1111111111"
            };
            var marketing = new BlogUser()
            {
                UserName    = "******",
                Email       = "*****@*****.**",
                PhoneNumber = "2222222222"
            };
            var disabled = new BlogUser()
            {
                UserName    = "******",
                Email       = "*****@*****.**",
                PhoneNumber = "3333333333"
            };

            // create the user with the manager class
            if (userMgr.FindByName(admin.UserName) == null)
            {
                userMgr.Create(admin, "corndog123");
            }
            if (userMgr.FindByName(marketing.UserName) == null)
            {
                userMgr.Create(marketing, "corndog123");
            }
            if (userMgr.FindByName(disabled.UserName) == null)
            {
                userMgr.Create(disabled, "corndog123");
            }

            // add the user to the admin role
            userMgr.AddToRole(admin.Id, "Admin");
            userMgr.AddToRole(marketing.Id, "Marketing");
            userMgr.AddToRole(disabled.Id, "Disabled");

            InMemoryCategoryRepository catRepo = new InMemoryCategoryRepository();

            foreach (var c in catRepo.GetAll())
            {
                context.Categories.AddOrUpdate(c);
                context.SaveChanges();
            }

            InMemoryTagRepository tagRepo = new InMemoryTagRepository();

            foreach (var t in tagRepo.GetAll())
            {
                context.Tags.AddOrUpdate(t);
                context.SaveChanges();
            }

            InMemoryStaticPageRepository statRepo = new InMemoryStaticPageRepository();

            foreach (var s in statRepo.GetAll())
            {
                context.StaticPages.AddOrUpdate(s);
                context.SaveChanges();
            }

            InMemoryPostRepository postRepo = new InMemoryPostRepository();

            foreach (var p in postRepo.GetAll())
            {
                context.Posts.AddOrUpdate(p);
                context.SaveChanges();
            }
        }