示例#1
0
        public void CreateTest()
        {
            var controller = new CashBillController();
            var context    = new Mock <HttpContextBase>();

            context.Setup(c => c.Session["UserName"]).Returns("abc");
            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);

            var result = controller.Index() as ViewResult;
            var db     = new DIENMAYQUYETTIENEntities();

            Assert.IsNotNull(result);
        }
示例#2
0
        public void TestIndex()
        {
            var controller = new CashBillController();
            var context    = new Mock <HttpContextBase>();

            context.Setup(c => c.Session["UserName"]).Returns("abc");
            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);

            var result = controller.Index() as ViewResult;
            var db     = new DIENMAYQUYETTIENEntities();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(List <CashBill>));
            Assert.AreEqual(db.CashBills.Count(), ((List <CashBill>)result.Model).Count);
        }