3 // Jonathan Pobst (monkey@jpobst.com)
5 // Copyright (C) 2009 Novell, Inc (http://www.novell.com)
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:
15 // The above copyright notice and this permission notice shall be
16 // included in all copies or substantial portions of the Software.
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.
27 using System.Windows.Forms.DataVisualization.Charting;
28 using NUnit.Framework;
30 namespace ChartingTests
33 public class DataPointTest
36 public void Constructor1 ()
38 DataPoint dp = new DataPoint ();
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");
47 public void Constructor2 ()
49 DataPoint dp = new DataPoint (1d, 2d);
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");
58 public void Constructor3 ()
60 DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
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");
69 public void IsEmptyProperty ()
71 DataPoint dp = new DataPoint (1d, 2d);
73 Assert.AreEqual (false, dp.IsEmpty, "A1");
74 Assert.AreEqual (1d, dp.XValue, "A2");
75 Assert.AreEqual (new double[] { 2d }, dp.YValues, "A3");
79 Assert.AreEqual (true, dp.IsEmpty, "A4");
80 Assert.AreEqual (1d, dp.XValue, "A5");
81 Assert.AreEqual (new double[] { 2d }, dp.YValues, "A6");
84 dp.YValues = new double[] { 7d };
86 Assert.AreEqual (true, dp.IsEmpty, "A7");
90 public void NameProperty ()
92 DataPoint dp = new DataPoint (1d, 2d);
93 Assert.AreEqual ("DataPoint", dp.Name, "A1");
96 Assert.AreEqual ("DataPoint", dp.Name, "A2");
100 public void XValueProperty ()
102 DataPoint dp = new DataPoint (1d, 2d);
103 Assert.AreEqual (1d, dp.XValue, "A1");
106 Assert.AreEqual (2d, dp.XValue, "A2");
110 public void YValueProperty ()
112 DataPoint dp = new DataPoint (1d, 2d);
113 Assert.AreEqual (new double[] { 2d }, dp.YValues, "A1");
115 dp.YValues = new double[] { 2d, 3d };
116 Assert.AreEqual (new double[] { 2d, 3d }, dp.YValues, "A2");
120 public void CloneMethod ()
122 DataPoint dp = new DataPoint ();
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");
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");
137 public void GetValueByNameMethod ()
139 DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
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");
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");
153 [ExpectedException (typeof (ArgumentException))]
154 public void GetValueByNameMethodAE ()
156 DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
158 Assert.AreEqual (1d, dp.GetValueByName ("X1"), "A1");
162 [ExpectedException (typeof (ArgumentException))]
163 public void GetValueByNameMethodAE2 ()
165 DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
167 Assert.AreEqual (1d, dp.GetValueByName ("Y4"), "A1");
171 [ExpectedException (typeof (ArgumentNullException))]
172 public void GetValueByNameMethodANE ()
174 DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
176 Assert.AreEqual (1d, dp.GetValueByName (null), "A1");
180 [ExpectedException (typeof (ArgumentException))]
181 public void GetValueByNameMethodAE3 ()
183 DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
185 Assert.AreEqual (1d, dp.GetValueByName (string.Empty), "A1");
189 [ExpectedException (typeof (ArgumentException))]
190 public void GetValueByNameMethodAE4 ()
192 DataPoint dp = new DataPoint (1d, new double[] { 2d, 3d });
194 Assert.AreEqual (1d, dp.GetValueByName ("Y0"), "A1");