public void ClickHeaderCommandTest() { DateTime date = new DateTime(2010, 1, 1); SchedulerDayModel day = new SchedulerDayModel(new SchedulerDisplayInfo(new CultureInfo("cs-CZ")), date); SchedulerMonthDayHeaderViewModel target = new SchedulerMonthDayHeaderViewModel(null, day); Assert.IsInstanceOfType(target.ClickHeaderCommand, typeof(ICommand), "ClickHeaderCommand should return ICommand object."); }
public SchedulerWeekModel(SchedulerDisplayInfo displayInfo, DateTime today, DisplayedDays displayedDays) : base(displayInfo) { this.displayedDays = displayedDays; days = new SchedulerDayModel[(int)displayedDays]; for (int i = 0; i < days.Length; i++) days[i] = new SchedulerDayModel(displayInfo, today); }
public SchedulerWeekModel(SchedulerDisplayInfo displayInfo, DateTime today, DisplayedDays displayedDays) : base(displayInfo) { this.displayedDays = displayedDays; days = new SchedulerDayModel[(int)displayedDays]; for (int i = 0; i < days.Length; i++) { days[i] = new SchedulerDayModel(displayInfo, today); } }
public void CanClickHeaderTest() { DateTime date = new DateTime(2010, 1, 1); SchedulerDayModel day = new SchedulerDayModel(new SchedulerDisplayInfo(new CultureInfo("cs-CZ")), date); day.SetDate(date); SchedulerMonthDayHeaderViewModel_Accessor target = new SchedulerMonthDayHeaderViewModel_Accessor(null, day); Assert.IsTrue(target.CanClickHeader, "Should be able to click header."); day.SetDate(date, date.AddDays(1), date.AddDays(2)); Assert.IsFalse(target.CanClickHeader, "Should not be able to click header."); }
public void ClickHeaderTest() { DaySelected dayNotify = new DaySelected(); DateTime date = new DateTime(2010, 1, 1); SchedulerDayModel day = new SchedulerDayModel(new SchedulerDisplayInfo(new CultureInfo("cs-CZ")), date); day.SetDate(date); SchedulerMonthDayHeaderViewModel target = new SchedulerMonthDayHeaderViewModel(dayNotify, day); Assert.IsNull(dayNotify.Day, "Day should be null."); ICommand command = target.ClickHeaderCommand; command.Execute(null); Assert.IsNotNull(dayNotify.Day, "Day should be assigned."); Assert.AreEqual(date, dayNotify.Day.Date, "Date should be 1/1/2010."); }
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 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); } }
public void MonthTest() { DateTime date = new DateTime(2010, 1, 1); SchedulerDayModel day = new SchedulerDayModel(new SchedulerDisplayInfo(new CultureInfo("cs-CZ")), date); day.SetDate(date); SchedulerMonthDayHeaderViewModel target = new SchedulerMonthDayHeaderViewModel(null, day); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); day.SetDate(date.AddDays(-1)); Assert.IsTrue(NotifiedProperties.Contains("Month"), "PropertyChanged event wasn't raised on property 'Month' changing to December."); } finally { target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); } }
public void SelectDayTest() { SchedulerViewModel_Accessor target = new SchedulerViewModel_Accessor(null, new CultureInfo("en-US"), false, false); SchedulerDayModel day = new SchedulerDayModel(target.displayInfo, new DateTime(2010, 1, 1)); target.SelectDay(day); Assert.IsNotNull(target.ViewModels[(int)DisplayMode.Day], "SelectDay doesn't create view model for Day."); }
public void SetDateRangeTest() { SchedulerDayModel target = new SchedulerDayModel(displayInfo, date); try { target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); PreparePropertyChangedTest(); target.SetDate(date, date.AddDays(-1), date.AddDays(1)); 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), date.AddDays(-1), date.AddDays(1)); 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.IsFalse(target.IsActive, "IsActive must be set to false."); Assert.IsTrue(NotifiedProperties.Contains("Date"), "PropertyChanged event wasn't raised on property 'Date' changing to 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."); } 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); } }