Beispiel #1
0
        public void Save(CakeSchedule cakeSchedule)
        {
            if (cakeSchedule == null)
                cakeSchedule = new CakeSchedule();

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

            cakeSchedule.NextDate = GetSecondFridayFromToday(currentDate);

            cakeSchedule = AdjustNextCakeDateForHollidays(cakeSchedule);

            return cakeSchedule;
        }
        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));
        }
            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;
            }
Beispiel #6
0
        public CakeSchedule Get()
        {
            CakeSchedule cakeSchedule;

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

            return cakeSchedule;
        }
        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;
        }
 public CakeSchedule SetNextCakeDate(CakeSchedule cakeSchedule, DateTime currentDate)
 {
     return new CakeSchedule
                {
                    NextDate = _nextCakeDate
                };
 }
 public void Save(CakeSchedule cakeSchedule)
 {
 }
 public CakeScheduleController(ICakeScheduleDao cakeScheduleDao)
 {
     _cakeScheduleDao = cakeScheduleDao;
     _cakeSchedule = _cakeScheduleDao.Get();
 }
 public CakeScheduleController()
 {
     _cakeScheduleDao = new CakeScheduleDao(SiteSettings.RepositoryPath);
     _cakeSchedule = _cakeScheduleDao.Get();
 }
 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;
            }