Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1041 was 1040, checked in by mstoeger, 16 years ago

Added test for AutoZoom function. It currently doesn't work when data was already available in the model before the view was created. (#345)

File size: 2.4 KB
Line 
1using System;
2using System.Drawing;
3using NUnit.Framework;
4
5namespace HeuristicLab.Visualization.Test {
6  [TestFixture]
7  public class LineChartTests {
8    private ChartDataRowsModel model;
9
10    [SetUp]
11    public void SetUp() {
12      model = new ChartDataRowsModel();
13    }
14
15    [Test]
16    public void TestLineChart() {
17      LineChartTestForm f = new LineChartTestForm(model);
18
19      IDataRow row1 = new DataRow();
20      IDataRow row2 = new DataRow();
21      IDataRow row3 = new DataRow();
22
23      row1.Color = Color.Red;
24      row2.Color = Color.Green;
25      row3.Color = Color.Blue;
26
27      row1.Thickness = 3;
28      row2.Thickness = 4;
29      row3.Thickness = 5;
30
31      row1.Style = DrawingStyle.Solid;
32      row2.Style = DrawingStyle.Solid;
33      row3.Style = DrawingStyle.Dashed;
34     
35
36      model.AddDataRow(row1);
37      model.AddDataRow(row2);
38      model.AddDataRow(row3);
39
40      row1.AddValue(10);
41      row1.AddValue(5);
42      row1.AddValue(7);
43      row1.AddValue(3);
44      row1.AddValue(10);
45      row1.AddValue(2);
46
47      row2.AddValue(5);
48      row2.AddValue(6);
49      row2.AddValue(5);
50
51      row3.AddValue(2);
52      row3.AddValue(2);
53      row3.AddValue(2);
54      row3.AddValue(2);
55      row3.AddValue(2);
56
57      Random rand = new Random();
58
59      for (int i = 0; i < 10000; i++) {
60        row1.AddValue(rand.NextDouble()*10);
61        row2.AddValue(rand.NextDouble()*10);
62        row3.AddValue(rand.NextDouble()*10);
63      }
64
65      f.ShowDialog();
66    }
67
68    [Test]
69    public void TestAxes() {
70      LineChartTestForm f = new LineChartTestForm(model);
71
72      IDataRow row1 = new DataRow();
73
74      row1.Color = Color.Red;
75      row1.Thickness = 3;
76      row1.Style = DrawingStyle.Solid;
77
78      model.AddDataRow(row1);
79
80      row1.AddValue(10);
81      row1.AddValue(5);
82      row1.AddValue(7);
83      row1.AddValue(3);
84      row1.AddValue(10);
85      row1.AddValue(2);
86
87      f.ShowDialog();
88    }
89
90    [Test]
91    public void TestAutoZoomInConstructor() {
92      IDataRow row1 = new DataRow();
93
94      row1.Color = Color.Red;
95      row1.Thickness = 3;
96      row1.Style = DrawingStyle.Solid;
97
98      model.AddDataRow(row1);
99
100      row1.AddValue(10);
101      row1.AddValue(5);
102      row1.AddValue(7);
103      row1.AddValue(3);
104      row1.AddValue(10);
105      row1.AddValue(2);
106
107      LineChartTestForm f = new LineChartTestForm(model);
108      f.ShowDialog();
109    }
110  }
111}
Note: See TracBrowser for help on using the repository browser.