public void FirstDayOfWeekTest() { SchedulerDisplayInfo target = new SchedulerDisplayInfo(new CultureInfo("en-US")); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.FirstDayOfWeek = DayOfWeek.Monday; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'FirstDayOfWeek' changing to Monday."); PreparePropertyChangedTest(); target.FirstDayOfWeek = DayOfWeek.Tuesday; Assert.IsTrue(NotifiedProperties.Contains("FirstDayOfWeek"), "PropertyChanged event wasn't raised on property 'FirstDayOfWeek' changing to Tuesday."); PreparePropertyChangedTest(); target.FirstDayOfWeek = DayOfWeek.Tuesday; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'FirstDayOfWeek' changing to Tuesday."); PreparePropertyChangedTest(); target.FirstDayOfWeek = DayOfWeek.Wednesday; Assert.IsTrue(NotifiedProperties.Contains("FirstDayOfWeek"), "PropertyChanged event wasn't raised on property 'FirstDayOfWeek' changing to Wednesday."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void ShiftTest() { Occurrence target = new Occurrence(); target.StartDate = new DateTime(2010, 1, 1, 12, 0, 0); target.EndDate = new DateTime(2010, 1, 1, 12, 30, 0); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.Shift(new TimeSpan(0, 15, 0)); Assert.AreEqual(new DateTime(2010, 1, 1, 12, 15, 0), target.StartDate, "StartDate is not set correctly due to calling method 'ShiftOccurrence' with +15 minutes."); Assert.AreEqual(new DateTime(2010, 1, 1, 12, 45, 0), target.EndDate, "EndDate is not set correctly due to calling method 'ShiftOccurrence' with +15 minutes."); Assert.IsTrue(NotifiedProperties.Contains("StartDate"), "PropertyChanged event wasn't raised on property 'StartDate' changing due to calling method 'ShiftOccurrence' with +15 minutes."); Assert.IsTrue(NotifiedProperties.Contains("EndDate"), "PropertyChanged event wasn't raised on property 'EndDate' changing due to calling method 'ShiftOccurrence' with +15 minutes."); PreparePropertyChangedTest(); target.Shift(new TimeSpan(0, -10, 0)); Assert.AreEqual(new DateTime(2010, 1, 1, 12, 05, 0), target.StartDate, "StartDate is not set correctly due to calling method 'ShiftOccurrence' with -10 minutes."); Assert.AreEqual(new DateTime(2010, 1, 1, 12, 35, 0), target.EndDate, "EndDate is not set correctly due to calling method 'ShiftOccurrence' with -10 minutes."); Assert.IsTrue(NotifiedProperties.Contains("StartDate"), "PropertyChanged event wasn't raised on property 'StartDate' changing due to calling method 'ShiftOccurrence' with -10 minutes."); Assert.IsTrue(NotifiedProperties.Contains("EndDate"), "PropertyChanged event wasn't raised on property 'EndDate' changing due to calling method 'ShiftOccurrence' with -10 minutes."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void CategoryPropertyChangedTest() { Occurrence target = new Occurrence(); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.Category = Category.Blue; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'Category' changing to Blue."); PreparePropertyChangedTest(); target.Category = Category.Green; Assert.IsTrue(NotifiedProperties.Contains("Category"), "PropertyChanged event wasn't raised on property 'Category' changing to Green."); PreparePropertyChangedTest(); target.Category = Category.Green; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'Category' changing to Green."); PreparePropertyChangedTest(); target.Category = Category.Red; Assert.IsTrue(NotifiedProperties.Contains("Category"), "PropertyChanged event wasn't raised on property 'Category' changing to Red."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void SetDateTest() { SchedulerDayModel target = new SchedulerDayModel(displayInfo, date); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.SetDate(date); Assert.AreEqual(date, target.Date, "Date must be set."); Assert.AreEqual("Friday", target.DayOfWeek, "DayOfWeek must be set to Friday."); Assert.IsTrue(target.IsToday, "IsToday must be set to true."); Assert.IsTrue(target.IsActive, "IsActive must be set to true."); Assert.IsTrue(NotifiedProperties.Contains("Date"), "PropertyChanged event wasn't raised on property 'Date' changing to 1/1/2010."); Assert.IsTrue(NotifiedProperties.Contains("DayOfWeek"), "PropertyChanged event wasn't raised on property 'DayOfWeek' changing to Friday 1/1/2010."); Assert.IsTrue(NotifiedProperties.Contains("IsActive"), "PropertyChanged event wasn't raised on property 'IsActive' changing to true."); Assert.IsTrue(NotifiedProperties.Contains("IsToday"), "PropertyChanged event wasn't raised on property 'IsToday' changing to true."); Assert.IsTrue(NotifiedProperties.Contains("Month"), "PropertyChanged event wasn't raised on property 'Month' changing to January."); PreparePropertyChangedTest(); target.SetDate(date.AddDays(-7)); Assert.AreEqual(date.AddDays(-7), target.Date, "Date must be set."); Assert.AreEqual("Friday", target.DayOfWeek, "DayOfWeek must be set to Friday."); Assert.IsFalse(target.IsToday, "IsToday must be set to false."); Assert.IsTrue(target.IsActive, "IsActive must be set to true."); Assert.IsTrue(NotifiedProperties.Contains("Date"), "PropertyChanged event wasn't raised on property 'Date' changing to 1/1/2010."); Assert.IsTrue(NotifiedProperties.Contains("IsToday"), "PropertyChanged event wasn't raised on property 'IsToday' changing to true."); Assert.IsTrue(NotifiedProperties.Contains("Month"), "PropertyChanged event wasn't raised on property 'Month' changing to January."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void CalendarWeekRuleTest() { SchedulerDisplayInfo target = new SchedulerDisplayInfo(new CultureInfo("en-US")); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.CalendarWeekRule = CalendarWeekRule.FirstDay; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'CalendarWeekRule' changing to FirstDay."); PreparePropertyChangedTest(); target.CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek; Assert.IsTrue(NotifiedProperties.Contains("CalendarWeekRule"), "PropertyChanged event wasn't raised on property 'CalendarWeekRule' changing to FirstFourDayWeek."); PreparePropertyChangedTest(); target.CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'CalendarWeekRule' changing to FirstFourDayWeek."); PreparePropertyChangedTest(); target.CalendarWeekRule = CalendarWeekRule.FirstFullWeek; Assert.IsTrue(NotifiedProperties.Contains("CalendarWeekRule"), "PropertyChanged event wasn't raised on property 'CalendarWeekRule' changing to FirstFullWeek."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void ImportancePropertyChangedTest() { Occurrence target = new Occurrence(); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.Importance = Importance.Normal; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'Importance' changing to Normal."); PreparePropertyChangedTest(); target.Importance = Importance.Low; Assert.IsTrue(NotifiedProperties.Contains("Importance"), "PropertyChanged event wasn't raised on property 'Importance' changing to Low."); PreparePropertyChangedTest(); target.Importance = Importance.Low; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'Importance' changing to Low."); PreparePropertyChangedTest(); target.Importance = Importance.High; Assert.IsTrue(NotifiedProperties.Contains("Importance"), "PropertyChanged event wasn't raised on property 'Importance' changing to High."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void TitlePropertyChangedTest() { Occurrence target = new Occurrence(); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.Title = string.Empty; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'Title' changing to empty string."); PreparePropertyChangedTest(); target.Title = "TEST"; Assert.IsTrue(NotifiedProperties.Contains("Title"), "PropertyChanged event wasn't raised on property 'Title' changing to 'TEST'."); PreparePropertyChangedTest(); target.Title = "TEST"; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'Title' changing to 'TEST'."); PreparePropertyChangedTest(); target.Title = "TITLE"; Assert.IsTrue(NotifiedProperties.Contains("Title"), "PropertyChanged event wasn't raised on property 'Title' changing to 'TITLE'."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void DisplayedWeeksCaptionTest() { SchedulerViewModel scheduler = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false); SchedulerMonthViewModel target = new SchedulerMonthViewModel(scheduler, null); DateTime date = new DateTime(2010, 1, 1); target.Initialize(new DateTime(2010, 2, 1)); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.SetView(date); Assert.AreEqual(5, target.DisplayedWeeks, "DisplayedWeeks must be set 5."); Assert.IsTrue(NotifiedProperties.Contains("DisplayedWeeks"), "PropertyChanged event wasn't raised on property 'DisplayedWeeks' changing to 5."); PreparePropertyChangedTest(); target.SetView(date.AddDays(40)); Assert.AreEqual(4, target.DisplayedWeeks, "DisplayedWeeks must be set 4."); Assert.IsTrue(NotifiedProperties.Contains("DisplayedWeeks"), "PropertyChanged event wasn't raised on property 'DisplayedWeeks' changing to 4."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void AllDayEventPropertyChangedTest() { Occurrence target = new Occurrence(); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.AllDayEvent = false; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'AllDayEvent' changing to false."); PreparePropertyChangedTest(); target.AllDayEvent = true; Assert.IsTrue(NotifiedProperties.Contains("AllDayEvent"), "PropertyChanged event wasn't raised on property 'AllDayEvent' changing to true."); PreparePropertyChangedTest(); target.AllDayEvent = true; Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'AllDayEvent' changing to true."); PreparePropertyChangedTest(); target.AllDayEvent = false; Assert.IsTrue(NotifiedProperties.Contains("AllDayEvent"), "PropertyChanged event wasn't raised on property 'AllDayEvent' changing to false."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void SetTodayTest() { SchedulerDayModel target = new SchedulerDayModel(displayInfo, date); target.SetDate(date); Assert.IsTrue(target.IsToday, "IsToday must be set to true."); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.SetToday(date.AddDays(1)); Assert.IsFalse(target.IsToday, "IsToday must be set to false."); Assert.IsTrue(NotifiedProperties.Contains("IsToday"), "PropertyChanged event wasn't raised on property 'IsToday' changing to false."); PreparePropertyChangedTest(); target.SetToday(date); Assert.IsTrue(target.IsToday, "IsToday must be set to false."); Assert.IsTrue(NotifiedProperties.Contains("IsToday"), "PropertyChanged event wasn't raised on property 'IsToday' changing to true."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void SetDisplayedDateTest() { SchedulerViewModel target = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.SetDisplayedDate("TEST"); Assert.IsTrue(NotifiedProperties.Contains("DisplayedDate"), "PropertyChanged event wasn't raised on property 'DisplayedDate' changing to TEST."); PreparePropertyChangedTest(); target.SetDisplayedDate("TEST"); Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'DisplayedDate' changing to TEST."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void DayOfWeekTest() { DateTime date = new DateTime(2010, 1, 1); SchedulerDayModel day = new SchedulerDayModel(new SchedulerDisplayInfo(new CultureInfo("cs-CZ")), date); day.SetDate(date); SchedulerDayHeaderViewModel target = new SchedulerDayHeaderViewModel(null, day); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); day.SetDate(date.AddDays(-1), date, date); Assert.IsTrue(NotifiedProperties.Contains("DayOfWeek"), "PropertyChanged event wasn't raised on property 'DayOfWeek' changing to Thursday."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void IsTodayTest() { DateTime date = new DateTime(2010, 1, 1); SchedulerDayModel day = new SchedulerDayModel(new SchedulerDisplayInfo(new CultureInfo("cs-CZ")), date); day.SetDate(date); SchedulerAllDayBodyViewModel target = new SchedulerAllDayBodyViewModel(day); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); day.SetToday(date.AddDays(-1)); Assert.IsTrue(NotifiedProperties.Contains("IsToday"), "PropertyChanged event wasn't raised on property 'IsToday' changing to false."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void SetWeekRangeTest() { SchedulerWeekModel target = new SchedulerWeekModel(displayInfo, date, DisplayedDays.Week); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.SetDate(date, date.AddDays(-1), date.AddDays(1)); Assert.AreEqual(1, target.Week, "Week must be set 1."); Assert.IsTrue(NotifiedProperties.Contains("Week"), "PropertyChanged event wasn't raised on property 'Week' changing to 1."); PreparePropertyChangedTest(); target.SetDate(date.AddDays(-7), date.AddDays(-1), date.AddDays(1)); Assert.AreEqual(52, target.Week, "Week must be set 52."); Assert.IsTrue(NotifiedProperties.Contains("Week"), "PropertyChanged event wasn't raised on property 'Week' changing to 52."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void SetMonthRangeTest() { SchedulerMonthModel target = new SchedulerMonthModel(displayInfo, date); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.SetDate(date, date, date); Assert.AreEqual(5, target.DisplayedWeeks, "DisplayedWeeks must be set 5."); Assert.IsTrue(NotifiedProperties.Contains("DisplayedWeeks"), "PropertyChanged event wasn't raised on property 'DisplayedWeeks' changing to 5."); PreparePropertyChangedTest(); target.SetDate(date.AddDays(40), date, date); Assert.AreEqual(4, target.DisplayedWeeks, "DisplayedWeeks must be set 4."); Assert.IsTrue(NotifiedProperties.Contains("DisplayedWeeks"), "PropertyChanged event wasn't raised on property 'DisplayedWeeks' changing to 4."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void WorkingHoursToTest() { SchedulerDisplayInfo target = new SchedulerDisplayInfo(new CultureInfo("en-US")); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.WorkingHoursTo = new TimeSpan(17, 0, 0); Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'WorkingHoursTo' changing to 17:0:0."); PreparePropertyChangedTest(); target.WorkingHoursTo = new TimeSpan(16, 0, 0); Assert.IsTrue(NotifiedProperties.Contains("WorkingHoursTo"), "PropertyChanged event wasn't raised on property 'WorkingHoursTo' changing to 16:0:0."); PreparePropertyChangedTest(); target.WorkingHoursTo = new TimeSpan(16, 0, 0); Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'WorkingHoursTo' changing to 16:0:0."); PreparePropertyChangedTest(); target.WorkingHoursTo = new TimeSpan(15, 0, 0); Assert.IsTrue(NotifiedProperties.Contains("WorkingHoursTo"), "PropertyChanged event wasn't raised on property 'WorkingHoursTo' changing to 15:0:0."); PreparePropertyChangedTest(); target.WorkingHoursTo = new TimeSpan(7, 59, 59); Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'WorkingHoursTo' changing to 7:59:59."); PreparePropertyChangedTest(); target.WorkingHoursTo = new TimeSpan(24, 0, 1); Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'WorkingHoursTo' changing to 24:0:1."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void EndDateAndDurationPropertyChangedTest() { Occurrence target = new Occurrence(); target.StartDate = new DateTime(2010, 1, 1, 12, 0, 0); target.EndDate = new DateTime(2010, 1, 1, 12, 30, 0); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.EndDate = new DateTime(2010, 1, 1, 12, 30, 0); Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'EndDate' changing to 1/1/2010 12:30:00PM."); PreparePropertyChangedTest(); target.EndDate = new DateTime(2010, 1, 1, 12, 15, 0); Assert.IsTrue(NotifiedProperties.Contains("EndDate"), "PropertyChanged event wasn't raised on property 'EndDate' changing to 1/1/2010 12:15:00PM."); Assert.IsTrue(NotifiedProperties.Contains("Duration"), "PropertyChanged event wasn't raised on property 'Duration' changing due to 'EndDate' changed to' 1/1/2010 12:15:00PM."); PreparePropertyChangedTest(); target.EndDate = new DateTime(2010, 1, 1, 12, 15, 0); Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'EndDate' changing to 1/1/2010 12:15:00PM."); PreparePropertyChangedTest(); target.EndDate = new DateTime(2010, 1, 1, 12, 10, 0); Assert.IsTrue(NotifiedProperties.Contains("EndDate"), "PropertyChanged event wasn't raised on property 'EndDate' changing to 1/1/2010 12:10:00PM."); Assert.IsTrue(NotifiedProperties.Contains("Duration"), "PropertyChanged event wasn't raised on property 'Duration' changing due to 'EndDate' changed to' 1/1/2010 12:10:00PM."); PreparePropertyChangedTest(); target.EndDate = new DateTime(2010, 1, 1, 11, 15, 0); Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'EndDate' changing to 1/1/2010 11:45:00PM."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void WeekTest() { DateTime date = new DateTime(2010, 1, 1); SchedulerWeekModel model = new SchedulerWeekModel(new SchedulerDisplayInfo(new CultureInfo("en-US")), date, DisplayedDays.Week); model.SetDate(date); SchedulerMonthWeekHeaderViewModel target = new SchedulerMonthWeekHeaderViewModel(null, model); Assert.AreEqual(1, target.Week, "Week isn't 1."); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); model.SetDate(date.AddDays(7)); Assert.IsTrue(NotifiedProperties.Contains("Week"), "PropertyChanged event wasn't raised on property 'Week' changing to 2."); Assert.AreEqual(2, target.Week, "Week isn't 2."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void DayOfWeekTest() { DateTime date = new DateTime(2010, 1, 1); SchedulerDayModel model = new SchedulerDayModel(new SchedulerDisplayInfo(new CultureInfo("en-US")), date); model.SetDate(date); SchedulerMonthDayNameHeaderViewModel target = new SchedulerMonthDayNameHeaderViewModel(model); Assert.AreEqual("Friday", target.DayOfWeek, "DayOfWeek isn't Friday."); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); model.SetDate(date.AddDays(1)); Assert.IsTrue(NotifiedProperties.Contains("DayOfWeek"), "PropertyChanged event wasn't raised on property 'DayOfWeek' changing to Saturday."); Assert.AreEqual("Saturday", target.DayOfWeek, "DayOfWeek isn't Saturday."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }