Пример #1
0
        public void HiredFourYearsAgo()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context       = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear           = 2011,
                    DetailedYearsQuantity = 5
                },
                Data = new VacationsReportData()
                {
                    HiringDate = DateTime.Parse("2007-3-15"),
                    Vacations  = new Vacation[0]
                }
            };

            var calculated = calculator.Execute();
            var expected   = 70;
            int actual     = calculated.TotalPending;

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void IgnoreVacationsBeforHiring()
        {
            var calculator = new CalculateVacations()
            {
                Context       = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear           = 2012,
                    DetailedYearsQuantity = 5
                },
                Data = new VacationsReportData()
                {
                    HiringDate = DateTime.Parse("2010-06-10T23:00:00"),
                    Vacations  = new[] { new Vacation()
                                         {
                                             Period = 2009,
                                             From   = DateTime.Parse("2012-01-01T20:00:00"),
                                             To     = DateTime.Parse("2012-01-1T20:00:00")
                                         } }
                }
            };
            var calculated = calculator.Execute();
            var expected   = 0;
            int actual     = calculated.TotalTaken;

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void MoreThanOneVacationInYear()
        {
            var calculator = new CalculateVacations()
            {
                Context       = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear           = 2012,
                    DetailedYearsQuantity = 5
                },
                Data = new VacationsReportData()
                {
                    HiringDate = DateTime.Parse("2012-04-07"),
                    Vacations  = new[] {
                        new Vacation()
                        {
                            Period = 2012,
                            From   = DateTime.Parse("2012-08-31T00:00:00"),
                            To     = DateTime.Parse("2012-09-01T00:00:00")
                        },
                        new Vacation()
                        {
                            Period = 2012,
                            From   = DateTime.Parse("2012-08-01T00:00:00"),
                            To     = DateTime.Parse("2012-08-02T00:00:00")
                        },
                        new Vacation()
                        {
                            Period = 2013,
                            From   = DateTime.Parse("2012-10-1T00:00:00"),
                            To     = DateTime.Parse("2012-10-03T00:00:00")
                        },
                        new Vacation()
                        {
                            Period = 2013,
                            From   = DateTime.Parse("2012-12-1T00:00:00"),
                            To     = DateTime.Parse("2012-12-03T00:00:00")
                        },
                        new Vacation()
                        {
                            Period = 2015,
                            From   = DateTime.Parse("2012-11-1T00:00:00"),
                            To     = DateTime.Parse("2012-11-03T00:00:00")
                        },
                    }
                }
            };
            var calculated = calculator.Execute();
            var expected   = 4;
            int actual     = calculated.ByYear[2012].Taken;

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void OlderVacationsPending()
        {
            var calculator = new CalculateVacations()
            {
                Context       = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear           = 2012,
                    DetailedYearsQuantity = 0
                },
                Data = new VacationsReportData()
                {
                    HiringDate = DateTime.Parse("2011-04-07"),
                    Vacations  = new[] {
                        new Vacation()
                        {
                            Period = 2011,
                            From   = DateTime.Parse("2012-08-31T00:00:00"),
                            To     = DateTime.Parse("2012-09-01T00:00:00")
                        },
                        new Vacation()
                        {
                            Period = 2012,
                            From   = DateTime.Parse("2012-08-01T00:00:00"),
                            To     = DateTime.Parse("2012-08-02T00:00:00")
                        },
                        new Vacation()
                        {
                            Period = 2013,
                            From   = DateTime.Parse("2012-10-1T00:00:00"),
                            To     = DateTime.Parse("2012-10-03T00:00:00")
                        },
                        new Vacation()
                        {
                            Period = 2013,
                            From   = DateTime.Parse("2012-12-1T00:00:00"),
                            To     = DateTime.Parse("2012-12-03T00:00:00")
                        },
                        new Vacation()
                        {
                            Period = 2015,
                            From   = DateTime.Parse("2012-11-1T00:00:00"),
                            To     = DateTime.Parse("2012-11-03T00:00:00")
                        },
                    }
                }
            };
            var calculated = calculator.Execute();
            var expected   = 15;
            int actual     = calculated.TotalPending;

            Assert.AreEqual(expected, actual);
        }
Пример #5
0
        public void HiringDateUnset()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context       = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear           = 2011,
                    DetailedYearsQuantity = 5
                },
                Data = VacationsReportData.FromEmployee(target)
            };

            var result = calculator.Execute();
        }
        public void HiredOnAugust()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context = new ScriptContext(),
                HiringDate = DateTime.Parse("2011-8-15"),
                Vacations = new List<Vacation>(),
                Now = DateTime.Parse("2011-12-30")
            };

            var calculated = calculator.Execute();
            var expected = 5;
            int actual = calculated.TotalPending;
            Assert.AreEqual(expected, actual);
        }
        public void HiredOnSeptember()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context    = new ScriptContext(),
                HiringDate = DateTime.Parse("2011-9-15"),
                Vacations  = new List <Vacation>(),
                Now        = DateTime.Parse("2011-12-30")
            };

            var calculated = calculator.Execute();
            var expected   = 4;
            int actual     = calculated.TotalPending;

            Assert.AreEqual(expected, actual);
        }
        public void HiredFiveYearsAgo()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context    = new ScriptContext(),
                HiringDate = DateTime.Parse("2006-3-15"),
                Vacations  = new List <Vacation>(),
                Now        = DateTime.Parse("2011-6-15")
            };

            var calculated = calculator.Execute();
            var expected   = 91;
            int actual     = calculated.TotalPending;

            Assert.AreEqual(expected, actual);
        }
        public void HiringDateUnset()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context   = new ScriptContext(),
                Vacations = new List <Vacation>(),
                Now       = DateTime.Parse("2011-6-15")
            };

            try
            {
                var calculated = calculator.Execute();
            }
            catch (ScriptCommandException e)
            {
                return;
            }
            Assert.Fail("There should be a ScriptCommandException");
        }
        public void HiredFiveYearsAgo()
        {
            var calculator = new CalculateVacations()
            {
                Context = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear = 2011,
                    DetailedYearsQuantity = 5
                },
                Data = new VacationsReportData()
                {
                    HiringDate = DateTime.Parse("2006-3-15"),
                    Vacations = new Vacation[0]
                }
            };

            var calculated = calculator.Execute();
            var expected = 91;
            int actual = calculated.TotalPending;
            Assert.AreEqual(expected, actual);
        }
Пример #11
0
        public void TotalDaysTest_DoNotCareAboutHour()
        {
            var target = new Employee();

            target.HiringDate = DateTime.Parse("2010-06-10T23:00:00");
            target.Vacations  = new List <Vacation>()
            {
                new Vacation()
                {
                    Period = 2010, From = DateTime.Parse("2012-01-01T23:00:00"), To = DateTime.Parse("2012-01-10T00:00:00")
                }
            };
            var calculator = new CalculateVacations()
            {
                Context  = new ScriptContext(),
                Employee = target
            };
            var calculated = calculator.Execute();
            var expected   = 10;
            int actual     = calculated.TotalTaken;

            Assert.AreEqual(expected, actual);
        }
Пример #12
0
        public void IgnoreVacationsBeforHiring()
        {
            var target = new Employee();

            target.HiringDate = DateTime.Parse("2010-06-10T23:00:00");
            target.Vacations  = new List <Vacation>()
            {
                new Vacation()
                {
                    Period = 2009, From = DateTime.Parse("2012-01-01T20:00:00"), To = DateTime.Parse("2012-01-1T20:00:00")
                }
            };
            var calculator = new CalculateVacations()
            {
                Context    = new ScriptContext(),
                HiringDate = target.HiringDate,
                Vacations  = target.Vacations
            };
            var calculated = calculator.Execute();
            var expected   = 0;
            int actual     = calculated.TotalTaken;

            Assert.AreEqual(expected, actual);
        }
Пример #13
0
        public void HiringDateUnset()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context = new ScriptContext(),
                Vacations = new List<Vacation>(),
                Now = DateTime.Parse("2011-6-15")
            };

            try
            {
                var calculated = calculator.Execute();
            }
            catch (ScriptCommandException e)
            {
                return;
            }
            Assert.Fail("There should be a ScriptCommandException");
        }
Пример #14
0
 public void TotalDaysTest_StartAndEndDateIncluded()
 {
     var target = new Employee();
     target.HiringDate = DateTime.Parse("2010-06-10T23:00:00");
     target.Vacations = new List<Vacation>() {
         new Vacation() { Period = 2010, From = DateTime.Parse("2012-01-01T00:00:00"), To = DateTime.Parse("2012-01-10T00:00:00") }
     };
     var calculator = new CalculateVacations() {
         Context = new ScriptContext(),
         Employee = target
     };
     var calculated = calculator.Execute();
     var expected = 10;
     int actual = calculated.TotalTaken;
     Assert.AreEqual(expected, actual);
 }
        public void HiringDateUnset()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear = 2011,
                    DetailedYearsQuantity = 5
                },
                Data = VacationsReportData.FromEmployee(target)
            };

            var result = calculator.Execute();
        }
 public void Pending()
 {
     var calculator = new CalculateVacations()
     {
         Context = CreateContext(),
         Configuration = new VacationsReportConfiguration()
         {
             CurrentYear = 2012,
             DetailedYearsQuantity = 5
         },
         Data = new VacationsReportData()
         {
             HiringDate = DateTime.Parse("2011-04-07"),
             Vacations = new[] {
                 new Vacation() {
                     Period = 2011,
                     From = DateTime.Parse("2012-08-31T00:00:00"),
                     To = DateTime.Parse("2012-09-01T00:00:00")
                 },
                 new Vacation() {
                     Period = 2012,
                     From = DateTime.Parse("2012-08-01T00:00:00"),
                     To = DateTime.Parse("2012-08-02T00:00:00")
                 },
                 new Vacation() {
                     Period = 2013,
                     From = DateTime.Parse("2012-10-1T00:00:00"),
                     To = DateTime.Parse("2012-10-03T00:00:00")
                 },
                 new Vacation() {
                     Period = 2013,
                     From = DateTime.Parse("2012-12-1T00:00:00"),
                     To = DateTime.Parse("2012-12-03T00:00:00")
                 },
                 new Vacation() {
                     Period = 2015,
                     From = DateTime.Parse("2012-11-1T00:00:00"),
                     To = DateTime.Parse("2012-11-03T00:00:00")
                 },
             }
         }
     };
     var calculated = calculator.Execute();
     var expected = 15;
     int actual = calculated.TotalPending;
     Assert.AreEqual(expected, actual);
 }
 public void TotalDaysTest_StartAndEndDateIncluded()
 {
     var calculator = new CalculateVacations()
     {
         Context = CreateContext(),
         Configuration = new VacationsReportConfiguration()
         {
             CurrentYear = 2012,
             DetailedYearsQuantity = 5
         },
         Data = new VacationsReportData()
         {
             HiringDate = DateTime.Parse("2010-06-10T23:00:00"),
             Vacations = new[] { new Vacation() {
                 Period = 2010,
                 From = DateTime.Parse("2012-01-01T00:00:00"),
                 To = DateTime.Parse("2012-01-10T00:00:00") } }
         }
     };
     var calculated = calculator.Execute();
     var expected = 10;
     int actual = calculated.TotalTaken;
     Assert.AreEqual(expected, actual);
 }
Пример #18
0
 public void IgnoreVacationsBeforHiring()
 {
     var target = new Employee();
     target.HiringDate = DateTime.Parse("2010-06-10T23:00:00");
     target.Vacations = new List<Vacation>() {
         new Vacation() { Period = 2009, From = DateTime.Parse("2012-01-01T20:00:00"), To = DateTime.Parse("2012-01-1T20:00:00") }
     };
     var calculator = new CalculateVacations()
     {
         Context = new ScriptContext(),
         HiringDate = target.HiringDate,
         Vacations = target.Vacations
     };
     var calculated = calculator.Execute();
     var expected = 0;
     int actual = calculated.TotalTaken;
     Assert.AreEqual(expected, actual);
 }