public void The_Delete_Employee_Action_Returns_RedirectToRouteResult_When_The_Employee_Model_Is_Valid()
        {
            // Arrange
            const string expectedRouteName = "EmployeeDeleted";
            var employee = new Employee()
            {
                EmployeeID = 1,

            };

            var employeesController = new EmployeesController(_mockER.Object, _mockUW.Object);
            var routeData = new RouteData();
            employeesController.ControllerContext =
                new ControllerContext(_mockHttpContext.Object, routeData, employeesController);

            employeesController.ModelState.Clear();
            // Act
            var result = employeesController.DeleteConfirmed(1) as RedirectToRouteResult;

            // Assert
            Assert.AreEqual(2, _data.Count());
            Assert.IsNotNull(result, "Should have returned a RedirectToRouteResult");
            // Assert.AreEqual(expectedRouteName, result.RouteName, "Route name should have been {0}", expectedRouteName);
        }
        public void The_Add_Employee_Action_Returns_ViewResult_When_The_Employee_Model_Is_Invalid()
        {
            // Arrange
            const string expectedRouteName = "EmployeeCreated";
            var employee = new Employee()
            {
                EmployeeID = 1,
                Name = "Aimen",
                Address = "Address",
                Age = 1,
                Employment = 1,
                Active = 1
            };

            var employeesController = new EmployeesController(_mockER.Object, _mockUW.Object);
            employeesController.ModelState.AddModelError("A Error", "Message");
            // Act
            var result = employeesController.Create(employee) as RedirectToRouteResult;

            // Assert
            Assert.AreEqual(3, _data.Count());
            Assert.IsNull(result, "Should have returned a RedirectToRouteResult");
        }
        public void Default_Action_Returns_Index_View_Using_MvcContrib_TestHelper()
        {
            // Arrange
            var employeesController = new EmployeesController(_mockER.Object, null);
            var routeData = new RouteData();

            // Act
            var result = employeesController.Index();

            // Assert
            result.AssertViewRendered().ForView("Index");
            result.AssertViewRendered().WithViewData<IEnumerable<Employee>>();
        }
        public void The_Add_Employee_Action_Returns_RedirectToRouteResult_When_The_Employee_Model_Is_Valid()
        {
            // Arrange
            const string expectedRouteName = "EmployeeCreated";
            var employee = new Employee()
            {
                EmployeeID = 1,
                Name = "Aimen",
                Address = "Address",
                Age = 1,
                Employment = 1,
                Active = 1
            };

            var employeesController = new EmployeesController(_mockER.Object, _mockUW.Object);
            var routeData = new RouteData();
            _FormKeys.Add("Create", "Create");
            employeesController.ControllerContext =
                new ControllerContext(_mockHttpContext.Object, routeData, employeesController);
            employeesController.ModelState.Clear();
            // Act
            var result = employeesController.Create(employee) as RedirectToRouteResult;

            // Assert
            Assert.AreEqual(4, _data.Count());
            Assert.IsNotNull(result, "Should have returned a RedirectToRouteResult");
            // Assert.AreEqual(expectedRouteName, result.RouteName, "Route name should have been {0}", expectedRouteName);
        }
        public void Default_Action_Returns_Index_View()
        {
            // Arrange
            var employeesController = new EmployeesController(_mockER.Object, null);

            const string expectedViewName = "Index";
            //Act
            var result = employeesController.Index() as ViewResult;

            //Assert
            Assert.IsNotNull(result, "Should have returned a ViewResult");
            result.AssertViewRendered().WithViewData<IEnumerable<Employee>>();
            Assert.AreEqual(expectedViewName, result.ViewName, "View name should have been {0}", expectedViewName);
        }