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); } }
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); } }
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); }
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); }
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)); }
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"); }