Пример #1
0
        public void Adding_ScheduleItem_On_Blacked_Out_Date_Should_Fail()
        {
            DateTime           blackedOutDate = DateTime.Now.AddDays(3);
            string             key            = KeyHelper.GetKey <IScheduleRepository>();
            var                repository     = RepositoryFactory.GetRepository <IScheduleRepository>(key);
            ScheduleController controller     = new ScheduleController();

            controller.CreateSchedule(TestFactories.GetDefaultLookup(), "Test Schedule", "This is a test", "test user");

            Schedule schedule = repository.GetAllSchedules().Last();

            controller.CreateBlackoutDate(schedule, "Test blackout date", blackedOutDate, "test user");

            try
            {
                controller.CreateScheduleItem(schedule, blackedOutDate, TestFactories.GetDefaultPerson(), new List <Baptizer>(),
                                              TestFactories.GetDefaultPerson(), true, "test user");
                Assert.Fail("controller.CreateScheduleItem() should throw an exception.");
            }
            catch (ValidationException ex)
            {
                Assert.IsTrue(ex.Errors[0].Contains("Unable to schedule a baptism on a Black Out Date."));
                Assert.AreEqual(ex.Errors.Count, 1);
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                ClearStatus();
                DateTime date = dtbDate.Text.Trim() != Constants.NULL_STRING ?
                                DateTime.Parse(dtbDate.Text) : Constants.NULL_DATE;
                int blackoutDateID;

                if (blackoutDate == null)
                {
                    scheduleController.CreateBlackoutDate(schedule, tbDescription.Text.Trim(),
                                                          date, CurrentUser.Identity.Name);
                    blackoutDateID = schedule.BlackoutDates.First(b => b.Date.Date == date.Date).BlackoutDateID;
                    blackoutDate   = schedule.BlackoutDates.SingleOrDefault(b => b.BlackoutDateID == blackoutDateID);
                }
                else
                {
                    scheduleController.UpdateBlackoutDate(schedule, blackoutDate.BlackoutDateID,
                                                          tbDescription.Text.Trim(), date, CurrentUser.Identity.Name);
                    blackoutDateID = blackoutDate.BlackoutDateID;
                }

                ihBlackoutDateID.Value = blackoutDateID.ToString();
                ShowSuccess();
            }
            catch (ValidationException ex)
            {
                ShowErrors(ex.Errors);
            }
        }
Пример #3
0
        public void Blackout_Date_Create()
        {
            ScheduleController controller = new ScheduleController();
            Schedule           schedule   = CreateSchedule();

            controller.CreateBlackoutDate(schedule, "Test blackout date", DateTime.Now, "test user");

            Assert.Greater(schedule.BlackoutDates.Count, 0);
            Assert.AreEqual(schedule.BlackoutDates.First().CreatedBy, "test user");
            Assert.Greater(schedule.BlackoutDates.First().BlackoutDateID, 0);
        }
Пример #4
0
        public void Blackout_Date_Read()
        {
            ScheduleController controller = new ScheduleController();
            Schedule           schedule   = CreateSchedule();

            controller.CreateBlackoutDate(schedule, "Test blackout date", DateTime.Now, "test user");

            BlackoutDate blackoutDate    = schedule.BlackoutDates.First();
            string       key             = KeyHelper.GetKey <IBlackoutDateRepository>();
            BlackoutDate newBlackoutDate = RepositoryFactory.GetRepository <IBlackoutDateRepository>(key).GetBlackoutDate(blackoutDate.BlackoutDateID);

            Assert.AreSame(blackoutDate, newBlackoutDate);
        }
Пример #5
0
        public void Blackout_Date_Delete()
        {
            ScheduleController controller = new ScheduleController();
            Schedule           schedule   = CreateSchedule();

            controller.CreateBlackoutDate(schedule, "Test blackout date", DateTime.Now, "test user");

            BlackoutDate blackoutDate   = schedule.BlackoutDates.First();
            int          blackoutDateID = blackoutDate.BlackoutDateID;

            controller.DeleteBlackoutDate(schedule, blackoutDateID);
            string key = KeyHelper.GetKey <IBlackoutDateRepository>();

            Assert.IsFalse(RepositoryFactory.GetRepository <IBlackoutDateRepository>(key).Exists(blackoutDateID));
        }
Пример #6
0
        public void Blackout_Date_Update()
        {
            ScheduleController controller = new ScheduleController();
            Schedule           schedule   = CreateSchedule();

            controller.CreateBlackoutDate(schedule, "Test blackout date", DateTime.Now, "test user");

            BlackoutDate blackoutDate = schedule.BlackoutDates.First();

            blackoutDate.Date = DateTime.Now.AddDays(1);
            controller.UpdateBlackoutDate(schedule, blackoutDate.BlackoutDateID, blackoutDate.Description,
                                          blackoutDate.Date, "other user");

            Assert.AreNotEqual(blackoutDate.Date, DateTime.Now);
            Assert.AreNotEqual(blackoutDate.CreatedBy, blackoutDate.ModifiedBy);
            Assert.AreEqual(blackoutDate.ModifiedBy, "other user");
        }