[jit] Enable partial generic sharing when not using AOT as an experiment.
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / SelectionRangeTest.cs
1 //
2 // SelectionRangeTest.cs
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //
23 // Copyright (c) 2008 Andy Hume
24 //
25 // Authors:
26 //      Andy Hume  <andyhume32@yahoo.co.uk>
27
28 using System;
29 using System.Windows.Forms;
30 using NUnit.Framework;
31
32 namespace MonoTests.System.Windows.Forms
33 {
34         [TestFixture]
35         public class SelectionRangeTest : TestHelper
36         {
37
38                 [Test]
39                 public void DefaultConstructor ()
40                 {
41                         SelectionRange sr = new SelectionRange ();
42                         Assert.AreEqual (DateTime.MinValue, sr.Start, "Start");
43                         // "9999-12-31 00:00:00", note not 23:59:59.
44                         Assert.AreEqual (DateTime.MaxValue.Date, sr.End, "End");
45
46                         Assert.AreEqual (DateTimeKind.Unspecified, sr.Start.Kind, "Start Kind");
47                         Assert.AreEqual (DateTimeKind.Unspecified, sr.End.Kind, "End Kind");
48                 }
49
50                 [Test]
51                 public void DefaultConstructor_ToString ()
52                 {
53                         SelectionRange sr = new SelectionRange ();
54                         // "9999-12-31 00:00:00", note not 23:59:59.
55                         Assert.AreEqual (string.Format ("SelectionRange: Start: {0}, End: {1}", new DateTime (1, 1, 1).ToString (), new DateTime (9999, 12, 31).ToString ()),
56                            sr.ToString (), "ToString");
57                 }
58
59                 [Test]
60                 public void TwoDatesConstructor ()
61                 {
62                         SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11), new DateTime (2008, 2, 17));
63                         Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start");
64                         Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End");
65                 }
66
67                 [Test]
68                 public void TwoDatesConstructor_Backwards () // start > end
69                 {
70                         SelectionRange sr = new SelectionRange (new DateTime (2008, 2, 17), new DateTime (2001, 1, 11));
71                         Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start");
72                         Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End");
73                 }
74
75                 [Test]
76                 public void TwoDatesConstructor_WithTime ()
77                 {
78                         // Apparenly any time value is stripped, found while testing PropertyGrid.
79                         SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11, 13, 14, 15), new DateTime (2008, 2, 17));
80                         Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start");
81                         Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End");
82                 }
83
84                 [Test]
85                 public void TwoDatesConstructor_WithTime2 ()
86                 {
87                         // Apparenly any time value is stripped, found while testing PropertyGrid.
88                         SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11), new DateTime (2008, 2, 17, 1, 2, 3));
89                         Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start");
90                         Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End");
91                         Assert.AreEqual (DateTimeKind.Unspecified, sr.Start.Kind, "Start Kind");
92                         Assert.AreEqual (DateTimeKind.Unspecified, sr.End.Kind, "End Kind");
93                 }
94
95                 [Test]
96                 public void TwoDatesConstructor_WithTimeWithKindLocal ()
97                 {
98                         // Apparenly any time value is stripped, found while testing PropertyGrid.
99                         SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11, 13, 14, 15, DateTimeKind.Local), new DateTime (2008, 2, 17));
100                         Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start");
101                         Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End");
102                         //
103                         Assert.AreEqual (DateTimeKind.Local, sr.Start.Kind, "Start Kind");
104                         Assert.AreEqual (DateTimeKind.Unspecified, sr.End.Kind, "End Kind");
105                 }
106
107                 [Test]
108                 public void TwoDatesConstructor_WithTime2WithKindUtc ()
109                 {
110                         // Apparenly any time value is stripped, found while testing PropertyGrid.
111                         SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11), new DateTime (2008, 2, 17, 1, 2, 3, DateTimeKind.Utc));
112                         Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start");
113                         Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End");
114                         //
115                         Assert.AreEqual (DateTimeKind.Unspecified, sr.Start.Kind, "Start Kind");
116                         Assert.AreEqual (DateTimeKind.Utc, sr.End.Kind, "End Kind");
117                 }
118
119                 [Test]
120                 public void TwoDatesConstructor_WithTwoTimeWithTwoKinds ()
121                 {
122                         // Apparenly any time value is stripped, found while testing PropertyGrid.
123                         SelectionRange sr = new SelectionRange (
124                             new DateTime (2001, 1, 11, 1, 2, 3, DateTimeKind.Utc),
125                             new DateTime (2008, 2, 17, 1, 2, 3, DateTimeKind.Local));
126                         Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start");
127                         Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End");
128                         //
129                         Assert.AreEqual (DateTimeKind.Utc, sr.Start.Kind, "Start Kind");
130                         Assert.AreEqual (DateTimeKind.Local, sr.End.Kind, "End Kind");
131                 }
132
133         }
134 }