Exemplo n.º 1
0
 public void GetAllSheetsTest()
 {
     var repo = new TimeTrackerRepository();
     List<Timesheet> timesheets = new List<Timesheet>();
     timesheets = repo.GetAllTimeSheets(6);
     Assert.AreEqual(4, timesheets.Count);
 }
Exemplo n.º 2
0
 public void DeleteTimesheetTest()
 {
     var repo = new  TimeTrackerRepository();
     repo.DeleteTimesheet(1);
     List<Timesheet> listOfSheets = repo.GetAllTimeSheets(1);
     Assert.IsFalse(listOfSheets.Exists(p => p.TimesheetId == 1));
 }
        public Response<List<Employee>> GetAllEmployees()
        {
            TimeTrackerRepository repo = new TimeTrackerRepository();
            var response = new Response<List<Employee>>();
            List<Employee> listOfEmployees = repo.GetAllEmployees();

            try
            {
                if (listOfEmployees.Count > 0)
                {
                    response.Success = true;
                    response.Data = listOfEmployees;

                }
                else
                {
                    response.Success = false;
                    response.Message = "There were no employees found";
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return response;
        }
Exemplo n.º 4
0
 public void DeleteEmpTimesheetTest()
 {
     TimeTrackerOperations ops = new TimeTrackerOperations();
     ops.DeleteSingleTimesheet(14);
     var repo = new TimeTrackerRepository();
     List<Timesheet> listOfSheets = repo.GetAllTimeSheets(5);
     Assert.IsFalse(listOfSheets.Exists(p => p.TimesheetId == 15));
 }
Exemplo n.º 5
0
 public void GetAllSheetsTest()
 {
     var repo = new TimeTrackerRepository();
     List<Timesheet> timesheets = new List<Timesheet>();
     timesheets = repo.GetAllTimeSheets(6);
     var timesheet = timesheets.FirstOrDefault(x=>x.TimesheetId==22);
     Assert.AreEqual(timesheet.EntryType, "Timesheet");
     Assert.AreEqual(4, timesheets.Count);
 }
Exemplo n.º 6
0
 public void SubmitNewTimeSheet()
 {
     var repo = new TimeTrackerRepository();
     var timesheet = new Timesheet()
     {
         DateOfTimesheet = new DateTime(1989, 02, 01),
         EmpId = 1,
         TotalHoursByDay = 2
     };
     repo.SubmitNewTimeSheet(timesheet);
     List<Timesheet> listOfSheets = repo.GetAllTimeSheets(1);
     Assert.AreEqual(8, listOfSheets.Count);
 }
Exemplo n.º 7
0
        public void SubmitTimeSheetTest()
        {
            TimeTrackerOperations ops = new TimeTrackerOperations();
            var timesheet = new Timesheet()
            {
                DateOfTimesheet = new DateTime(1989, 07, 01),
                EmpId = 1,
                TotalHoursByDay = 12
            };
            ops.SubmitTimeSheet(timesheet);

            var repo = new TimeTrackerRepository();
            List<Timesheet> listOfSheets = repo.GetAllTimeSheets(1);
            Assert.AreEqual(6, listOfSheets.Count);
        }
        public Response<TimeTrackerSummary> GetTimeTrackerSummary(int empId)
        {
            TimeTrackerRepository repo = new TimeTrackerRepository();
            var response = new Response<TimeTrackerSummary>();
            List<Timesheet> listOfTimesheets = repo.GetAllTimeSheets(empId);

            try
            {
                if (listOfTimesheets.Count > 0)
                {
                    response.Success = true;
                    response.Data = new TimeTrackerSummary()
                    {
                       SelectedEmployee = repo.GetSingleEmployee(empId),
                       TotalHoursWorked = repo.TotalHoursWorked(empId),
                        AllTimesheets = listOfTimesheets
                    };
                }

                else
                {
                    response.Data = new TimeTrackerSummary()
                    {
                        SelectedEmployee = repo.GetSingleEmployee(empId),
                    };

                    response.Success = false;
                    response.Message = "There were no timesheets found for that employee";
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return response;
        }
Exemplo n.º 9
0
 public void TotalHoursWorkedTest()
 {
     var repo = new TimeTrackerRepository();
     int totalHoursWorked = repo.TotalHoursWorked(6);
     Assert.AreEqual(22, totalHoursWorked);
 }
Exemplo n.º 10
0
 public void GetSingleEmployeeTest()
 {
     var repo = new TimeTrackerRepository();
     Employee singleEmployee = repo.GetSingleEmployee(6);
     Assert.AreEqual("Lisa", singleEmployee.FirstName);
 }
Exemplo n.º 11
0
 public void GetAllEmployeesTest()
 {
     var repo = new TimeTrackerRepository();
     List<Employee> allEmployees = repo.GetAllEmployees();
     Assert.AreEqual(14, allEmployees.Count);
 }
Exemplo n.º 12
0
 public void SubmitTimeSheet(Timesheet timesheet)
 {
     TimeTrackerRepository repo = new TimeTrackerRepository();
     repo.SubmitNewTimeSheet(timesheet);
 }
Exemplo n.º 13
0
 public void DeleteSingleTimesheet(int timesheetId)
 {
     TimeTrackerRepository repo = new TimeTrackerRepository();
     repo.DeleteTimesheet(timesheetId);
 }