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 public class MonthCalendarPropertiesTest : MonthCalendar
27 public void DefaultMarginTest ()
29 Assert.AreEqual (DefaultMargin.All, 9, "#01");
35 [Ignore ("This test has to be completly reviewed")]
36 public class MonthCalendarTest
39 public void MonthCalendarPropertyTest ()
41 Form myfrm = new Form ();
42 myfrm.ShowInTaskbar = false;
43 MonthCalendar myMonthCal1 = new MonthCalendar ();
44 MonthCalendar myMonthCal2 = new MonthCalendar ();
45 myMonthCal1.Name = "MonthCendar";
46 myMonthCal1.TabIndex = 1;
47 DateTime myDateTime = new DateTime ();
50 myMonthCal1.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
51 Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.AnnuallyBoldedDates.GetValue (0), "#A1");
54 Assert.AreEqual ("Window", myMonthCal1.BackColor.Name, "#B1");
55 myMonthCal1.AddBoldedDate (new DateTime (2005, 09, 01));
56 Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.BoldedDates.GetValue (0), "#B2");
59 Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Height, "#C1");
60 Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Width, "#C2");
61 Assert.AreEqual (false, myMonthCal1.CalendarDimensions.IsEmpty, "#C3");
64 Assert.AreEqual (Day.Default, myMonthCal1.FirstDayOfWeek, "#F1");
65 myMonthCal1.FirstDayOfWeek = Day.Sunday;
66 Assert.AreEqual (Day.Sunday, myMonthCal1.FirstDayOfWeek, "#F2");
67 Assert.AreEqual ("WindowText", myMonthCal1.ForeColor.Name, "#F3");
70 Assert.AreEqual (new DateTime (9998,12,31), myMonthCal1.MaxDate, "#M1");
71 Assert.AreEqual (7, myMonthCal1.MaxSelectionCount, "#M2");
72 Assert.AreEqual (new DateTime (1753,1,1), myMonthCal1.MinDate, "#M3");
73 myMonthCal1.AddMonthlyBoldedDate (new DateTime (2005, 09, 01));
74 Assert.AreEqual (new DateTime(2005, 09, 01), myMonthCal1.MonthlyBoldedDates.GetValue (0), "#M4");
77 Assert.AreEqual (0, myMonthCal1.ScrollChange, "#S1");
78 myMonthCal1.SelectionStart = new DateTime (2005,09,02);
79 myMonthCal1.SelectionEnd = new DateTime (2005,09,03);
80 Assert.AreEqual (new DateTime (2005,09,03), myMonthCal1.SelectionEnd, "#S2");
81 //Assert.AreEqual (new SelectionRange (new DateTime(2005,09,02), new DateTime(2005,09,03)), myMonthCal1.SelectionRange, "#S3");
82 Assert.AreEqual (new DateTime (2005,09,02), myMonthCal1.SelectionStart, "#S4");
83 Assert.AreEqual (true, myMonthCal1.ShowToday, "#S5");
84 Assert.AreEqual (true, myMonthCal1.ShowTodayCircle, "#S6");
85 Assert.AreEqual (false, myMonthCal1.ShowWeekNumbers, "#S7");
86 Assert.AreEqual (153, myMonthCal1.SingleMonthSize.Height, "#S8a");
87 Assert.AreEqual (176, myMonthCal1.SingleMonthSize.Width, "#S8b");
88 Assert.AreEqual (null, myMonthCal1.Site, "#S9");
90 Assert.AreEqual ("ActiveCaption", myMonthCal1.TitleBackColor.Name, "#T1");
91 Assert.AreEqual ("ActiveCaptionText", myMonthCal1.TitleForeColor.Name, "#T2");
92 Assert.AreEqual (DateTime.Today, myMonthCal1.TodayDate, "#T3");
93 Assert.AreEqual (false, myMonthCal1.TodayDateSet, "#T4");
94 Assert.AreEqual ("GrayText", myMonthCal1.TrailingForeColor.Name, "#T5");
100 [ExpectedException (typeof (ArgumentException))]
101 public void MonthCalMaxSelectionCountException ()
103 MonthCalendar myMonthCal1 = new MonthCalendar ();
104 myMonthCal1.MaxSelectionCount = 0 ; // value is less than 1
108 [ExpectedException (typeof (ArgumentException))]
109 public void MonthCalMaxDateException ()
111 MonthCalendar myMonthCal1 = new MonthCalendar ();
112 myMonthCal1.MaxDate = new DateTime (1752, 1, 1, 0, 0, 0, 0); // value is less than min date (01/01/1753)
116 [ExpectedException (typeof (ArgumentException))]
117 public void MonthCalMinDateException ()
119 MonthCalendar myMonthCal1 = new MonthCalendar ();
120 myMonthCal1.MinDate = new DateTime(1752, 1, 1, 0, 0, 0, 0); // Date earlier than 01/01/1753
121 myMonthCal1.MinDate = new DateTime(9999, 12, 31, 0, 0, 0, 0); // Date greater than max date (01/01/1753)
125 [ExpectedException (typeof (ArgumentException))]
126 public void MonthCalSelectRangeException ()
128 MonthCalendar myMonthCal1 = new MonthCalendar ();
129 myMonthCal1.SelectionRange = new SelectionRange (new DateTime (1752, 01, 01), new DateTime (1752, 01, 02));
130 myMonthCal1.SelectionRange = new SelectionRange (new DateTime (9999, 12, 30), new DateTime (9999, 12, 31));
134 public void AddAnnuallyBoldedDateTest ()
136 Form myForm = new Form ();
137 myForm.ShowInTaskbar = false;
138 MonthCalendar myMonthCal = new MonthCalendar ();
139 myMonthCal.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
140 myForm.Controls.Add (myMonthCal);
141 Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal.AnnuallyBoldedDates.GetValue (0), "#add1");
146 public void AddBoldedDateTest ()
148 Form myForm = new Form ();
149 myForm.ShowInTaskbar = false;
150 MonthCalendar myMonthCal = new MonthCalendar ();
151 myMonthCal.AddBoldedDate (new DateTime (2005, 09, 02));
152 myForm.Controls.Add (myMonthCal);
153 Assert.AreEqual (new DateTime (2005, 09, 02), myMonthCal.BoldedDates.GetValue (0), "#add2");
158 public void AddMonthlyBoldedDateTest ()
160 Form myForm = new Form ();
161 myForm.ShowInTaskbar = false;
162 MonthCalendar myMonthCal = new MonthCalendar ();
163 myMonthCal.AddMonthlyBoldedDate (new DateTime (2005, 09, 03));
164 myForm.Controls.Add (myMonthCal);
165 Assert.AreEqual (new DateTime (2005, 09, 03), myMonthCal.MonthlyBoldedDates.GetValue (0), "#add2");
170 public void GetDispalyRangeTest ()
172 Form myForm = new Form ();
173 myForm.ShowInTaskbar = false;
174 MonthCalendar myMonthCal = new MonthCalendar ();
175 myForm.Controls.Add (myMonthCal);
176 SelectionRange mySelRange = new SelectionRange ();
177 mySelRange.Start = new DateTime (2005, 09, 01);
178 mySelRange.End = new DateTime (2005, 09, 30);
179 Assert.AreEqual (mySelRange.Start, myMonthCal.GetDisplayRange (true).Start, "#Get1");
180 Assert.AreEqual (mySelRange.End, myMonthCal.GetDisplayRange (true).End, "#Get22");
185 public void HitTest ()
187 Form myForm = new Form ();
188 myForm.ShowInTaskbar = false;
189 MonthCalendar myMonthCal = new MonthCalendar ();
190 myForm.Controls.Add (myMonthCal);
191 Assert.AreEqual (new DateTime (01, 01, 01), myMonthCal.HitTest(10, 10).Time, "#Hit1");