Exemplo n.º 1
0
        public void Save(CakeSchedule cakeSchedule)
        {
            if (cakeSchedule == null)
                cakeSchedule = new CakeSchedule();

            _repositoryWriter.Write(CakeScheduleFileName, cakeSchedule);
        }
Exemplo n.º 2
0
        public CakeSchedule SetNextCakeDate(CakeSchedule cakeSchedule, DateTime currentDate)
        {
            if (cakeSchedule == null)
                cakeSchedule = CreateCakeSchedule();

            cakeSchedule.NextDate = GetSecondFridayFromToday(currentDate);

            cakeSchedule = AdjustNextCakeDateForHollidays(cakeSchedule);

            return cakeSchedule;
        }
Exemplo n.º 3
0
        private static CakeSchedule GetSampleCakeScheduleWithHolidays()
        {
            var cakeSchedule = new CakeSchedule
                                   {
                                       NextDate = new DateTime(2010, 3, 1)
                                   };

            cakeSchedule.AddHoliday(new DateTime(2010, 3, 20));
            cakeSchedule.AddHoliday(new DateTime(2010, 4, 10));

            return cakeSchedule;
        }
        public void SetNextCakeDate_ExpectedCakeDateIsHolliday_ShouldSetSecondThirdFromToday()
        {
            var cakeSchedule = new CakeSchedule();
            var currentDate = new DateTime(2010, 5, 10);
            var secondFridayFromToday = new DateTime(2010, 5, 21);
            var thirdFridayFromToday = new DateTime(2010, 5, 28);
            cakeSchedule.AddHoliday(secondFridayFromToday);
            cakeSchedule = _cakeScheduleServices.SetNextCakeDate(cakeSchedule, currentDate);

            Assert.That(cakeSchedule.NextDate, Is.EqualTo(thirdFridayFromToday));
            Assert.That(cakeSchedule.NextDate.DayOfWeek, Is.EqualTo(DayOfWeek.Friday));
        }
Exemplo n.º 5
0
            public CakeSchedule Get()
            {
                var cakeSchedule = new CakeSchedule
                                       {
                                           NextDate = new DateTime(2010, 3, 1)
                                       };

                cakeSchedule.AddHoliday(new DateTime(2010, 3, 20));
                cakeSchedule.AddHoliday(new DateTime(2010, 4, 10));

                return cakeSchedule;
            }
Exemplo n.º 6
0
        public CakeSchedule Get()
        {
            CakeSchedule cakeSchedule;

            try
            {
                cakeSchedule = (CakeSchedule) _repositoryReader.Read(CakeScheduleFileName);
            }
            catch
            {
                cakeSchedule = new CakeSchedule();
            }

            return cakeSchedule;
        }
Exemplo n.º 7
0
        private CakeSchedule AdjustNextCakeDateForHollidays(CakeSchedule cakeSchedule)
        {
            if (cakeSchedule.Holidays.Count == 0)
            {
                return cakeSchedule;
            }

            while ((from d in cakeSchedule.Holidays
                    where d.Date == cakeSchedule.NextDate.Date
                    select d).Any())
            {
                cakeSchedule.NextDate = cakeSchedule.NextDate.AddDays(7);
            }

            return cakeSchedule;
        }
Exemplo n.º 8
0
 public CakeSchedule SetNextCakeDate(CakeSchedule cakeSchedule, DateTime currentDate)
 {
     return new CakeSchedule
                {
                    NextDate = _nextCakeDate
                };
 }
Exemplo n.º 9
0
 public void Save(CakeSchedule cakeSchedule)
 {
 }
Exemplo n.º 10
0
 public CakeScheduleController(ICakeScheduleDao cakeScheduleDao)
 {
     _cakeScheduleDao = cakeScheduleDao;
     _cakeSchedule = _cakeScheduleDao.Get();
 }
Exemplo n.º 11
0
 public CakeScheduleController()
 {
     _cakeScheduleDao = new CakeScheduleDao(SiteSettings.RepositoryPath);
     _cakeSchedule = _cakeScheduleDao.Get();
 }
Exemplo n.º 12
0
 public void Setup()
 {
     _cakeSchedule = new CakeSchedule();
 }
 public void Save(CakeSchedule cakeSchedule)
 {
     // do nothing here
 }
            public CakeSchedule Get()
            {
                var cakeSchedule = new CakeSchedule();
                foreach (DateTime holiday in GetHolidays())
                {
                    cakeSchedule.AddHoliday(holiday);
                }

                return cakeSchedule;
            }