public void IndexGETTest2() { CartController target = new CartController(new TestOrderRepository(), new TestProductRepository()); ControllerContext context = new ControllerContext(new MockHttpContext(), new RouteData(), target); context.HttpContext.Session["TxID"] = "1"; target.ControllerContext = context; ViewResult actual; actual = target.Index() as ViewResult; Assert.IsNotNull(actual.ViewData.Model); Assert.IsNotNull(actual.ViewData["TotalMoney"]); }
public void IndexPOST02Test() { CartController target = new CartController(new TestOrderRepository(), new TestProductRepository()); ControllerContext context = new ControllerContext(new MockHttpContext(), new RouteData(), target); context.HttpContext.Session["TxID"] = "aaaaaaaaa"; target.ControllerContext = context; FormCollection collection = null; string expectedAction = "Sorry"; string expectedController = "Result"; RedirectToRouteResult actual; actual = target.Index(collection) as RedirectToRouteResult; Assert.AreEqual(expectedAction, actual.RouteValues["action"]); Assert.AreEqual(expectedController, actual.RouteValues["controller"]); }
public void IndexGETTest1() { CartController target = new CartController(new TestOrderRepository(), new TestProductRepository()); ControllerContext context = new ControllerContext(new MockHttpContext(), new RouteData(), target); context.HttpContext.Session["TxID"] = "dummy"; target.ControllerContext = context; string expectedAction = "Empty"; string expectedController = null; RedirectToRouteResult actual; actual = target.Index() as RedirectToRouteResult; Assert.AreEqual(expectedAction, actual.RouteValues["action"]); Assert.AreEqual(expectedController, actual.RouteValues["controller"]); }