svn path=/branches/mono-1-1-9/mcs/; revision=50439
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / MonthCalendarTest.cs
1 //
2 // MonthCalendarTest.cs: Test case for MonthCalendar
3 // 
4 // Authors:
5 //   Ritvik Mayank (mritvik@novell.com)
6 //
7 // (C) 2005 Novell, Inc. (http://www.novell.com)
8 //
9
10 using System;
11 using System.Windows.Forms;
12 using System.Drawing;
13 using System.Reflection;
14 using NUnit.Framework;
15
16 namespace MonoTests.Syetem.Windows.Forms
17 {
18         [TestFixture]
19         [Ignore ("This test has to be completly reviewed")]     
20         public class MonthCalendarTest
21         {
22                 [Test]
23                 public void MonthCalendarPropertyTest ()
24                 {
25                         Form myfrm = new Form ();
26                         MonthCalendar myMonthCal1 = new MonthCalendar ();
27                         MonthCalendar myMonthCal2 = new MonthCalendar ();
28                         myMonthCal1.Name = "MonthCendar";
29                         myMonthCal1.TabIndex = 1;
30                         DateTime myDateTime = new DateTime ();
31                         
32                         // A
33                         myMonthCal1.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
34                         Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.AnnuallyBoldedDates.GetValue (0), "#A1");
35                      
36                         // B 
37                         Assert.AreEqual ("Window", myMonthCal1.BackColor.Name, "#B1");
38                         myMonthCal1.AddBoldedDate (new DateTime (2005, 09, 01));
39                         Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.BoldedDates.GetValue (0), "#B2");
40                                 
41                         // C
42                         Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Height, "#C1");
43                         Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Width, "#C2");
44                         Assert.AreEqual (false, myMonthCal1.CalendarDimensions.IsEmpty, "#C3");
45
46                         // F
47                         Assert.AreEqual (Day.Default, myMonthCal1.FirstDayOfWeek, "#F1");
48                         myMonthCal1.FirstDayOfWeek = Day.Sunday;
49                         Assert.AreEqual (Day.Sunday, myMonthCal1.FirstDayOfWeek, "#F2");
50                         Assert.AreEqual ("WindowText", myMonthCal1.ForeColor.Name, "#F3");
51
52                         // M 
53                         Assert.AreEqual (new DateTime (9998,12,31), myMonthCal1.MaxDate, "#M1");
54                         Assert.AreEqual (7, myMonthCal1.MaxSelectionCount, "#M2");
55                         Assert.AreEqual (new DateTime (1753,1,1), myMonthCal1.MinDate, "#M3");
56                         myMonthCal1.AddMonthlyBoldedDate (new DateTime (2005, 09, 01));
57                         Assert.AreEqual (new DateTime(2005, 09, 01), myMonthCal1.MonthlyBoldedDates.GetValue (0), "#M4");
58                         
59                         // S 
60                         Assert.AreEqual (0, myMonthCal1.ScrollChange, "#S1");
61                         myMonthCal1.SelectionStart = new DateTime (2005,09,02);
62                         myMonthCal1.SelectionEnd = new DateTime (2005,09,03);
63                         Assert.AreEqual (new DateTime (2005,09,03), myMonthCal1.SelectionEnd, "#S2");
64                         //Assert.AreEqual (new SelectionRange (new DateTime(2005,09,02), new DateTime(2005,09,03)), myMonthCal1.SelectionRange, "#S3");
65                         Assert.AreEqual (new DateTime (2005,09,02), myMonthCal1.SelectionStart, "#S4");
66                         Assert.AreEqual (true, myMonthCal1.ShowToday, "#S5");
67                         Assert.AreEqual (true, myMonthCal1.ShowTodayCircle, "#S6");
68                         Assert.AreEqual (false, myMonthCal1.ShowWeekNumbers, "#S7");
69                         Assert.AreEqual (153, myMonthCal1.SingleMonthSize.Height, "#S8a");
70                         Assert.AreEqual (176, myMonthCal1.SingleMonthSize.Width, "#S8b");
71                         Assert.AreEqual (null, myMonthCal1.Site, "#S9");
72                         // T
73                         Assert.AreEqual ("ActiveCaption", myMonthCal1.TitleBackColor.Name, "#T1");
74                         Assert.AreEqual ("ActiveCaptionText", myMonthCal1.TitleForeColor.Name, "#T2");
75                         Assert.AreEqual (DateTime.Today, myMonthCal1.TodayDate, "#T3");
76                         Assert.AreEqual (false, myMonthCal1.TodayDateSet, "#T4");
77                         Assert.AreEqual ("GrayText", myMonthCal1.TrailingForeColor.Name, "#T5");
78                 }
79         
80                 [Test]          
81                 [ExpectedException (typeof (ArgumentException))]
82                 public void MonthCalMaxSelectionCountException ()
83                 {
84                         MonthCalendar myMonthCal1 = new MonthCalendar ();
85                         myMonthCal1.MaxSelectionCount = 0 ; // value is less than 1
86                 }
87
88                 [Test]          
89                 [ExpectedException (typeof (ArgumentException))]
90                 public void MonthCalMaxDateException ()
91                 {
92                         MonthCalendar myMonthCal1 = new MonthCalendar ();
93                         myMonthCal1.MaxDate = new DateTime (1752, 1, 1, 0, 0, 0, 0); // value is less than min date (01/01/1753)
94                 }
95
96                 [Test]          
97                 [ExpectedException (typeof (ArgumentException))]
98                 public void MonthCalMinDateException ()
99                 {
100                         MonthCalendar myMonthCal1 = new MonthCalendar ();
101                         myMonthCal1.MinDate = new DateTime(1752, 1, 1, 0, 0, 0, 0); // Date earlier than 01/01/1753
102                         myMonthCal1.MinDate = new DateTime(9999, 12, 31, 0, 0, 0, 0); // Date greater than max date (01/01/1753)
103                 }
104
105                 [Test]          
106                 [ExpectedException (typeof (ArgumentException))]
107                 public void MonthCalSelectRangeException ()
108                 {
109                         MonthCalendar myMonthCal1 = new MonthCalendar ();
110                         myMonthCal1.SelectionRange = new SelectionRange (new DateTime (1752, 01, 01), new DateTime (1752, 01, 02));
111                         myMonthCal1.SelectionRange = new SelectionRange (new DateTime (9999, 12, 30), new DateTime (9999, 12, 31));
112                 }
113                 
114                 [Test]
115                 public void AddAnnuallyBoldedDateTest ()
116                 {
117                         Form myForm = new Form ();
118                         MonthCalendar myMonthCal = new MonthCalendar ();
119                         myMonthCal.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
120                         myForm.Controls.Add (myMonthCal);
121                         Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal.AnnuallyBoldedDates.GetValue (0), "#add1");
122                 }
123
124                 [Test]
125                 public void AddBoldedDateTest ()
126                 {
127                         Form myForm = new Form ();
128                         MonthCalendar myMonthCal = new MonthCalendar ();
129                         myMonthCal.AddBoldedDate (new DateTime (2005, 09, 02));
130                         myForm.Controls.Add (myMonthCal);
131                         Assert.AreEqual (new DateTime (2005, 09, 02), myMonthCal.BoldedDates.GetValue (0), "#add2");
132                 }
133
134                 [Test]
135                 public void AddMonthlyBoldedDateTest ()
136                 {
137                         Form myForm = new Form ();
138                         MonthCalendar myMonthCal = new MonthCalendar ();
139                         myMonthCal.AddMonthlyBoldedDate (new DateTime (2005, 09, 03));
140                         myForm.Controls.Add (myMonthCal);
141                         Assert.AreEqual (new DateTime (2005, 09, 03), myMonthCal.MonthlyBoldedDates.GetValue (0), "#add2");
142                 }
143                 
144                 [Test]
145                 public void GetDispalyRangeTest ()
146                 {
147                         Form myForm = new Form ();
148                         MonthCalendar myMonthCal = new MonthCalendar ();
149                         myForm.Controls.Add (myMonthCal);
150                         SelectionRange mySelRange = new SelectionRange ();
151                         mySelRange.Start = new DateTime (2005, 09, 01); 
152                         mySelRange.End = new DateTime (2005, 09, 30);
153                         Assert.AreEqual (mySelRange.Start, myMonthCal.GetDisplayRange (true).Start, "#Get1");
154                         Assert.AreEqual (mySelRange.End, myMonthCal.GetDisplayRange (true).End, "#Get22");
155                 }
156                 
157                 [Test]
158                 public void HitTest ()
159                 {
160                         Form myForm = new Form ();
161                         MonthCalendar myMonthCal = new MonthCalendar ();
162                         myForm.Controls.Add (myMonthCal);
163                         Assert.AreEqual (new DateTime (01, 01, 01), myMonthCal.HitTest(10, 10).Time, "#Hit1");
164                 }
165         }
166 }