Example #1
0
        public ActionResult show(string key)
        {
            Book b = BookProvider.GetByKey(key);
            IEnumerable <Page> pages = PageProvider.GetPages(b.PageIds);

            BookViewModel result = new BookViewModel
            {
                Book  = b,
                Pages = pages.ToList()
            };

            return(View(result));
        }
Example #2
0
        public void CanGetPagesByListOfIds()
        {
            // Arrange
            Page p1 = PageBuilder.BuildPage();
            Page p2 = PageBuilder.BuildPage();
            Page p3 = PageBuilder.BuildPage(); // Not used, make sure it doesn't popup in the result!

            Guid[] idList = new Guid[] { p1.Id, p2.Id };

            // Act
            IList <Page> pages = PageProvider.GetPages(idList).ToList();

            // Assert
            Assert.AreEqual(2, pages.Count);
            Assert.AreEqual(p1.Id, pages[0].Id);
            Assert.AreEqual(p2.Id, pages[1].Id);
        }
Example #3
0
        public void CanGetRecipePages()
        {
            // Arrange
            RecipePage p1 = RecipeBuilder.BuildRecipePage("milkshake", 1);
            RecipePage p2 = RecipeBuilder.BuildRecipePage("hotdog", 2);
            Page       p3 = PageBuilder.BuildPage("Test", 3);

            // Act
            IList <Page> pages = PageProvider.GetPages(new List <Guid> {
                p1.Id, p2.Id, p3.Id
            }).ToList();

            // Assert
            Assert.AreEqual(3, pages.Count);
            Assert.IsInstanceOf <RecipePage>(pages[0]);
            Assert.IsInstanceOf <RecipePage>(pages[1]);
            Assert.IsInstanceOf <Page>(pages[2]);
            RecipePage rp1 = (RecipePage)pages[0];

            Assert.AreEqual(p1.Id, rp1.Id);
            Assert.AreEqual(p1.Title, rp1.Title);
            Assert.AreEqual(p1.PageNo, rp1.PageNo);
            Assert.AreEqual(p1.RecipeId, rp1.RecipeId);
        }