New test.
[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.System.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                         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 ();
32                         
33                         // A
34                         myMonthCal1.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
35                         Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.AnnuallyBoldedDates.GetValue (0), "#A1");
36                      
37                         // B 
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");
41                                 
42                         // C
43                         Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Height, "#C1");
44                         Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Width, "#C2");
45                         Assert.AreEqual (false, myMonthCal1.CalendarDimensions.IsEmpty, "#C3");
46
47                         // F
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");
52
53                         // M 
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");
59                         
60                         // S 
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");
73                         // T
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");
79
80                         myfrm.Dispose ();
81                 }
82         
83                 [Test]          
84                 [ExpectedException (typeof (ArgumentException))]
85                 public void MonthCalMaxSelectionCountException ()
86                 {
87                         MonthCalendar myMonthCal1 = new MonthCalendar ();
88                         myMonthCal1.MaxSelectionCount = 0 ; // value is less than 1
89                 }
90
91                 [Test]          
92                 [ExpectedException (typeof (ArgumentException))]
93                 public void MonthCalMaxDateException ()
94                 {
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)
97                 }
98
99                 [Test]          
100                 [ExpectedException (typeof (ArgumentException))]
101                 public void MonthCalMinDateException ()
102                 {
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)
106                 }
107
108                 [Test]          
109                 [ExpectedException (typeof (ArgumentException))]
110                 public void MonthCalSelectRangeException ()
111                 {
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));
115                 }
116                 
117                 [Test]
118                 public void AddAnnuallyBoldedDateTest ()
119                 {
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");
126                         myForm.Dispose ();
127                 }
128
129                 [Test]
130                 public void AddBoldedDateTest ()
131                 {
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");
138                         myForm.Dispose ();
139                 }
140
141                 [Test]
142                 public void AddMonthlyBoldedDateTest ()
143                 {
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");
150                         myForm.Dispose ();
151                 }
152                 
153                 [Test]
154                 public void GetDispalyRangeTest ()
155                 {
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");
165                         myForm.Dispose ();
166                 }
167                 
168                 [Test]
169                 public void HitTest ()
170                 {
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");
176                 }
177         }
178 }