Beispiel #1
0
        public void TestThanSecondBunchDataSkipNullableExceptionRules()
        {
            var exceptionPerPayRules = new List <ExceptionRulePerPayRule>();
            var exceptionPerPayRule1 = new ExceptionRulePerPayRule();

            exceptionPerPayRule1.PayRule = new PayRule
            {
                PersonNumber = "PersonNumber1"
            };
            exceptionPerPayRule1.ExceptionRule = new ExceptionRule();
            exceptionPerPayRules.Add(exceptionPerPayRule1);

            var exceptionPerPayRule2 = new ExceptionRulePerPayRule();

            exceptionPerPayRule2.PayRule = new PayRule
            {
                PersonNumber = "PersonNumber2"
            };
            exceptionPerPayRules.Add(exceptionPerPayRule2);

            var calculator = new SecondBunchDataCalculator();
            var results    = calculator.Recalculate(exceptionPerPayRules);

            Assert.NotNull(results);
            Assert.AreEqual(0, results.Count);
        }
        public static List <ExceptionRulePerPayRule> GetData()
        {
            var exceptionPerPayRules = new List <ExceptionRulePerPayRule>();
            var exceptionPerPayRule1 = new ExceptionRulePerPayRule();

            exceptionPerPayRule1.PayRule = new PayRule
            {
                PersonNumber = "PersonNumber1",
                PayRuleName  = "PayRuleName1",
                FullName     = "FullName1"
            };
            exceptionPerPayRule1.ExceptionRule = new ExceptionRule
            {
                InLate      = new TimeSpan(5, 8, 0),
                OutLate     = new TimeSpan(4, 9, 0),
                InEarly     = new TimeSpan(22, 0, 0),
                OutEarly    = new TimeSpan(5, 13, 0),
                Unscheduled = true
            };
            exceptionPerPayRules.Add(exceptionPerPayRule1);

            var exceptionPerPayRule2 = new ExceptionRulePerPayRule();

            exceptionPerPayRule2.PayRule = new PayRule
            {
                PersonNumber = "PersonNumber2",
                PayRuleName  = "PayRuleName2",
                FullName     = "FullName2"
            };
            exceptionPerPayRule2.ExceptionRule = new ExceptionRule
            {
                InLate   = new TimeSpan(8, 0, 0),
                OutLate  = new TimeSpan(5, 1, 0),
                InEarly  = new TimeSpan(13, 1, 45),
                OutEarly = new TimeSpan(21, 0, 29)
            };
            exceptionPerPayRules.Add(exceptionPerPayRule2);

            var exceptionPerPayRule3 = new ExceptionRulePerPayRule();

            exceptionPerPayRule3.PayRule = new PayRule
            {
                PersonNumber = "PersonNumber3"
            };
            exceptionPerPayRule3.ExceptionRule = new ExceptionRule
            {
                InLate   = new TimeSpan(8, 0, 0),  //8:0
                OutLate  = new TimeSpan(5, 0, 0),  //22:00
                InEarly  = new TimeSpan(3, 20, 0), //4:41
                OutEarly = new TimeSpan(23, 1, 0)  //17:00
            };
            exceptionPerPayRules.Add(exceptionPerPayRule3);

            return(exceptionPerPayRules);
        }
Beispiel #3
0
        public void TestThanSecondBunchDataCalculateCorrectly()
        {
            var exceptionPerPayRules = new List <ExceptionRulePerPayRule>();
            var exceptionPerPayRule1 = new ExceptionRulePerPayRule();

            exceptionPerPayRule1.PayRule = new PayRule
            {
                PersonNumber = "PersonNumber1"
            };
            exceptionPerPayRule1.ExceptionRule = new ExceptionRule
            {
                Name     = "ExceptionRule1",
                InLate   = new TimeSpan(21, 0, 0), //8:00
                OutLate  = new TimeSpan(4, 9, 0),  //21:9
                InEarly  = new TimeSpan(22, 0, 0), //8:00
                OutEarly = new TimeSpan(5, 0, 0)   //17:00
            };
            exceptionPerPayRules.Add(exceptionPerPayRule1);

            var exceptionPerPayRule2 = new ExceptionRulePerPayRule();

            exceptionPerPayRule2.PayRule = new PayRule
            {
                PersonNumber = "PersonNumber2"
            };
            exceptionPerPayRule2.ExceptionRule = new ExceptionRule
            {
                Name     = "ExceptionRule2",
                InLate   = new TimeSpan(8, 5, 0),   //16:04
                OutLate  = new TimeSpan(5, 0, 0),   //17:00
                InEarly  = new TimeSpan(3, 1, 45),  //4:59
                OutEarly = new TimeSpan(10, 40, 49) // 6:20
            };
            exceptionPerPayRules.Add(exceptionPerPayRule2);

            var calculator = new SecondBunchDataCalculator();
            var results    = calculator.Recalculate(exceptionPerPayRules);

            Assert.NotNull(results);
            Assert.AreEqual(2, results.Count);
            Assert.AreEqual("PersonNumber1", results[0].PayRule.PersonNumber);
            Assert.AreEqual(new TimeSpan(8, 0, 0), results[0].ExceptionRule.InLate);
            Assert.AreEqual(new TimeSpan(21, 9, 0), results[0].ExceptionRule.OutLate);
            Assert.AreEqual(new TimeSpan(8, 0, 0), results[0].ExceptionRule.InEarly);
            Assert.AreEqual(new TimeSpan(17, 00, 0), results[0].ExceptionRule.OutEarly);

            Assert.AreEqual("PersonNumber2", results[1].PayRule.PersonNumber);
            Assert.AreEqual(new TimeSpan(16, 5, 0), results[1].ExceptionRule.InLate);
            Assert.AreEqual(new TimeSpan(17, 0, 0), results[1].ExceptionRule.OutLate);
            Assert.AreEqual(new TimeSpan(4, 59, 0), results[1].ExceptionRule.InEarly);
            Assert.AreEqual(new TimeSpan(6, 20, 0), results[1].ExceptionRule.OutEarly);
        }