Example #1
0
        public void CanFilterEmployee()
        {
            var employeesController = new EmployeesController(_mock.Object);

            employeesController.PageSize = 3;
            var viewResult = employeesController.EmployeeData(filter: "Active");
            var employees  = (viewResult.Model as EmployeesListViewModel).Employees;

            Assert.AreEqual(employees.Count(), 3);
            Assert.IsTrue(employees.ToArray()[0].IsActive);
        }
Example #2
0
        public void EmployeeDataCanPaginate()
        {
            var employeesController = new EmployeesController(_mock.Object);

            employeesController.PageSize = 3;
            var viewResult       = employeesController.EmployeeData(page: 2);
            var employeesEntries = (viewResult.Model as EmployeesListViewModel).Employees.ToArray();

            Assert.IsTrue(employeesEntries.Length == 2, "Got wrong number of employees");
            Assert.AreEqual(employeesEntries[0].Name, "N2");
            Assert.AreEqual(employeesEntries[1].Name, "N3");
        }
Example #3
0
        public void EmployeeDataCanSendPaginationViewModel()
        {
            var employeesController = new EmployeesController(_mock.Object);

            employeesController.PageSize = 3;
            var viewResult = employeesController.EmployeeData(page: 2);
            var pagingInfo = (viewResult.Model as EmployeesListViewModel).PagingInfo;

            Assert.AreEqual(pagingInfo.CurrentPage, 2);
            Assert.AreEqual(pagingInfo.ItemsPerPage, 3);
            Assert.AreEqual(pagingInfo.TotalItems, 5);
            Assert.AreEqual(pagingInfo.TotalPages, 2);
        }
Example #4
0
        public void EmployeeDataReturnsAListOfEmployees()
        {
            var employeesController = new EmployeesController(_mock.Object);
            var viewResult          = employeesController.EmployeeData();

            Assert.IsNotNull(viewResult, "View Result is null");
            Assert.IsInstanceOf(typeof(EmployeesListViewModel), viewResult.Model, "Wrong view model");
            var employeeEntries = viewResult.ViewData.Model as EmployeesListViewModel;

            Assert.IsNotNull(employeeEntries, "Employees entries is null");
            Assert.AreEqual(5, employeeEntries.Employees.Count(), "Got wrong number of employees");
            var employee1 = employeeEntries.Employees.ToArray()[0];

            Assert.AreEqual(Name1, employee1.Name);
            Assert.AreEqual(Salary1, employee1.Salary);
            var employee2 = employeeEntries.Employees.ToArray()[1];

            Assert.AreEqual(Name2, employee2.Name);
            Assert.AreEqual(Salary2, employee2.Salary);
        }