public void TestGetEdit()
        {
            // Arrange
            var controller = new StationsController(new StationLogic(new StationRepositoryStub()));

            // ACt
            var result = (ViewResult)controller.Edit(1);

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
        public void TestPostEditDBError()
        {
            // Arrange
            var controller = new StationsController(new StationLogic(new StationRepositoryStub()));
            var OneStation = new Station {
                StationID = 1, StationName = null
            };

            // ACt
            var result = (ViewResult)controller.Edit(OneStation);

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
        public void TestPostEditValidationError()
        {
            // Arrange
            var controller = new StationsController(new StationLogic(new StationRepositoryStub()));

            controller.ViewData.ModelState.AddModelError("StationName", "Station name should string!");
            var OneStation = new Station();

            // ACt
            var result = (ViewResult)controller.Edit(OneStation);

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
        public void TestPostEdit()
        {
            // Arrange
            var controller = new StationsController(new StationLogic(new StationRepositoryStub()));
            var OneStation = new Station {
                StationID = 1, StationName = "Bergen"
            };

            // ACt
            var result = (RedirectToRouteResult)controller.Edit(OneStation);

            // Assert
            Assert.AreEqual("", result.RouteName);
            Assert.AreEqual("Index", result.RouteValues.Values.First());
        }
示例#5
0
        public void Edit()
        {
            var controller  = new StationsController(new StationBLL(new StationRepositoryStab()));
            var sessionMock = new TestControllerBuilder();

            sessionMock.InitializeController(controller);
            controller.Session["AuthenticatedUser"] = new DbUser
            {
                Username = "******",
                Password = null,
                Salt     = null
            };
            var result = (ViewResult)controller.Edit(5);

            Assert.AreEqual("", result.ViewName);
            var station = (Station)result.Model;

            Assert.AreEqual(0, station.StationId);
        }
示例#6
0
        public void Edit_Post()
        {
            var station = new Station {
                StationId = 1, Name = "Oslo S", LineStations = null
            };

            var controller  = new StationsController(new StationBLL(new StationRepositoryStab()));
            var sessionMock = new TestControllerBuilder();

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

            Assert.IsNotNull(actionResult, "Not a redirect result");
            Assert.IsFalse(actionResult.Permanent);
            Assert.AreEqual("Index", actionResult.RouteValues["Action"]);
        }