Exemplo n.º 1
0
        public void TestGetAdd()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));

            // ACt
            var result = (ViewResult)controller.Add();

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 2
0
        public void TestPostAddValidationError()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));

            controller.ViewData.ModelState.AddModelError("PriceID", "Price ID should be provided!");
            var NewPrice = new Price();

            // ACt
            var result = (ViewResult)controller.Add(NewPrice);

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 3
0
        public void TestPostAddDBError()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));
            var NewPrice   = new Price {
                PriceID = 0, TicketPrice = 0.0f
            };

            // ACt
            var result = (ViewResult)controller.Add(NewPrice);

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 4
0
        public void TestPostAdd()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));
            var NewPrice   = new Price {
                PriceID = 7, RouteID = 3, PassengerType = "Adult", TicketPrice = 200
            };

            // ACt
            var result = (RedirectToRouteResult)controller.Add(NewPrice);

            // Assert
            Assert.AreEqual("", result.RouteName);
            Assert.AreEqual("Index", result.RouteValues.Values.First());
        }