Ejemplo n.º 1
0
        public void Add_post()
        {
            var departure = new Departure
            {
                DepartureId = 4
            };

            var controller = new DepartureController(
                new DepartureBLL(new DepartureRepositoryStab()),
                new LineBLL(new LineRepositoryStab())
                );

            var sessionMock = new TestControllerBuilder();

            sessionMock.InitializeController(controller);
            controller.Session["AuthenticatedUser"] = new DbUser
            {
                Username = "******",
                Password = null,
                Salt     = null
            };
            var actionResult = (RedirectToRouteResult)controller.Add(departure, 4);

            Assert.IsNotNull(actionResult, "Not a redirect result");
            Assert.IsFalse(actionResult.Permanent);
            Assert.AreEqual("Index", actionResult.RouteValues["Action"]);
            Assert.AreEqual(2, actionResult.RouteValues.Count());
        }
Ejemplo n.º 2
0
        public void Add()
        {
            var controller = new DepartureController(
                new DepartureBLL(new DepartureRepositoryStab()),
                new LineBLL(new LineRepositoryStab())
                );

            var sessionMock = new TestControllerBuilder();

            sessionMock.InitializeController(controller);
            controller.Session["AuthenticatedUser"] = new DbUser
            {
                Username = "******",
                Password = null,
                Salt     = null
            };
            var actionResult = (ViewResult)controller.Add(4);
            var data         = (Departure)actionResult.Model;

            Assert.AreEqual("", actionResult.ViewName);
            Assert.IsNotNull(data);
            Assert.IsNotNull(data.Line);
        }