コード例 #1
0
        public void CategoryReturnsCorrectNumberOfRecipesInSelectedCategory()
        {
            var db = new FakeBlondsCookingContext();
            db.AddSet(FakeData.Categories);
            db.AddSet(FakeData.Recipes);
            HomeController controller = new HomeController(db);

            ViewResult result = controller.Category(1) as ViewResult;
            IEnumerable<Recipe> model = result.Model as IEnumerable<Recipe>;
            Assert.AreEqual(9, model.Count());
        }
コード例 #2
0
        public void ReturnsSelectedRecipe()
        {
            var db = new FakeBlondsCookingContext();
            db.AddSet(FakeData.Categories);
            db.AddSet(FakeData.Recipes);
            CategoryController controller = new CategoryController();

            ViewResult result = controller.Recipe(1) as ViewResult;
            Recipe model = result.Model as Recipe;
            Assert.IsNotNull(model);
        }
コード例 #3
0
        public void CategoryReturnErrorPageWhenCannotFindSelectedCategory()
        {
            var db = new FakeBlondsCookingContext();
            db.AddSet(FakeData.Categories);
            db.AddSet(FakeData.Recipes);
            HomeController controller = new HomeController(db);

            ViewResult result = controller.Category(100) as ViewResult;

            Assert.AreEqual("Error", result.ViewName);
        }
コード例 #4
0
        public void ReturnsErrorPageWhenCannotFindSelectedRecipe()
        {
            var db = new FakeBlondsCookingContext();
            db.AddSet(FakeData.Categories);
            db.AddSet(FakeData.Recipes);
            CategoryController controller = new CategoryController();

            ViewResult result = controller.Recipe(-1) as ViewResult;

            Assert.AreEqual("Error", result.ViewName);
        }