2 // MonthCalendarTest.cs: Test case for MonthCalendar
5 // Ritvik Mayank (mritvik@novell.com)
7 // (C) 2005 Novell, Inc. (http://www.novell.com)
11 using System.Windows.Forms;
13 using System.Reflection;
14 using NUnit.Framework;
16 namespace MonoTests.System.Windows.Forms
19 [Ignore ("This test has to be completly reviewed")]
20 public class MonthCalendarTest
23 public void MonthCalendarPropertyTest ()
25 Form myfrm = new Form ();
26 myfrm.ShowInTaskbar = false;
27 MonthCalendar myMonthCal1 = new MonthCalendar ();
28 MonthCalendar myMonthCal2 = new MonthCalendar ();
29 myMonthCal1.Name = "MonthCendar";
30 myMonthCal1.TabIndex = 1;
31 DateTime myDateTime = new DateTime ();
34 myMonthCal1.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
35 Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.AnnuallyBoldedDates.GetValue (0), "#A1");
38 Assert.AreEqual ("Window", myMonthCal1.BackColor.Name, "#B1");
39 myMonthCal1.AddBoldedDate (new DateTime (2005, 09, 01));
40 Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.BoldedDates.GetValue (0), "#B2");
43 Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Height, "#C1");
44 Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Width, "#C2");
45 Assert.AreEqual (false, myMonthCal1.CalendarDimensions.IsEmpty, "#C3");
48 Assert.AreEqual (Day.Default, myMonthCal1.FirstDayOfWeek, "#F1");
49 myMonthCal1.FirstDayOfWeek = Day.Sunday;
50 Assert.AreEqual (Day.Sunday, myMonthCal1.FirstDayOfWeek, "#F2");
51 Assert.AreEqual ("WindowText", myMonthCal1.ForeColor.Name, "#F3");
54 Assert.AreEqual (new DateTime (9998,12,31), myMonthCal1.MaxDate, "#M1");
55 Assert.AreEqual (7, myMonthCal1.MaxSelectionCount, "#M2");
56 Assert.AreEqual (new DateTime (1753,1,1), myMonthCal1.MinDate, "#M3");
57 myMonthCal1.AddMonthlyBoldedDate (new DateTime (2005, 09, 01));
58 Assert.AreEqual (new DateTime(2005, 09, 01), myMonthCal1.MonthlyBoldedDates.GetValue (0), "#M4");
61 Assert.AreEqual (0, myMonthCal1.ScrollChange, "#S1");
62 myMonthCal1.SelectionStart = new DateTime (2005,09,02);
63 myMonthCal1.SelectionEnd = new DateTime (2005,09,03);
64 Assert.AreEqual (new DateTime (2005,09,03), myMonthCal1.SelectionEnd, "#S2");
65 //Assert.AreEqual (new SelectionRange (new DateTime(2005,09,02), new DateTime(2005,09,03)), myMonthCal1.SelectionRange, "#S3");
66 Assert.AreEqual (new DateTime (2005,09,02), myMonthCal1.SelectionStart, "#S4");
67 Assert.AreEqual (true, myMonthCal1.ShowToday, "#S5");
68 Assert.AreEqual (true, myMonthCal1.ShowTodayCircle, "#S6");
69 Assert.AreEqual (false, myMonthCal1.ShowWeekNumbers, "#S7");
70 Assert.AreEqual (153, myMonthCal1.SingleMonthSize.Height, "#S8a");
71 Assert.AreEqual (176, myMonthCal1.SingleMonthSize.Width, "#S8b");
72 Assert.AreEqual (null, myMonthCal1.Site, "#S9");
74 Assert.AreEqual ("ActiveCaption", myMonthCal1.TitleBackColor.Name, "#T1");
75 Assert.AreEqual ("ActiveCaptionText", myMonthCal1.TitleForeColor.Name, "#T2");
76 Assert.AreEqual (DateTime.Today, myMonthCal1.TodayDate, "#T3");
77 Assert.AreEqual (false, myMonthCal1.TodayDateSet, "#T4");
78 Assert.AreEqual ("GrayText", myMonthCal1.TrailingForeColor.Name, "#T5");
84 [ExpectedException (typeof (ArgumentException))]
85 public void MonthCalMaxSelectionCountException ()
87 MonthCalendar myMonthCal1 = new MonthCalendar ();
88 myMonthCal1.MaxSelectionCount = 0 ; // value is less than 1
92 [ExpectedException (typeof (ArgumentException))]
93 public void MonthCalMaxDateException ()
95 MonthCalendar myMonthCal1 = new MonthCalendar ();
96 myMonthCal1.MaxDate = new DateTime (1752, 1, 1, 0, 0, 0, 0); // value is less than min date (01/01/1753)
100 [ExpectedException (typeof (ArgumentException))]
101 public void MonthCalMinDateException ()
103 MonthCalendar myMonthCal1 = new MonthCalendar ();
104 myMonthCal1.MinDate = new DateTime(1752, 1, 1, 0, 0, 0, 0); // Date earlier than 01/01/1753
105 myMonthCal1.MinDate = new DateTime(9999, 12, 31, 0, 0, 0, 0); // Date greater than max date (01/01/1753)
109 [ExpectedException (typeof (ArgumentException))]
110 public void MonthCalSelectRangeException ()
112 MonthCalendar myMonthCal1 = new MonthCalendar ();
113 myMonthCal1.SelectionRange = new SelectionRange (new DateTime (1752, 01, 01), new DateTime (1752, 01, 02));
114 myMonthCal1.SelectionRange = new SelectionRange (new DateTime (9999, 12, 30), new DateTime (9999, 12, 31));
118 public void AddAnnuallyBoldedDateTest ()
120 Form myForm = new Form ();
121 myForm.ShowInTaskbar = false;
122 MonthCalendar myMonthCal = new MonthCalendar ();
123 myMonthCal.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
124 myForm.Controls.Add (myMonthCal);
125 Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal.AnnuallyBoldedDates.GetValue (0), "#add1");
130 public void AddBoldedDateTest ()
132 Form myForm = new Form ();
133 myForm.ShowInTaskbar = false;
134 MonthCalendar myMonthCal = new MonthCalendar ();
135 myMonthCal.AddBoldedDate (new DateTime (2005, 09, 02));
136 myForm.Controls.Add (myMonthCal);
137 Assert.AreEqual (new DateTime (2005, 09, 02), myMonthCal.BoldedDates.GetValue (0), "#add2");
142 public void AddMonthlyBoldedDateTest ()
144 Form myForm = new Form ();
145 myForm.ShowInTaskbar = false;
146 MonthCalendar myMonthCal = new MonthCalendar ();
147 myMonthCal.AddMonthlyBoldedDate (new DateTime (2005, 09, 03));
148 myForm.Controls.Add (myMonthCal);
149 Assert.AreEqual (new DateTime (2005, 09, 03), myMonthCal.MonthlyBoldedDates.GetValue (0), "#add2");
154 public void GetDispalyRangeTest ()
156 Form myForm = new Form ();
157 myForm.ShowInTaskbar = false;
158 MonthCalendar myMonthCal = new MonthCalendar ();
159 myForm.Controls.Add (myMonthCal);
160 SelectionRange mySelRange = new SelectionRange ();
161 mySelRange.Start = new DateTime (2005, 09, 01);
162 mySelRange.End = new DateTime (2005, 09, 30);
163 Assert.AreEqual (mySelRange.Start, myMonthCal.GetDisplayRange (true).Start, "#Get1");
164 Assert.AreEqual (mySelRange.End, myMonthCal.GetDisplayRange (true).End, "#Get22");
169 public void HitTest ()
171 Form myForm = new Form ();
172 myForm.ShowInTaskbar = false;
173 MonthCalendar myMonthCal = new MonthCalendar ();
174 myForm.Controls.Add (myMonthCal);
175 Assert.AreEqual (new DateTime (01, 01, 01), myMonthCal.HitTest(10, 10).Time, "#Hit1");