Ejemplo n.º 1
0
        public void HolidaysAggregatorAggreagatesHolidaysFromPassedHolidayFactories()
        {
            var firstDate  = new DateTime(2018, 1, 1);
            var secondDate = new DateTime(2018, 1, 5);
            var expected   = new List <DateTime>()
            {
                new DateTime(2018, 1, 2),
                new DateTime(2018, 1, 3),
            };

            var holidayMock1 = new Mock <IHolidaysFactory>();
            var holidayMock2 = new Mock <IHolidaysFactory>();

            holidayMock1.Setup(h => h.CreateHolidays(It.Is <DateTime>(d => d.Equals(firstDate)), It.Is <DateTime>(d => d.Equals(secondDate)))).Returns(new List <DateTime>()
            {
                new DateTime(2018, 1, 2)
            });
            holidayMock2.Setup(h => h.CreateHolidays(It.Is <DateTime>(d => d.Equals(firstDate)), It.Is <DateTime>(d => d.Equals(secondDate)))).Returns(new List <DateTime>()
            {
                new DateTime(2018, 1, 3)
            });

            IHolidaysFactory sut = new HolidaysAggregator(new List <IHolidaysFactory>()
            {
                holidayMock1.Object, holidayMock2.Object
            });

            Assert.That(sut.CreateHolidays(firstDate, secondDate), Is.EquivalentTo(expected));
            holidayMock1.VerifyAll();
            holidayMock2.VerifyAll();
        }
        public void BusinessDayCounterIntegrationWithAnnualHolidaysTests()
        {
            var newYear   = new FirstWeekdayHolidayShiftingDecorator(new FixedDateHolidaysFactory(1, 1));
            var christmas = new FixedDateHolidaysFactory(12, 25);
            var boxing    = new FixedDateHolidaysFactory(12, 26);
            var queenDay  = new DayOfMonthHolidaysFactory(6, DayOfWeek.Monday, 2);

            var aggregator = new HolidaysAggregator(new List <IHolidaysFactory>()
            {
                newYear,
                christmas,
                boxing,
                queenDay
            });

            var counter = new BusinessDayCounter();

            Assert.That(counter.BusinessDaysBetweenTwoDates(new DateTime(2016, 12, 20), new DateTime(2018, 2, 1), aggregator), Is.EqualTo(291 - 6));
        }