Exemple #1
0
        /*protected override void OnActionExecuting(ActionExecutingContext filterContext)
         * {
         *  // Do whatever here...
         *  pc = new PricesController(Server);
         *  var cusid = filterContext.RequestContext.HttpContext.Request["_id"];
         *  if (cusid == null)
         *  {
         *      filterContext.Result = RedirectToAction("Index", "Cus", new { area = "crm" });
         *      return;
         *  }
         * }*/
        public ActionResult Index()
        {
            //Server.GetType();
            PricesController pc = new PricesController(Server);

            return((ActionResult)pc.Index(Request)["view"]);
        }
Exemple #2
0
        public void TestGetIndex()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));

            var PriceList = new List <Price>
            {
                new Price {
                    PriceID = 1, RouteID = 1, PassengerType = "Adult", TicketPrice = 50
                },
                new Price {
                    PriceID = 2, RouteID = 1, PassengerType = "Student", TicketPrice = 30
                },
                new Price {
                    PriceID = 3, RouteID = 1, PassengerType = "Child", TicketPrice = 15
                },
                new Price {
                    PriceID = 4, RouteID = 2, PassengerType = "Adult", TicketPrice = 300
                },
                new Price {
                    PriceID = 5, RouteID = 2, PassengerType = "Student", TicketPrice = 150
                },
                new Price {
                    PriceID = 6, RouteID = 2, PassengerType = "Child", TicketPrice = 75
                }
            };

            // ACt
            var result     = (ViewResult)controller.Index();
            var resultList = (List <Price>)result.Model;

            // Assert
            Assert.AreEqual("", result.ViewName);
            for (int i = 0; i < resultList.Count(); i++)
            {
                Assert.AreEqual(PriceList[i].PriceID, resultList[i].PriceID);
                Assert.AreEqual(PriceList[i].PassengerType, resultList[i].PassengerType);
                Assert.AreEqual(PriceList[i].RouteID, resultList[i].RouteID);
                Assert.AreEqual(PriceList[i].TicketPrice, resultList[i].TicketPrice);
            }
        }