Пример #1
0
        public void OneWeekCaseIsApproved()
        {
            EmployeeCase theCase = LogicAndDataAccess.CreateCase(1, new DateTime(2017, 1, 2), new DateTime(2017, 1, 6));

            Assert.IsTrue(theCase.Approved);
            Assert.IsFalse(theCase.Denied);
        }
Пример #2
0
        public void CaseNumberIsNotDuplicate()
        {
            EmployeeCase firstCase  = LogicAndDataAccess.CreateCase(1, DateTime.UtcNow, DateTime.UtcNow.AddDays(7));
            EmployeeCase secondCase = LogicAndDataAccess.CreateCase(1, DateTime.UtcNow, DateTime.UtcNow.AddDays(7));

            Assert.AreNotEqual(firstCase.CaseNumber, secondCase.CaseNumber);
        }
Пример #3
0
        public void ThirteenWeekCaseIsApprovedAndDenied()
        {
            EmployeeCase theCase = LogicAndDataAccess.CreateCase(1, new DateTime(2017, 1, 2), new DateTime(2017, 3, 31));

            Assert.IsTrue(theCase.Approved);
            Assert.IsTrue(theCase.Denied);
        }
Пример #4
0
        public void EightEmployeesExistInTheDatabase()
        {
            List <Employee> employees = LogicAndDataAccess.GetAllEmployees();

            Assert.IsNotNull(employees);
            Assert.AreEqual(8, employees.Count);
        }
Пример #5
0
        public JsonResult CreateCase(CaseViewModel newCase)
        {
            EmployeeCase theCase = LogicAndDataAccess.CreateCase(newCase.EmployeeId, newCase.StartDate.Value, newCase.EndDate.Value);

            newCase.Approved = theCase.Approved;
            newCase.Denied   = theCase.Denied;
            return(Json(newCase));
        }
Пример #6
0
        /// <summary>
        /// Home Page to view all employees and approved cases
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var homeViewModel = new HomeViewModel()
            {
                Employees = LogicAndDataAccess.GetAllEmployees().Select(e => new EmployeeViewModel(e)).ToList(),
                Cases     = LogicAndDataAccess.ViewApprovedCases().Select(c => new CaseViewModel(c)).ToList()
            };

            return(View(homeViewModel));
        }
Пример #7
0
        public void SecondCaseIsApprovedAndDenied()
        {
            // 11 week case
            EmployeeCase firstCase = LogicAndDataAccess.CreateCase(1, new DateTime(2017, 1, 2), new DateTime(2017, 3, 17));

            Assert.IsTrue(firstCase.Approved);
            Assert.IsFalse(firstCase.Denied);

            // two week case
            EmployeeCase secondCase = LogicAndDataAccess.CreateCase(1, new DateTime(2017, 3, 20), new DateTime(2017, 3, 31));

            Assert.IsTrue(secondCase.Approved);
            Assert.IsTrue(secondCase.Denied);
        }
Пример #8
0
        // GET: Employee
        /// <summary>
        /// View an employee
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Index(int?id)
        {
            //Employee employeeData = null;
            //if(id.HasValue)
            //    employeeData = LogicAndDataAccess.ViewEmployeeById(id.Value);

            //// Translate employee data to view model
            //EmployeeViewModel viewModel = new EmployeeViewModel(employeeData);

            if (id.HasValue)
            {
                CaseListViewModel caseList = new CaseListViewModel();
                caseList.Employee = LogicAndDataAccess.ViewEmployeeById(id.Value);
                caseList.caseList = LogicAndDataAccess.ViewCasesForEmployee(id.Value);
                return(View(caseList));
            }
            return(Content("An error occured. Please try again"));
        }
Пример #9
0
 public void CreateCaseThrowsExceptionIfStartDateIsBeforeEndDate()
 {
     LogicAndDataAccess.CreateCase(1, new DateTime(2017, 3, 20), new DateTime(2017, 3, 19));
 }
Пример #10
0
 public void CreateCaseThrowsExceptionsIfEmployeeIdIsNegative()
 {
     LogicAndDataAccess.CreateCase(-1, new DateTime(2017, 3, 20), new DateTime(2017, 3, 21));
 }