Added time format with only offset. Fixes #22558.
[mono.git] / mcs / class / System.Windows.Forms.DataVisualization / Test / System.Windows.Forms.DataVisualization.Charting / DataPointTest.cs
1 //
2 // Authors:
3 // Jonathan Pobst (monkey@jpobst.com)
4 //
5 // Copyright (C) 2009 Novell, Inc (http://www.novell.com) 
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining
8 // a copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
14 // 
15 // The above copyright notice and this permission notice shall be
16 // included in all copies or substantial portions of the Software.
17 // 
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 using System;
27 using System.Windows.Forms.DataVisualization.Charting;
28 using NUnit.Framework;
29
30 namespace ChartingTests
31 {
32         [TestFixture]
33         public class DataPointTest
34         {
35                 [Test]
36                 public void Constructor1 ()
37                 {
38                         DataPoint dp = new DataPoint ();
39
40                         Assert.AreEqual (false, dp.IsEmpty, "A1");
41                         Assert.AreEqual ("DataPoint", dp.Name, "A2");
42                         Assert.AreEqual (0, dp.XValue, "A3");
43                         Assert.AreEqual (new double[] { 0.0d }, dp.YValues, "A4");
44                 }
45
46                 [Test]
47                 public void Constructor2 ()
48                 {
49                         DataPoint dp = new DataPoint (1d, 2d);
50
51                         Assert.AreEqual (false, dp.IsEmpty, "A1");
52                         Assert.AreEqual ("DataPoint", dp.Name, "A2");
53                         Assert.AreEqual (1d, dp.XValue, "A3");
54                         Assert.AreEqual (new double[] { 2d }, dp.YValues, "A4");
55                 }
56
57                 [Test]
58                 public void Constructor3 ()
59                 {
60                         DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
61
62                         Assert.AreEqual (false, dp.IsEmpty, "A1");
63                         Assert.AreEqual ("DataPoint", dp.Name, "A2");
64                         Assert.AreEqual (1d, dp.XValue, "A3");
65                         Assert.AreEqual (new double[] { 2d, 3d }, dp.YValues, "A4");
66                 }
67
68                 [Test]
69                 public void IsEmptyProperty ()
70                 {
71                         DataPoint dp = new DataPoint (1d, 2d);
72
73                         Assert.AreEqual (false, dp.IsEmpty, "A1");
74                         Assert.AreEqual (1d, dp.XValue, "A2");
75                         Assert.AreEqual (new double[] { 2d }, dp.YValues, "A3");
76
77                         dp.IsEmpty = true;
78
79                         Assert.AreEqual (true, dp.IsEmpty, "A4");
80                         Assert.AreEqual (1d, dp.XValue, "A5");
81                         Assert.AreEqual (new double[] { 2d }, dp.YValues, "A6");
82
83                         dp.XValue = 6d;
84                         dp.YValues = new double[] { 7d };
85
86                         Assert.AreEqual (true, dp.IsEmpty, "A7");
87                 }
88
89                 [Test]
90                 public void NameProperty ()
91                 {
92                         DataPoint dp = new DataPoint (1d, 2d);
93                         Assert.AreEqual ("DataPoint", dp.Name, "A1");
94
95                         dp.Name = "Point";
96                         Assert.AreEqual ("DataPoint", dp.Name, "A2");
97                 }
98
99                 [Test]
100                 public void XValueProperty ()
101                 {
102                         DataPoint dp = new DataPoint (1d, 2d);
103                         Assert.AreEqual (1d, dp.XValue, "A1");
104
105                         dp.XValue = 2d;
106                         Assert.AreEqual (2d, dp.XValue, "A2");
107                 }
108
109                 [Test]
110                 public void YValueProperty ()
111                 {
112                         DataPoint dp = new DataPoint (1d, 2d);
113                         Assert.AreEqual (new double[] { 2d }, dp.YValues, "A1");
114
115                         dp.YValues = new double[] { 2d, 3d };
116                         Assert.AreEqual (new double[] { 2d, 3d }, dp.YValues, "A2");
117                 }
118
119                 [Test]
120                 public void CloneMethod ()
121                 {
122                         DataPoint dp = new DataPoint ();
123
124                         Assert.AreEqual (false, dp.IsEmpty, "A1");
125                         Assert.AreEqual ("DataPoint", dp.Name, "A2");
126                         Assert.AreEqual (0, dp.XValue, "A3");
127                         Assert.AreEqual (new double[] { 0.0d }, dp.YValues, "A4");
128
129                         DataPoint dp2 = (DataPoint)dp.Clone ();
130                         Assert.AreEqual (false, dp2.IsEmpty, "A5");
131                         Assert.AreEqual ("DataPoint", dp2.Name, "A6");
132                         Assert.AreEqual (0, dp2.XValue, "A7");
133                         Assert.AreEqual (new double[] { 0.0d }, dp2.YValues, "A8");
134                 }
135
136                 [Test]
137                 public void GetValueByNameMethod ()
138                 {
139                         DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
140
141                         Assert.AreEqual (1d, dp.GetValueByName ("X"), "A1");
142                         Assert.AreEqual (2d, dp.GetValueByName ("Y"), "A2");
143                         Assert.AreEqual (2d, dp.GetValueByName ("Y1"), "A3");
144                         Assert.AreEqual (3d, dp.GetValueByName ("Y2"), "A4");
145
146                         Assert.AreEqual (1d, dp.GetValueByName ("x"), "A5");
147                         Assert.AreEqual (2d, dp.GetValueByName ("y"), "A6");
148                         Assert.AreEqual (2d, dp.GetValueByName ("y1"), "A7");
149                         Assert.AreEqual (3d, dp.GetValueByName ("y2"), "A8");
150                 }
151
152                 [Test]
153                 [ExpectedException (typeof (ArgumentException))]
154                 public void GetValueByNameMethodAE ()
155                 {
156                         DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
157
158                         Assert.AreEqual (1d, dp.GetValueByName ("X1"), "A1");
159                 }
160
161                 [Test]
162                 [ExpectedException (typeof (ArgumentException))]
163                 public void GetValueByNameMethodAE2 ()
164                 {
165                         DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
166
167                         Assert.AreEqual (1d, dp.GetValueByName ("Y4"), "A1");
168                 }
169
170                 [Test]
171                 [ExpectedException (typeof (ArgumentNullException))]
172                 public void GetValueByNameMethodANE ()
173                 {
174                         DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
175
176                         Assert.AreEqual (1d, dp.GetValueByName (null), "A1");
177                 }
178
179                 [Test]
180                 [ExpectedException (typeof (ArgumentException))]
181                 public void GetValueByNameMethodAE3 ()
182                 {
183                         DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
184
185                         Assert.AreEqual (1d, dp.GetValueByName (string.Empty), "A1");
186                 }
187
188                 [Test]
189                 [ExpectedException (typeof (ArgumentException))]
190                 public void GetValueByNameMethodAE4 ()
191                 {
192                         DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
193
194                         Assert.AreEqual (1d, dp.GetValueByName ("Y0"), "A1");
195                 }
196         }
197 }