示例#1
0
        public void CreateNewShift()
        {
            WorkScheduleShift newShift = new WorkScheduleShift(testEmployee, thisMoment, thisMoment.AddHours(2));
            TimeSpan          timeSpan = new TimeSpan(2, 0, 0);

            Assert.AreEqual("Niels Hansen", newShift.Employee.FullName);
            Assert.AreEqual(timeSpan, newShift.EndTime.Subtract(newShift.StartTime));
            Assert.AreEqual("08:00:00 - 10:00:00", newShift.ToString());
            Assert.AreEqual(120, newShift.TotalNumberOfMinutes);
        }
示例#2
0
        public void CreateNewSchedule()
        {
            WorkScheduleShift newShift     = new WorkScheduleShift(testEmployee, thisMoment, thisMoment.AddHours(2));
            WorkSchedule      testSchedule = new WorkSchedule(2018, 2);

            Assert.AreEqual(2018, testSchedule.Year);
            Assert.AreEqual(2, testSchedule.Month);
            Assert.AreEqual(0, testSchedule.GetAllShifts().Count);
            testSchedule.AddShiftToSchedule(newShift);
            Assert.AreEqual(1, testSchedule.GetAllShifts().Count);
        }
示例#3
0
        public void MonthWeekNumbers()
        {
            WorkSchedule workSchedule = new WorkSchedule(2018, 3);
            DateTime     firstday     = new DateTime(workSchedule.Year, workSchedule.Month, 1);
            DateTime     lastday      = firstday.AddMonths(1).AddDays(-1);
            Calendar     cal          = DateTimeFormatInfo.CurrentInfo.Calendar;

            Assert.AreEqual("2018 03 01", firstday.ToString("yyyy MM dd"));
            Assert.AreEqual("2018 03 31", lastday.ToString("yyyy MM dd"));
            WorkScheduleShift newShift = new WorkScheduleShift(testEmployee, otherMoment, otherMoment.AddHours(2));

            Assert.AreEqual(9, newShift.WeekNumber);
            Assert.AreEqual(10, cal.GetWeekOfYear(firstday.AddDays(7), DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek));
            Assert.AreEqual(11, cal.GetWeekOfYear(firstday.AddDays(14), DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek));
            Assert.AreEqual(12, cal.GetWeekOfYear(firstday.AddDays(21), DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek));
        }
 public void AddShift(WorkScheduleShift shift)
 {
     weekShifts.Add(shift);
 }