2006-12-19 Daniel Nauck <dna@mono-project.de>
[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         public class MonthCalendarPropertiesTest : MonthCalendar
20         {
21                 [Test]
22                 public void Tester ()
23                 {
24                 }
25 #if NET_2_0
26                 [Test]
27                 public void DefaultMarginTest ()
28                 {
29                         Assert.AreEqual (DefaultMargin.All, 9, "#01");
30                 }
31 #endif
32         }
33
34         [TestFixture]
35         [Ignore ("This test has to be completly reviewed")]     
36         public class MonthCalendarTest
37         {
38                 [Test]
39                 public void MonthCalendarPropertyTest ()
40                 {
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 ();
48                         
49                         // A
50                         myMonthCal1.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
51                         Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.AnnuallyBoldedDates.GetValue (0), "#A1");
52                      
53                         // B 
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");
57                                 
58                         // C
59                         Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Height, "#C1");
60                         Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Width, "#C2");
61                         Assert.AreEqual (false, myMonthCal1.CalendarDimensions.IsEmpty, "#C3");
62
63                         // F
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");
68
69                         // M 
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");
75                         
76                         // S 
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");
89                         // T
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");
95
96                         myfrm.Dispose ();
97                 }
98         
99                 [Test]          
100                 [ExpectedException (typeof (ArgumentException))]
101                 public void MonthCalMaxSelectionCountException ()
102                 {
103                         MonthCalendar myMonthCal1 = new MonthCalendar ();
104                         myMonthCal1.MaxSelectionCount = 0 ; // value is less than 1
105                 }
106
107                 [Test]          
108                 [ExpectedException (typeof (ArgumentException))]
109                 public void MonthCalMaxDateException ()
110                 {
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)
113                 }
114
115                 [Test]          
116                 [ExpectedException (typeof (ArgumentException))]
117                 public void MonthCalMinDateException ()
118                 {
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)
122                 }
123
124                 [Test]          
125                 [ExpectedException (typeof (ArgumentException))]
126                 public void MonthCalSelectRangeException ()
127                 {
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));
131                 }
132                 
133                 [Test]
134                 public void AddAnnuallyBoldedDateTest ()
135                 {
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");
142                         myForm.Dispose ();
143                 }
144
145                 [Test]
146                 public void AddBoldedDateTest ()
147                 {
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");
154                         myForm.Dispose ();
155                 }
156
157                 [Test]
158                 public void AddMonthlyBoldedDateTest ()
159                 {
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");
166                         myForm.Dispose ();
167                 }
168                 
169                 [Test]
170                 public void GetDispalyRangeTest ()
171                 {
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");
181                         myForm.Dispose ();
182                 }
183                 
184                 [Test]
185                 public void HitTest ()
186                 {
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");
192                 }
193         }
194 }