Пример #1
0
 private void VerifyIsTodayHighlighted(Calendar calendar)
 {
     CalendarDayButton b = calendar.FindDayButtonFromDay(DateTime.Today);
     Assert.IsTrue(b.IsToday);
     calendar.IsTodayHighlighted = false;
     Assert.IsFalse(b.IsToday);
     _isLoaded = false;
 }
Пример #2
0
        private void VerifySelectedDate(Calendar calendar, DateTime d)
        {
            CalendarDayButton b;
            Assert.IsTrue(CompareDates(calendar.SelectedDate.Value, d));
            Assert.IsTrue(calendar.SelectedDates.Contains(d));
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            b = calendar.FindDayButtonFromDay(d);
            Assert.IsTrue(b.IsSelected);

            for (int i = 7; i < 48; i++)
            {
                if (i != b.Index)
                {
                    Assert.IsFalse(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
                }
            }
        }
Пример #3
0
 private void VerifyDisplayModeVisibleDayCount(Calendar calendar)
 {
     calendar.DisplayMode = CalendarMode.Year;
     calendar.DisplayMode = CalendarMode.Month;
     Assert.IsFalse((calendar.FindDayButtonFromDay(new DateTime(2008, 6, 14))).IsEnabled);
     Assert.IsFalse((calendar.FindDayButtonFromDay(new DateTime(2008, 6, 30))).IsEnabled);
     _isLoaded = false;
 }
Пример #4
0
        public void DayButton_AutomationPeer()
        {
            Calendar calendar = new Calendar();
            Assert.IsNotNull(calendar);
            _isLoaded = false;
            DateTime date = new DateTime(2000, 2, 2);
            calendar.DisplayDate = date;
            calendar.SelectedDate = date;

            CalendarAutomationPeer calendarAutomationPeer = (CalendarAutomationPeer)CalendarAutomationPeer.CreatePeerForElement(calendar);
            Assert.IsNotNull(calendarAutomationPeer);
            TestPeer testPeer = new TestPeer(calendar);

            calendar.Loaded += new RoutedEventHandler(calendar_Loaded);
            TestPanel.Children.Add(calendar);
            EnqueueConditional(IsLoaded);

            EnqueueCallback(delegate
            {
                CalendarDayButton dayButton = calendar.FindDayButtonFromDay(date);
                Assert.IsNotNull(dayButton);
                AutomationPeer peer = CalendarAutomationPeer.CreatePeerForElement(dayButton);
                Assert.IsNotNull(peer);

                Assert.AreEqual(peer.GetAutomationControlType(), AutomationControlType.Button, "Incorrect Control type for Daybutton");
                Assert.AreEqual(peer.GetClassName(), dayButton.GetType().Name, "Incorrect ClassName value for DayButton");
                Assert.AreEqual(peer.GetName(), dayButton.Content.ToString(), "Incorrect Name value for DayButtonPeer");
                Assert.IsTrue(peer.IsContentElement(), "Incorrect IsContentElement value");
                Assert.IsTrue(peer.IsControlElement(), "Incorrect IsControlElement value");
                Assert.IsFalse(peer.IsKeyboardFocusable(), "Incorrect IsKeyBoardFocusable value");

                #region DayButtonAutomationPeer ISelectionItemProvider tests:

                ISelectionItemProvider selectionItem = (ISelectionItemProvider)peer.GetPattern(PatternInterface.SelectionItem);
                Assert.IsNotNull(selectionItem);
                Assert.IsTrue(selectionItem.IsSelected);
                Assert.AreEqual(calendarAutomationPeer, testPeer.GetPeerFromProvider(selectionItem.SelectionContainer));
                selectionItem.RemoveFromSelection();
                Assert.IsFalse(selectionItem.IsSelected);
                selectionItem.AddToSelection();
                Assert.IsTrue(selectionItem.IsSelected);


                //check selection in SingleDate mode
                CalendarDayButton dayButton2 = calendar.FindDayButtonFromDay(date.AddDays(1));
                Assert.IsNotNull(dayButton2);
                AutomationPeer peer2 = CalendarAutomationPeer.CreatePeerForElement(dayButton2);
                Assert.IsNotNull(peer2);
                ISelectionItemProvider selectionItem2 = (ISelectionItemProvider)peer2.GetPattern(PatternInterface.SelectionItem);
                Assert.IsNotNull(selectionItem2);
                Assert.IsFalse(selectionItem2.IsSelected);
                selectionItem2.AddToSelection();
                Assert.IsTrue(selectionItem2.IsSelected);
                Assert.IsFalse(selectionItem.IsSelected);

                //check blackout day
                selectionItem.RemoveFromSelection();
                calendar.BlackoutDates.Add(new CalendarDateRange(date));
                selectionItem.AddToSelection();
                Assert.IsFalse(selectionItem.IsSelected);

                //check selection in None mode
                calendar.SelectionMode = CalendarSelectionMode.None;
                Assert.IsFalse(selectionItem2.IsSelected);
                selectionItem2.AddToSelection();
                Assert.IsFalse(selectionItem2.IsSelected);

                //check selection in MultiRange mode
                calendar.BlackoutDates.Clear();
                calendar.SelectionMode = CalendarSelectionMode.MultipleRange;
                Assert.IsFalse(selectionItem.IsSelected);
                Assert.IsFalse(selectionItem2.IsSelected);
                selectionItem.AddToSelection();
                selectionItem2.AddToSelection();
                Assert.IsTrue(selectionItem.IsSelected);
                Assert.IsTrue(selectionItem2.IsSelected);
                selectionItem2.RemoveFromSelection();
                Assert.IsTrue(selectionItem.IsSelected);
                Assert.IsFalse(selectionItem2.IsSelected);
                #endregion

                #region DayButtonAutomationPeer IInvoke tests:

                //check selection and trailing day functionality
                CalendarDayButton dayButton4 = calendar.FindDayButtonFromDay(new DateTime(2000,1,31));
                Assert.IsNotNull(dayButton4);
                AutomationPeer peer4 = CalendarAutomationPeer.CreatePeerForElement(dayButton4);
                Assert.IsNotNull(peer4);
                IInvokeProvider invokeItem = (IInvokeProvider)peer4.GetPattern(PatternInterface.Invoke);
                Assert.IsNotNull(invokeItem);
                invokeItem.Invoke();
                dayButton4 = calendar.FindDayButtonFromDay(new DateTime(2000, 1, 31));
                Assert.IsTrue(dayButton4.IsSelected);
                Assert.AreEqual(calendar.DisplayDate.Month, 1);

                #endregion

                #region DayButtonAutomationPeer ITableItemProvider tests:

                ITableItemProvider tableItem = (ITableItemProvider)peer.GetPattern(PatternInterface.TableItem);
                Assert.IsNotNull(tableItem);

                IRawElementProviderSimple[] headers = tableItem.GetColumnHeaderItems();
                Assert.AreEqual(1, headers.Length);
                Assert.Equals((((ITableProvider)calendarAutomationPeer).GetColumnHeaders())[3], headers[0]);
                Assert.IsNull(tableItem.GetRowHeaderItems());

                #endregion

                #region DayButtonAutomationPeer IGridItemProvider tests:

                foreach (UIElement child in calendar.MonthControl.MonthView.Children)
                {
                    int childRow = (int)child.GetValue(Grid.RowProperty);
                    IGridItemProvider gridItem;

                    if (childRow != 0)
                    {
                        peer = CalendarDayButtonAutomationPeer.CreatePeerForElement(child);
                        Assert.IsNotNull(peer);
                        gridItem = (IGridItemProvider)peer.GetPattern(PatternInterface.GridItem);
                        Assert.IsNotNull(gridItem);

                        Assert.AreEqual(child.GetValue(Grid.ColumnProperty), gridItem.Column);
                        Assert.AreEqual((int)child.GetValue(Grid.RowProperty) - 1, gridItem.Row);
                        Assert.AreEqual(1, gridItem.ColumnSpan);
                        Assert.AreEqual(1, gridItem.RowSpan);
                        Assert.AreEqual(calendarAutomationPeer, testPeer.GetPeerFromProvider(gridItem.ContainingGrid));
                    }
                }

                #endregion
            });

            EnqueueTestComplete();
        }
Пример #5
0
        private void VerifyKeyboardSingleRange(Calendar calendar)
        {
            // Assumes that the Calendar is Gregorian
            DateTime d, end;
            CalendarDayButton b;

            //single selection with keyboard in SingleRange Mode
            calendar.TestHook.ProcessDownKey(false, false);
            d = DateTime.Today.AddDays(7);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessUpKey(false, false);
            d = DateTime.Today;
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessLeftKey(false);
            d = DateTime.Today.AddDays(-1);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessRightKey(false);
            d = DateTime.Today;
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessPageDownKey(false);
            d = DateTime.Today.AddMonths(1);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessPageUpKey(false);
            d = d.AddMonths(-1);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessHomeKey(false);
            d = calendar.DisplayDateInternal;
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessEndKey(false);
            d = d.AddMonths(1);
            d = d.AddDays(-1);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessDownKey(false, true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(7);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 8);
            while (DateTime.Compare(d, end) < 1)
            {
                b = calendar.FindDayButtonFromDay(d);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                d = d.AddDays(1);
            }

            calendar.TestHook.ProcessUpKey(false, true);
            calendar.TestHook.ProcessShiftKeyUp();
            d = d.AddDays(-8);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            b = calendar.FindDayButtonFromDay(d);
            Assert.IsTrue(b.IsSelected);

            calendar.TestHook.ProcessUpKey(false, true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(-7);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 8);
            while (DateTime.Compare(end, d) < 1)
            {
                b = calendar.FindDayButtonFromDay(end);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                end = end.AddDays(1);
            }

            calendar.TestHook.ProcessLeftKey(true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(-8);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 9);
            while (DateTime.Compare(end, d) < 1)
            {
                b = calendar.FindDayButtonFromDay(end);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                end = end.AddDays(1);
            }

            calendar.TestHook.ProcessRightKey(true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(-7);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 8);
            while (DateTime.Compare(end, d) < 1)
            {
                b = calendar.FindDayButtonFromDay(end);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                end = end.AddDays(1);
            }

            calendar.TestHook.ProcessPageDownKey(true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(-7);
            end = end.AddMonths(1);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == ((end - d).Days + 1));
            while (DateTime.Compare(d, end) < 1)
            {
                b = calendar.FindDayButtonFromDay(d);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                d = d.AddDays(1);
            }

            calendar.TestHook.ProcessPageUpKey(true);
            calendar.TestHook.ProcessShiftKeyUp();
            d = end.AddMonths(-1);
            end = d.AddDays(7);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, end) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 8);
            while (DateTime.Compare(d, end) < 1)
            {
                b = calendar.FindDayButtonFromDay(d);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                d = d.AddDays(1);
            }

            calendar.TestHook.ProcessHomeKey(true);
            calendar.TestHook.ProcessShiftKeyUp();
            d = calendar.DisplayDateInternal;
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, end) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == ((end - d).Days + 1));
            while (DateTime.Compare(d, end) < 1)
            {
                b = calendar.FindDayButtonFromDay(d);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                d = d.AddDays(1);
            }

            calendar.TestHook.ProcessEndKey(true);
            calendar.TestHook.ProcessShiftKeyUp();
            d = end;
            end = calendar.DisplayDateInternal.AddMonths(1);
            end = end.AddDays(-1);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, end) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == ((end - d).Days + 1));
            while (DateTime.Compare(d, end) < 1)
            {
                b = calendar.FindDayButtonFromDay(d);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                d = d.AddDays(1);
            }

            _isLoaded = false;
        }
Пример #6
0
        private void VerifySelectDaySingleRangeMouseHover(Calendar calendar)
        {
            //Assumes that the Calendar is Gregorian
            CalendarDayButton b;
            System.Globalization.Calendar cal = new GregorianCalendar();
            int start, end;
            DateTime r1, r2;

            r1 = new DateTime(2003, 10, 10);
            r2 = new DateTime(2003, 11, 1);

            Clear();
            calendar.DisplayDate = r1;
            b = calendar.FindDayButtonFromDay(r1);
            start = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);

            while (DateTime.Compare(r2, r1) > 0)
            {
                r1 = cal.AddDays(r1, 1);
                b = calendar.FindDayButtonFromDay(r1);
                calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);
                calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);
            }
            end = b.Index;
            Assert.IsTrue(calendar.SelectedDates.Count == 0);

            //check if the buttons are highlighted
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }

            b = calendar.FindDayButtonFromDay(r2);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);

            Assert.IsTrue(_addedDays.Count == 23);
            Assert.IsTrue(_eventCount == 1);

            Assert.IsTrue(DateTimeHelper.CompareYearMonth(calendar.DisplayDate, r2) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 23);
            Assert.IsTrue(CompareDates(calendar.SelectedDates[0], calendar.SelectedDate.Value));

            _isLoaded = false;
        }
Пример #7
0
        private void VerifySelectDaySingleRangeMouseEnter(Calendar calendar)
        {
            // Assumes that the Calendar is Gregorian
            CalendarDayButton b;
            int start, end;

            //
            //verify if a single day can be selected
            //
            Clear();
            DateTime d = new DateTime(2003, 10, 1);
            calendar.DisplayDate = d;
            b = calendar.FindDayButtonFromDay(d);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            Assert.IsTrue(calendar.SelectedDates.Count == 0);
            Assert.IsNull(calendar.SelectedDate);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);


            Assert.IsTrue(_addedDays.Count == 1);
            Assert.IsTrue(_removedDays.Count == 0);
            Assert.IsTrue(_eventCount == 1);
            Assert.IsTrue(CompareDates((DateTime)_addedDays[0], (DateTime)b.DataContext));
            Assert.IsTrue(b.IsSelected);
            Assert.AreEqual(b.DataContext, calendar.SelectedDate);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            Assert.IsTrue(calendar.SelectedDates.Contains(d));

            calendar.SelectedDates.Clear();

            //
            //verify SingleRange selection with MouseEnter -- One single set
            //
            Clear();
            d = new DateTime(2003, 10, 10);
            b = calendar.FindDayButtonFromDay(d);
            start = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            Assert.IsTrue(calendar.SelectedDates.Count == 0);
            Assert.IsNull(calendar.SelectedDate);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);
            Assert.IsTrue(calendar.SelectedDates.Count == 0);

            d = new DateTime(2003, 10, 20);
            b = calendar.FindDayButtonFromDay(d);
            end = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);
            Assert.IsTrue(calendar.SelectedDates.Count == 0);
            Assert.IsNull(calendar.SelectedDate);

            //check if the buttons are highlighted
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }

            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);

            Assert.IsTrue(_addedDays.Count == 11);
            Assert.IsTrue(_removedDays.Count == 0);
            Assert.IsTrue(_eventCount == 1);
            int j = 0;
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).DataContext));
                Assert.IsTrue(CompareDates((DateTime)_addedDays[j], (DateTime)((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).DataContext));
                j++;
            }

            Assert.IsTrue(CompareDates(calendar.SelectedDates[0], calendar.SelectedDate.Value));
            Assert.IsTrue(calendar.SelectedDates.Count == 11);


            //
            //verify SingleRange selection with MouseEnter -- two sets
            //
            Clear();
            d = new DateTime(2003, 10, 10);
            b = calendar.FindDayButtonFromDay(d);
            start = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);


            d = new DateTime(2003, 10, 20);
            b = calendar.FindDayButtonFromDay(d);
            end = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);

            //check if the buttons are highlighted
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }

            //check if the selectedDates are not updated yet
            Assert.IsTrue(calendar.SelectedDates.Count == 11);

            d = new DateTime(2003, 10, 1);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);
            b = calendar.FindDayButtonFromDay(d);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);
            //check if the first set is unhighlighted
            for (int i = start + 1; i <= end; i++)
            {
                Assert.IsFalse(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }
            end = b.Index;
            //check if the second set is highlighted
            for (int i = end; i <= start; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);



            Assert.IsTrue(_addedDays.Count == 10);
            Assert.IsTrue(_removedDays.Count == 11);
            Assert.IsTrue(_eventCount == 1);
            j = 0;
            for (int i = start; i >= end; i--)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).DataContext));
                Assert.IsTrue(CompareDates((DateTime)_addedDays[j], (DateTime)((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).DataContext));
                j++;
            }

            Assert.IsTrue(CompareDates(calendar.SelectedDates[0], calendar.SelectedDate.Value));
            Assert.IsTrue(calendar.SelectedDates.Count == 10);


            ////check if the trailing days work in SingleRange Mode
            Clear();
            start = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);
            d = new DateTime(2003, 11, 1);
            b = calendar.FindDayButtonFromDay(d);
            end = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);
            ////check if the buttons are highlighted
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);

            Assert.IsTrue(_addedDays.Count == 32);
            Assert.IsTrue(_removedDays.Count == 10);
            Assert.IsTrue(_eventCount == 1);
            Assert.IsTrue(DateTime.Compare(calendar.DisplayDate, d) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 32);
            Assert.IsTrue(CompareDates(calendar.SelectedDates[0], calendar.SelectedDate.Value));

            _isLoaded = false;
        }
Пример #8
0
        private void VerifySelectDaySingle(Calendar calendar)
        {
            // Assumes that the Calendar is Gregorian
            CalendarDayButton b;

            Clear();
            DateTime d = new DateTime(2003, 10, 1);
            calendar.DisplayDate = d;
            b = calendar.FindDayButtonFromDay(d);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);

            Assert.IsTrue(_addedDays.Count == 1);
            Assert.IsTrue(_removedDays.Count == 1);
            Assert.IsTrue(_eventCount == 1);
            Assert.IsTrue(CompareDates((DateTime)_addedDays[0], (DateTime)b.DataContext));
            Assert.IsTrue(CompareDates((DateTime)_removedDays[0], new DateTime(2000, 2, 2)));
            Assert.IsTrue(b.IsSelected);
            Assert.AreEqual(b.DataContext, calendar.SelectedDate);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            Assert.IsTrue(calendar.SelectedDates.Contains(d));

            //check if the trailing days work in Single Mode
            Clear();
            b = calendar.FindDayButtonFromDay(new DateTime(2003, 9, 30));
            d = (DateTime)b.DataContext;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            //we find the button again since the button changed when clicked-on
            b = calendar.FindDayButtonFromDay(new DateTime(2003, 9, 30));
            Assert.IsTrue(_addedDays.Count == 1);
            Assert.IsTrue(_removedDays.Count == 1);
            Assert.IsTrue(_eventCount == 1);
            Assert.IsTrue(CompareDates((DateTime)_addedDays[0], (DateTime)b.DataContext));
            Assert.IsTrue(CompareDates((DateTime)_removedDays[0], new DateTime(2003, 10, 1)));
            Assert.IsTrue(b.IsSelected);
            Assert.AreEqual(b.DataContext, calendar.SelectedDate);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            Assert.IsTrue(calendar.SelectedDates.Contains(d));
            Assert.AreEqual(d, calendar.SelectedDate);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);
            Assert.AreEqual(calendar.DisplayDate, new DateTime(2003, 9, 1));
            b = calendar.FindDayButtonFromDay(d);
            Assert.IsTrue(b.IsSelected);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            Assert.IsTrue(calendar.SelectedDates.Contains(d));

            _isLoaded = false;
        }