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); }
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); }