New test.
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / SelectedDatesCollectionTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.SelectedDatesCollection.cs
3 //
4 // Author:
5 //      Jordi Mas i Hernandez (jordi@ximian.com)
6 //
7
8 //
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System.Web.UI.WebControls;
32 using NUnit.Framework;
33 using System;
34 using System.Collections;
35 using System.Web;
36 using System.Web.UI;
37 using System.Globalization;
38         
39
40 namespace MonoTests.System.Web.UI.WebControls
41 {
42         [TestFixture]
43         public class SelectedDatesCollectionTest {
44
45
46                 [Test]
47                 public void SelectedDatesCollectionTest_DefaultValues ()
48                 {
49                         ArrayList list = new ArrayList ();
50                         SelectedDatesCollection s = new SelectedDatesCollection (list);                 
51
52                         Assert.AreEqual (0, s.Count, "A1");
53                         Assert.AreEqual (false, s.IsReadOnly, "A2");
54                         Assert.AreEqual (false, s.IsSynchronized, "A3");
55                         Assert.AreEqual (s, s.SyncRoot, "A4");
56                 }
57
58
59                 //
60                 // Methods
61                 //
62                 [Test]
63                 public void AddMethod ()
64                 {
65                         ArrayList list = new ArrayList ();
66                         SelectedDatesCollection s = new SelectedDatesCollection (list);                 
67                         
68                         s.Add (DateTime.Today);
69                         Assert.AreEqual (true, s.Contains (DateTime.Today), "A1");
70                         Assert.AreEqual (1, s.Count, "A2");
71                         
72                         s.Add (DateTime.Today); // Duplicates are not inserted
73                         Assert.AreEqual (1, s.Count, "A2");
74                 }
75
76                 //
77                 // Methods
78                 //
79                 [Test]
80                 public void ClearMethod ()
81                 {
82                         ArrayList list = new ArrayList ();
83                         SelectedDatesCollection s = new SelectedDatesCollection (list);                 
84                         
85                         s.Add (DateTime.Today);
86                         s.Clear ();
87                         Assert.AreEqual (0, s.Count, "A1");
88                 }
89
90
91                 [Test]
92                 public void SelectRangeMethod ()
93                 {
94                         ArrayList list = new ArrayList ();
95                         SelectedDatesCollection s = new SelectedDatesCollection (list);                 
96                         
97                         s.Add (DateTime.Today);
98                         s.Add (DateTime.Today);
99                         // Internally clears the list
100                         s.SelectRange (new DateTime (2000, 1, 1), new DateTime (2001, 1, 1));
101
102                         Assert.AreEqual (367, s.Count, "A1");
103                 }
104
105                 [Test]
106                 public void RemoveMethod ()
107                 {
108                         ArrayList list = new ArrayList ();
109                         SelectedDatesCollection s = new SelectedDatesCollection (list);                 
110                         
111                         s.Add (DateTime.Today);
112                         s.Remove (DateTime.Today);
113                         Assert.AreEqual (0, s.Count, "A1");
114                 }
115
116         }
117 }
118
119
120