public List <SalaryReference> getSalaryReference()
        {
            List <Day> daysMoFr = new List <Day> {
                Day.MO, Day.TU, Day.WE, Day.TH, Day.FR
            };
            List <Day> daysSaSu = new List <Day> {
                Day.SA, Day.SU
            };

            SalaryReference salaryReferenceA = new SalaryReference(daysMoFr, new TimeSpan(0, 1, 0), new TimeSpan(9, 0, 0), 25.0);
            SalaryReference salaryReferenceB = new SalaryReference(daysMoFr, new TimeSpan(9, 1, 0), new TimeSpan(18, 0, 0), 15.0);
            SalaryReference salaryReferenceC = new SalaryReference(daysMoFr, new TimeSpan(18, 1, 0), new TimeSpan(24, 0, 0), 20.0);
            SalaryReference salaryReferenceD = new SalaryReference(daysSaSu, new TimeSpan(0, 1, 0), new TimeSpan(9, 0, 0), 30);
            SalaryReference salaryReferenceE = new SalaryReference(daysSaSu, new TimeSpan(9, 1, 0), new TimeSpan(18, 0, 0), 20);
            SalaryReference salaryReferenceF = new SalaryReference(daysSaSu, new TimeSpan(18, 1, 0), new TimeSpan(24, 0, 0), 25.0);

            salarysReferences.AddRange(new[] {
                salaryReferenceA,
                salaryReferenceB,
                salaryReferenceC,
                salaryReferenceD,
                salaryReferenceE,
                salaryReferenceF
            });
            return(salarysReferences);
        }
示例#2
0
        public void TestSimply()
        {
            List <Day> daysMoFr = new List <Day> {
                Day.MO, Day.TU, Day.WE, Day.TH, Day.FR
            };
            List <Day> daysSaSu = new List <Day> {
                Day.SA, Day.SU
            };

            SalaryReference salaryReferenceA = new SalaryReference(daysMoFr, new TimeSpan(0, 1, 0), new TimeSpan(9, 0, 0), 25.0);
            SalaryReference salaryReferenceB = new SalaryReference(daysMoFr, new TimeSpan(9, 1, 0), new TimeSpan(18, 0, 0), 15.0);
            SalaryReference salaryReferenceC = new SalaryReference(daysMoFr, new TimeSpan(18, 1, 0), new TimeSpan(0, 0, 0), 20.0);
            SalaryReference salaryReferenceD = new SalaryReference(daysSaSu, new TimeSpan(0, 1, 0), new TimeSpan(9, 0, 0), 30);
            SalaryReference salaryReferenceE = new SalaryReference(daysSaSu, new TimeSpan(9, 1, 0), new TimeSpan(18, 0, 0), 20);
            SalaryReference salaryReferenceF = new SalaryReference(daysSaSu, new TimeSpan(18, 1, 0), new TimeSpan(0, 0, 0), 25.0);

            salarysReferences.Add(salaryReferenceA);
            salarysReferences.Add(salaryReferenceB);
            salarysReferences.Add(salaryReferenceC);
            salarysReferences.Add(salaryReferenceD);
            salarysReferences.Add(salaryReferenceE);
            salarysReferences.Add(salaryReferenceF);

            Assert.IsTrue(salaryReferenceA.Days.Contains(Day.MO));
            Assert.IsTrue(salaryReferenceB.Days.Contains(Day.TH));
            Assert.IsTrue(salaryReferenceF.Days.Contains(Day.SU));
            Assert.IsFalse(salaryReferenceC.Days.Contains(Day.SA));
            Assert.IsFalse(salaryReferenceE.Days.Contains(Day.TH));

            Assert.AreEqual(20.0, salaryReferenceC.CostHour);
            Assert.AreEqual(30.0, salaryReferenceD.CostHour);

            Assert.AreEqual(15, salarysReferences[1].CostHour);
            Assert.AreNotEqual(65, salarysReferences[4].CostHour);
            Equals("18:00:00", salarysReferences[5].StartHour.ToString());
            Equals("00:00:00", salarysReferences[5].EndHour.ToString());
        }