示例#1
0
 public SchedulerMonthModel(SchedulerDisplayInfo displayInfo, DateTime today)
     : base(displayInfo)
 {
     weeks = new SchedulerWeekModel[6];
     for (int i = 0; i < 6; i++)
         weeks[i] = new SchedulerWeekModel(displayInfo, today, DisplayedDays.Week);
 }
 public void ClickHeaderCommandTest()
 {
     DateTime date = new DateTime(2010, 1, 1);
     SchedulerWeekModel week = new SchedulerWeekModel(new SchedulerDisplayInfo(new CultureInfo("cs-CZ")), date, DisplayedDays.Week);
     SchedulerMonthWeekHeaderViewModel target = new SchedulerMonthWeekHeaderViewModel(null, week);
     Assert.IsInstanceOfType(target.ClickHeaderCommand, typeof(ICommand), "ClickHeaderCommand should return ICommand object.");
 }
 public SchedulerMonthModel(SchedulerDisplayInfo displayInfo, DateTime today)
     : base(displayInfo)
 {
     weeks = new SchedulerWeekModel[6];
     for (int i = 0; i < 6; i++)
     {
         weeks[i] = new SchedulerWeekModel(displayInfo, today, DisplayedDays.Week);
     }
 }
        public void ClickHeaderTest()
        {
            WeekSelected weekNotify = new WeekSelected();
            DateTime date = new DateTime(2010, 1, 1);
            SchedulerWeekModel week = new SchedulerWeekModel(new SchedulerDisplayInfo(new CultureInfo("cs-CZ")), date, DisplayedDays.Week);
            week.SetDate(date);
            SchedulerMonthWeekHeaderViewModel target = new SchedulerMonthWeekHeaderViewModel(weekNotify, week);

            Assert.IsNull(weekNotify.Week, "Week should be null.");

            ICommand command = target.ClickHeaderCommand;
            command.Execute(null);

            Assert.IsNotNull(weekNotify.Week, "Week should be assigned.");
            Assert.AreEqual(1, weekNotify.Week.Week, "Date should be 1.");
        }
 public void SelectWeekTest()
 {
     SchedulerViewModel_Accessor target = new SchedulerViewModel_Accessor(null, new CultureInfo("en-US"), false, false);
     SchedulerWeekModel week = new SchedulerWeekModel(target.displayInfo, new DateTime(2010, 1, 1), DisplayedDays.Week);
     target.SelectWeek(week);
     Assert.IsNotNull(target.ViewModels[(int)DisplayMode.Week], "SelectWeek doesn't create view model for Week.");
 }
        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 SetTodayTest()
 {
     SchedulerWeekModel target = new SchedulerWeekModel(displayInfo, date, DisplayedDays.Week);
     target.SetToday(date.AddDays(1));
     Assert.IsFalse(target.Days[0].IsToday, "IsToday must be set to false.");
 }
 public void SchedulerWeekModelCtorTest()
 {
     SchedulerWeekModel target = new SchedulerWeekModel(displayInfo, date, DisplayedDays.Week);
     Assert.AreEqual((int)target.DisplayedDays, target.Days.Length, "Days array must have " + (int)target.DisplayedDays + " items.");
 }
        public void SetWeekTest()
        {
            SchedulerWeekModel target = new SchedulerWeekModel(displayInfo, date, DisplayedDays.Week);
            try
            {
                target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

                PreparePropertyChangedTest();
                target.SetDate(date);
                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));
                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);
            }
        }