Ejemplo n.º 1
0
        public void Customer_Show_Customer_NotAdmin()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var Controller = new CustomerController(new CustomerBLL(new CustomerRepoStub()));
            SessionMock.InitializeController(Controller);

            Controller.Session["Admin"] = false;
            var customerId = 1;
            var returnUrl = "returnUrl";

            var expRouteName = "";
            var expAction = "Index";
            var expController = "Home";

            // Act
            var result = (RedirectToRouteResult)Controller.ShowCustomer(customerId, returnUrl);

            // Assert
            Assert.AreEqual(expRouteName, result.RouteName);
            Assert.AreEqual(expAction, result.RouteValues["action"]);
            Assert.AreEqual(expController, result.RouteValues["controller"]);
        }
Ejemplo n.º 2
0
        public void Customer_Show_CustomerOk()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var Controller = new CustomerController(new CustomerBLL(new CustomerRepoStub()));
            SessionMock.InitializeController(Controller);

            Controller.Session["Admin"] = true;
            var customerId = 1;
            var returnUrl = "returnUrl";

            var expViewName = "Administration_Customer";
            var expViewBagCustomer = new CustomerView()
            {
                CustomerId = customerModel.CustomerId,
                Email = customerModel.Email,
                Firstname = customerModel.Firstname,
                Lastname = customerModel.Lastname,
                Address = customerModel.Address,
                Zipcode = customerModel.Zipcode,
                City = customerModel.City
            };
            var expViewBagReturnUrl = returnUrl;

            // Act
            var result = (ViewResult)Controller.ShowCustomer(customerId,returnUrl);

            var viewBagCustomer = result.ViewBag.Customer;
            var viewBagReturnUrl = result.ViewBag.ReturnUrl;

            // Assert
            Assert.AreEqual(expViewName, result.ViewName);

            Assert.AreEqual(expViewBagCustomer.CustomerId, viewBagCustomer.CustomerId);
            Assert.AreEqual(expViewBagCustomer.Firstname, viewBagCustomer.Firstname);
            Assert.AreEqual(expViewBagCustomer.Lastname, viewBagCustomer.Lastname);
            Assert.AreEqual(expViewBagCustomer.Address, viewBagCustomer.Address);
            Assert.AreEqual(expViewBagCustomer.Zipcode, viewBagCustomer.Zipcode);
            Assert.AreEqual(expViewBagCustomer.City, viewBagCustomer.City);

            Assert.AreEqual(expViewBagReturnUrl, viewBagReturnUrl);
        }