Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs @ 1307

Last change on this file since 1307 was 1285, checked in by mstoeger, 16 years ago

Implemented multiple Y-Axes. (#433) Panning & Zooming is broken.

File size: 3.9 KB
RevLine 
[983]1using System;
[869]2using System.Drawing;
[861]3using NUnit.Framework;
4
5namespace HeuristicLab.Visualization.Test {
6  [TestFixture]
7  public class LineChartTests {
[1038]8    private ChartDataRowsModel model;
9
10    [SetUp]
11    public void SetUp() {
12      model = new ChartDataRowsModel();
13    }
14
[861]15    [Test]
16    public void TestLineChart() {
[1038]17      LineChartTestForm f = new LineChartTestForm(model);
[861]18
[869]19      IDataRow row1 = new DataRow();
20      IDataRow row2 = new DataRow();
21      IDataRow row3 = new DataRow();
[861]22
[869]23      row1.Color = Color.Red;
24      row2.Color = Color.Green;
25      row3.Color = Color.Blue;
[861]26
[869]27      row1.Thickness = 3;
28      row2.Thickness = 4;
29      row3.Thickness = 5;
30
[1049]31      row1.Label = "Simon";
32      row2.Label = "Gertschi";
33      row3.Label = "Maxi";
34
[980]35      row1.Style = DrawingStyle.Solid;
36      row2.Style = DrawingStyle.Solid;
37      row3.Style = DrawingStyle.Dashed;
38     
39
[1038]40      model.AddDataRow(row1);
41      model.AddDataRow(row2);
42      model.AddDataRow(row3);
[869]43
44      row1.AddValue(10);
45      row1.AddValue(5);
46      row1.AddValue(7);
47      row1.AddValue(3);
48      row1.AddValue(10);
49      row1.AddValue(2);
50
51      row2.AddValue(5);
52      row2.AddValue(6);
53      row2.AddValue(5);
54
55      row3.AddValue(2);
56      row3.AddValue(2);
57      row3.AddValue(2);
58      row3.AddValue(2);
59      row3.AddValue(2);
60
[983]61      Random rand = new Random();
62
[1038]63      for (int i = 0; i < 10000; i++) {
[983]64        row1.AddValue(rand.NextDouble()*10);
65        row2.AddValue(rand.NextDouble()*10);
66        row3.AddValue(rand.NextDouble()*10);
67      }
68
[861]69      f.ShowDialog();
70    }
[983]71
72    [Test]
73    public void TestAxes() {
[1038]74      LineChartTestForm f = new LineChartTestForm(model);
[983]75
76      IDataRow row1 = new DataRow();
[1285]77      IDataRow row2 = new DataRow();
[983]78
79      row1.Color = Color.Red;
80      row1.Thickness = 3;
81      row1.Style = DrawingStyle.Solid;
82
[1285]83      row2.Color = Color.Green;
84      row2.Thickness = 3;
85      row2.Style = DrawingStyle.Solid;
86
[1038]87      model.AddDataRow(row1);
[1285]88      model.AddDataRow(row2);
[983]89
[1285]90      Random rand = new Random(42);
91     
92      for (int i = 0; i < 10; i++) {
93        row1.AddValue(rand.NextDouble()*10);
94        row2.AddValue(rand.NextDouble()*10);
95      }
[983]96
97      f.ShowDialog();
98    }
[1040]99
100    [Test]
101    public void TestAutoZoomInConstructor() {
102      IDataRow row1 = new DataRow();
103
104      row1.Color = Color.Red;
105      row1.Thickness = 3;
106      row1.Style = DrawingStyle.Solid;
107
108      model.AddDataRow(row1);
109
110      row1.AddValue(10);
111      row1.AddValue(5);
112      row1.AddValue(7);
113      row1.AddValue(3);
114      row1.AddValue(10);
115      row1.AddValue(2);
116
117      LineChartTestForm f = new LineChartTestForm(model);
118      f.ShowDialog();
119    }
[1240]120
[1243]121
[1240]122    [Test]
[1243]123    public void TestSingleValueDataRows() {
124      LineChartTestForm f = new LineChartTestForm(model);
125
126      IDataRow row1 = new DataRow();
127      IDataRow row2 = new DataRow();
128      IDataRow row3 = new DataRow();
129
130      row1.Color = Color.Red;
131      row2.Color = Color.Green;
132      row3.Color = Color.Blue;
133
134      row1.Thickness = 3;
135      row2.Thickness = 4;
136      row3.Thickness = 5;
137
138      row1.Label = "SingleValue";
139      row2.Label = "Gertschi";
140      row3.Label = "Maxi";
141
142      row1.Style = DrawingStyle.Solid;
143      row2.Style = DrawingStyle.Solid;
144      row3.Style = DrawingStyle.Dashed;
145
146      row1.LineType = DataRowType.SingleValue;
147      row2.LineType = DataRowType.SingleValue;
148      row1.AddValue(12);
149
150      model.AddDataRow(row1);
151      model.AddDataRow(row2);
152      model.AddDataRow(row3);
153
154     
155     
156      row2.AddValue(5);
157     
158
159      row3.AddValue(2);
160      row3.AddValue(5);
161      row3.AddValue(9);
162      row3.AddValue(1);
163      row3.AddValue(3);
164
165
166   
167
168      f.ShowDialog();
169    }
170
171
172
173    [Test]
[1240]174    public void TestMainForm() {
175      MainForm f = new MainForm();
176      f.ShowDialog();
177    }
[861]178  }
[1243]179}
Note: See TracBrowser for help on using the repository browser.