コード例 #1
0
        public void TestIndex()
        {
            var db         = new HoangEntities();
            var controller = new ProductControllerTest();

            var result = controller.Index() as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model,
                                    typeof(List <Product>));
            Assert.AreEqual(db.Products.Count(),
                            (result.Model as List <Product>).Count);
        }
コード例 #2
0
        public void TestIndex()
        {
            var db         = new HoangEntities();
            var controller = new Default1Controller();

            var result = controller.Index() as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model,
                                    typeof(List <Expenditure>));
            Assert.AreEqual(db.Expenditures.Count(),
                            (result.Model as List <Expenditure>).Count);
        }
コード例 #3
0
        public void TestEdit()
        {
            var controller = new ProductControllerTest();
            var result0    = controller.Edit(0);

            Assert.IsInstanceOfType(result0, typeof(HttpNotFoundResult));

            var db      = new HoangEntities();
            var item    = db.Products.First();
            var result1 = controller.Edit(item.id) as ViewResult;

            Assert.IsNotNull(result1);
            var model = result1.Model as Product;

            Assert.IsNotNull(model);
            Assert.AreEqual(item.id, model.id);
        }