Example #1
0
        public void Test_Display_Model_Type()
        {
            var Context = new FakeNorthwindContext();

            Context.Categories = new[]
            {
                new Category {
                    CategoryID = 1
                },
                new Category {
                    CategoryID = 2
                },
                new Category {
                    CategoryID = 3
                },
                new Category {
                    CategoryID = 4
                }
            }.AsQueryable();

            var controller = new CategoryController(Context);

            var result = controller.Display(1) as ViewResult;

            Assert.AreEqual(typeof(Category), result.Model.GetType());
        }
Example #2
0
        public void Test_GetIamge_ReturnType()
        {
            //1 arrange
            var Context = new FakeNorthwindContext();

            Context.Categories = new[]
            {
                new Category {
                    CategoryID = 1, Picture = new byte[0]
                },
                new Category {
                    CategoryID = 2, Picture = new byte[0]
                },
                new Category {
                    CategoryID = 3, Picture = new byte[0]
                },
                new Category {
                    CategoryID = 4, Picture = new byte[0]
                }
            }.AsQueryable();

            var controller = new CategoryController(Context);

            //2
            var result = controller.GetImage(1) as ActionResult;

            //3

            Assert.AreEqual(typeof(FileContentResult), result.GetType());
        }
        public void Test_Index_Return_View()
        {
            // Arrange
            var Context = new FakeNorthwindContext();
            CategoryController controller = new CategoryController(Context);

            // Act
            var result = controller.Index() as ViewResult;

            // Assert
            Assert.AreEqual("Index", result.ViewName);
        }
        public void Test_CategoryList_Model_Type()
        {
            var Context = new FakeNorthwindContext();

            Context.Categories = new[]
            {
                new Category(), new Category(), new Category(), new Category()
            }.AsQueryable();

            var controller = new CategoryController(Context);
            var result     = controller._CategoryList() as PartialViewResult;

            Assert.AreEqual(typeof(List <Category>), result.Model.GetType());
        }
Example #5
0
        public void Test_CategoryList_Int_Parameter()
        {
            var Context = new FakeNorthwindContext();

            Context.Categories = new[]
            {
                new Category(), new Category(), new Category(), new Category()
            }.AsQueryable();

            var controller = new CategoryController();

            var result = controller._CategoryList(3) as PartialViewResult;
            var model  = result.Model as IEnumerable <Category>;

            Assert.AreEqual(3, model.Count());
        }