Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Operator Architecture Refactoring/HeuristicLab.Visualization.Test/3.2/LineChartTests.cs @ 2111

Last change on this file since 2111 was 1987, checked in by mstoeger, 16 years ago

more "zoom level too high" fixes. the error also occured for empty charts and for empty data rows. #498

File size: 25.1 KB
Line 
1using System;
2using System.Drawing;
3using System.Threading;
4using NUnit.Framework;
5
6namespace HeuristicLab.Visualization.Test {
7  [TestFixture]
8  public class LineChartTests {
9    private ChartDataRowsModel model;
10
11    [SetUp]
12    public void SetUp() {
13      model = new ChartDataRowsModel();
14    }
15
16    [Test]
17    public void TestLineChartWithManyDataPoints() {
18      LineChartTestForm f = new LineChartTestForm(model);
19
20      IDataRow row1 = new DataRow();
21      IDataRow row2 = new DataRow();
22      IDataRow row3 = new DataRow();
23
24      row1.RowSettings.Color = Color.Red;
25      row2.RowSettings.Color = Color.Green;
26      row3.RowSettings.Color = Color.Blue;
27
28      row1.RowSettings.Thickness = 3;
29      row2.RowSettings.Thickness = 4;
30      row3.RowSettings.Thickness = 5;
31
32      row1.RowSettings.Label = "Simon";
33      row2.RowSettings.Label = "Gertschi";
34      row3.RowSettings.Label = "Maxi";
35
36      row1.RowSettings.Style = DrawingStyle.Solid;
37      row2.RowSettings.Style = DrawingStyle.Solid;
38      row3.RowSettings.Style = DrawingStyle.Dashed;
39
40
41      model.AddDataRow(row1);
42      model.AddDataRow(row2);
43      model.AddDataRow(row3);
44
45      row1.AddValue(10);
46      row1.AddValue(5);
47      row1.AddValue(7);
48      row1.AddValue(3);
49      row1.AddValue(10);
50      row1.AddValue(2);
51
52      row2.AddValue(5);
53      row2.AddValue(6);
54      row2.AddValue(5);
55
56      row3.AddValue(2);
57      row3.AddValue(2);
58      row3.AddValue(2);
59      row3.AddValue(2);
60      row3.AddValue(2);
61
62      Random rand = new Random();
63
64      for (int i = 0; i < 10000; i++) {
65        row1.AddValue(rand.NextDouble() * 10);
66        row2.AddValue(rand.NextDouble() * 10);
67        row3.AddValue(rand.NextDouble() * 10);
68      }
69
70      f.ShowDialog();
71    }
72
73    [Test]
74    public void TestGrid() {
75      LineChartTestForm f = new LineChartTestForm(model);
76
77      model.XAxis.ShowGrid = true;
78      model.XAxis.GridColor = Color.Red;
79
80      model.DefaultYAxis.ShowGrid = true;
81      model.DefaultYAxis.GridColor = Color.Blue;
82
83      IDataRow row1 = new DataRow();
84      row1.RowSettings.Label = "row1";
85
86      model.AddDataRow(row1);
87
88      row1.AddValue(0);
89      row1.AddValue(10);
90
91      f.ShowDialog();
92    }
93
94    [Test]
95    public void TestShowMarkers() {
96      LineChartTestForm f = new LineChartTestForm(model);
97
98      IDataRow row1 = new DataRow();
99      row1.RowSettings.Label = "row1";
100      row1.RowSettings.Color = Color.Red;
101      row1.RowSettings.ShowMarkers = true;
102
103      IDataRow row2 = new DataRow();
104      row2.RowSettings.Label = "row2";
105      row2.RowSettings.Color = Color.Blue;
106      row2.RowSettings.ShowMarkers = false;
107
108      model.AddDataRow(row1);
109      model.AddDataRow(row2);
110
111      for (int i = 0; i < 10; i++) {
112        row1.AddValue(i);
113        row2.AddValue(i*2);
114      }
115
116      f.ShowDialog();
117    }
118
119    [Test]
120    public void TestShowLabelOnAxes() {
121      LineChartTestForm f = new LineChartTestForm(model);
122
123      IDataRow row1 = new DataRow();
124      IDataRow row2 = new DataRow();
125
126      model.XAxis.Label = "X-Axis";
127      model.XAxis.ShowLabel = true;
128
129      row1.YAxis = model.DefaultYAxis;
130      row1.YAxis.Label = "Y-Axis row1";
131      row1.RowSettings.Color = Color.Blue;
132      row1.YAxis.ShowYAxisLabel = false;
133
134      row2.YAxis = new YAxisDescriptor();
135      row2.YAxis.Label = "Y-Axis row2";
136      row2.RowSettings.Color = Color.Red;
137      row2.YAxis.ShowYAxisLabel = true;
138
139      model.AddDataRow(row1);
140      model.AddDataRow(row2);
141
142      row1.AddValue(0);
143      row1.AddValue(10);
144      row1.AddValue(15);
145      row1.AddValue(16);
146
147      row2.AddValue(0);
148      row2.AddValue(20);
149      row2.AddValue(25);
150      row2.AddValue(26);
151
152      f.ShowDialog();
153    }
154
155    [Test]
156    public void TestAxes() {
157      LineChartTestForm f = new LineChartTestForm(model);
158
159      IDataRow row1 = new DataRow();
160      IDataRow row2 = new DataRow();
161      IDataRow row3 = new DataRow();
162
163      model.XAxis.Label = "X Axis";
164      model.XAxis.ShowLabel = true;
165      model.XAxis.ShowGrid = true;
166      model.XAxis.GridColor = Color.Blue;
167
168      YAxisDescriptor yaxis1 = model.DefaultYAxis;
169      YAxisDescriptor yaxis2 = new YAxisDescriptor();
170
171      yaxis1.Label = "Y-Axis 1";
172      yaxis1.Position = AxisPosition.Left;
173
174      yaxis2.Label = "Y-Axis 2";
175      yaxis2.Position = AxisPosition.Right;
176
177      row1.RowSettings.Color = Color.Red;
178      row1.RowSettings.Label = "Die Rote";
179
180      row2.RowSettings.Color = Color.Green;
181      row2.RowSettings.Label = "Die Grüne";
182
183      row3.RowSettings.Color = Color.Blue;
184      row3.RowSettings.Label = "Die Blaue";
185      row3.YAxis = yaxis2;
186
187      model.AddDataRow(row1);
188      model.AddDataRow(row2);
189      model.AddDataRow(row3);
190
191      Random rand = new Random(42);
192
193      for (int i = 0; i < 10; i++) {
194        row1.AddValue(rand.NextDouble() * 10);
195        row2.AddValue(rand.NextDouble() * 10);
196        row3.AddValue(rand.NextDouble() * 1);
197      }
198
199      f.AddValue += delegate {
200        row1.AddValue(rand.NextDouble() * 10);
201        row2.AddValue(rand.NextDouble() * 10);
202        row3.AddValue(rand.NextDouble() * 1);
203      };
204
205      f.ShowDialog();
206    }
207
208    [Test]
209    public void TestDataRowWithOnlyOneValueShouldntCauseZoomLevelTooHighError() {
210      LineChartTestForm f = new LineChartTestForm(model);
211
212      IDataRow row1 = new DataRow();
213      row1.AddValue(10);
214
215      model.AddDataRow(row1);
216
217      f.ShowDialog();
218    }
219
220    [Test]
221    public void TestDataRowWithoutValuesShouldntCauseZoomLevelTooHighError() {
222      LineChartTestForm f = new LineChartTestForm(model);
223
224      IDataRow row1 = new DataRow();
225
226      model.AddDataRow(row1);
227
228      f.ShowDialog();
229    }
230
231    [Test]
232    public void TestModelWithoutDataRowsShouldntCauseZoomLevelTooHighError() {
233      LineChartTestForm f = new LineChartTestForm(model);
234
235      f.ShowDialog();
236    }
237
238    [Test]
239    public void TestAddValueToDataRow() {
240      LineChartTestForm f = new LineChartTestForm(model);
241
242      IDataRow row = new DataRow();
243      row.AddValue(0);
244      row.AddValue(10);
245      row.AddValue(-5);
246
247      model.AddDataRow(row);
248
249      f.ShowDialog();
250    }
251
252    [Test]
253    public void TestAddValuesToDataRow() {
254      LineChartTestForm f = new LineChartTestForm(model);
255
256      IDataRow row = new DataRow();
257      row.AddValues(new double[] {0, 10, -5});
258
259      model.AddDataRow(row);
260
261      f.ShowDialog();
262    }
263
264    [Test]
265    public void TestInsertValueInDataRow() {
266      LineChartTestForm f = new LineChartTestForm(model);
267
268      IDataRow row = new DataRow();
269      row.AddValue(0);
270      row.AddValue(5);
271
272      row.AddValue(10, 1);
273      row.AddValue(10, 2);
274
275      model.AddDataRow(row);
276
277      f.ShowDialog();
278    }
279
280    [Test]
281    public void TestInsertValuesInDataRow() {
282      LineChartTestForm f = new LineChartTestForm(model);
283
284      IDataRow row = new DataRow();
285      row.AddValue(0);
286      row.AddValue(5);
287
288      row.AddValues(new double[] {10, 10}, 1);
289
290      model.AddDataRow(row);
291
292      f.ShowDialog();
293    }
294
295    [Test]
296    public void TestModifyValueInDataRow() {
297      LineChartTestForm f = new LineChartTestForm(model);
298
299      IDataRow row = new DataRow();
300      row.AddValue(0);
301      row.AddValue(100);
302      row.AddValue(0);
303
304      row.ModifyValue(5, 1);
305
306      model.AddDataRow(row);
307
308      f.ShowDialog();
309    }
310
311    [Test]
312    public void TestModifyValuesInDataRow() {
313      LineChartTestForm f = new LineChartTestForm(model);
314
315      IDataRow row = new DataRow();
316      row.AddValue(0);
317      row.AddValue(100);
318      row.AddValue(100);
319      row.AddValue(0);
320
321      row.ModifyValues(new double[] {5, 5}, 1);
322
323      model.AddDataRow(row);
324
325      f.ShowDialog();
326    }
327
328    [Test]
329    public void TestRemoveValueFromDataRow() {
330      LineChartTestForm f = new LineChartTestForm(model);
331
332      IDataRow row = new DataRow();
333      row.AddValue(0);
334      row.AddValue(20);
335      row.AddValue(100);
336      row.AddValue(50);
337
338      row.RemoveValue(2);
339
340      model.AddDataRow(row);
341
342      f.ShowDialog();
343    }
344
345    [Test]
346    public void TestRemoveValuesFromDataRow() {
347      LineChartTestForm f = new LineChartTestForm(model);
348
349      IDataRow row = new DataRow();
350      row.AddValue(0);
351      row.AddValue(20);
352      row.AddValue(100);
353      row.AddValue(50);
354
355      row.RemoveValues(1, 2);
356
357      model.AddDataRow(row);
358
359      f.ShowDialog();
360    }
361
362    [Test]
363    public void TestPersistence() {
364      LineChartTestForm f = new LineChartTestForm(model);
365
366      IDataRow row1 = new DataRow();
367      row1.AddValues(new double[] {0, 10, 5});
368
369      IDataRow row2 = new DataRow();
370      row2.AddValues(new double[] {1, 20, 7});
371
372      model.AddDataRows(row1, row2);
373    }
374
375    [Test]
376    public void SimpleTestAggregator() {
377      LineChartTestForm f = new LineChartTestForm(model);
378
379      IDataRow row1 = new DataRow();
380      row1.RowSettings.Label = "row";
381      row1.RowSettings.Color = Color.Red;
382      row1.RowSettings.Thickness = 3;
383      row1.RowSettings.Style = DrawingStyle.Solid;
384
385      model.AddDataRow(row1);
386
387
388      MaxAggregator aggregator = new MaxAggregator();
389      aggregator.RowSettings.Label = "MinAggregator";
390      aggregator.RowSettings.Color = Color.Pink;
391      aggregator.RowSettings.Thickness = 5;
392      aggregator.RowSettings.Style = DrawingStyle.Solid;
393      aggregator.RowSettings.LineType = DataRowType.SingleValue;
394      aggregator.AddWatch(row1);
395
396      model.AddDataRow(aggregator);
397
398      row1.AddValue(10);
399      row1.AddValue(5);
400      row1.AddValue(7);
401      row1.AddValue(3);
402      row1.AddValue(10);
403      row1.AddValue(2);
404
405      f.ShowDialog();
406    }
407
408
409    public class Worker {
410      // This method will be called when the thread is started.
411      private readonly ChartDataRowsModel model;
412
413      public Worker(ChartDataRowsModel model) {
414        this.model = model;
415      }
416
417      public void DoWorkMultiLine() {
418        IDataRow row1 = new DataRow();
419        row1.RowSettings.Color = Color.Red;
420        row1.RowSettings.Thickness = 2;
421        row1.RowSettings.Label = "Sinus";
422        row1.RowSettings.Style = DrawingStyle.Solid;
423        row1.RowSettings.ShowMarkers = false;
424        model.AddDataRow(row1);
425
426        IDataRow row2 = new DataRow();
427        row2.RowSettings.Color = Color.Red;
428        row2.RowSettings.Thickness = 3;
429        row2.RowSettings.Label = "Growing";
430        row2.RowSettings.Style = DrawingStyle.Solid;
431        row2.RowSettings.ShowMarkers = false;
432        model.AddDataRow(row2);
433
434        AvgAggregator multiAvgAggregator = new AvgAggregator();
435        multiAvgAggregator.RowSettings.Label = "MultiAvgAggregator";
436        multiAvgAggregator.RowSettings.Color = Color.DarkOliveGreen;
437        multiAvgAggregator.RowSettings.Thickness = 3;
438        multiAvgAggregator.RowSettings.Style = DrawingStyle.Solid;
439        multiAvgAggregator.RowSettings.LineType = DataRowType.SingleValue;
440        multiAvgAggregator.RowSettings.ShowMarkers = false;
441        multiAvgAggregator.AddWatch(row1);
442        multiAvgAggregator.AddWatch(row2);
443        model.AddDataRow(multiAvgAggregator);
444
445        MaxAggregator multiMaxAggregator = new MaxAggregator();
446        multiMaxAggregator.RowSettings.Label = "MultiMaxAggregator";
447        multiMaxAggregator.RowSettings.Color = Color.DarkKhaki;
448        multiMaxAggregator.RowSettings.Thickness = 3;
449        multiMaxAggregator.RowSettings.Style = DrawingStyle.Solid;
450        multiMaxAggregator.RowSettings.LineType = DataRowType.SingleValue;
451        multiMaxAggregator.RowSettings.ShowMarkers = false;
452        multiMaxAggregator.AddWatch(row1);
453        multiMaxAggregator.AddWatch(row2);
454        model.AddDataRow(multiMaxAggregator);
455
456        MinAggregator multiMinAggregator = new MinAggregator();
457        multiMinAggregator.RowSettings.Label = "MultiMinAggregator";
458        multiMinAggregator.RowSettings.Color = Color.DarkRed;
459        multiMinAggregator.RowSettings.Thickness = 3;
460        multiMinAggregator.RowSettings.Style = DrawingStyle.Solid;
461        multiMinAggregator.RowSettings.LineType = DataRowType.SingleValue;
462        multiMinAggregator.RowSettings.ShowMarkers = false;
463        multiMinAggregator.AddWatch(row1);
464        multiMinAggregator.AddWatch(row2);
465        model.AddDataRow(multiMinAggregator);
466
467        //        AvgLineAggregator multiLineAvgAggregator = new AvgLineAggregator {
468        //                                                                           Label = "MultiLineAvgAggregator",
469        //                                                                           Color = Color.Red,
470        //                                                                           Thickness = 4,
471        //                                                                           Style = DrawingStyle.Solid,
472        //                                                                           LineType = DataRowType.Normal,
473        //                                                                           ShowMarkers = false
474        //                                                                         };
475        //        multiLineAvgAggregator.AddWatch(row1);
476        //        multiLineAvgAggregator.AddWatch(row2);
477        //        multiLineAvgAggregator.AddValue(0);
478        //        model.AddDataRow(multiLineAvgAggregator);
479
480        double i = 0;
481
482
483        while (!_shouldStop && i <= 24) {
484          i += 0.2;
485          double newY = Math.Sin(i);
486          Console.WriteLine("working");
487          //row1.AddValue(rand.NextDouble() * 10);
488          row1.AddValue(newY * 10);
489          row2.AddValue(i * 2 - 15);
490          Thread.Sleep(100);
491        }
492        Console.WriteLine("worker thread: terminating gracefully.");
493      }
494
495      public void DoWorkSingleLine() {
496        IDataRow row1 = new DataRow();
497        row1.RowSettings.Color = Color.Red;
498        row1.RowSettings.Thickness = 2;
499        row1.RowSettings.Label = "Sinus";
500        row1.RowSettings.Style = DrawingStyle.Solid;
501        row1.RowSettings.ShowMarkers = false;
502        model.AddDataRow(row1);
503
504        IDataRow row2 = new DataRow();
505        row2.RowSettings.Color = Color.Red;
506        row2.RowSettings.Thickness = 3;
507        row2.RowSettings.Label = "Growing";
508        row2.RowSettings.Style = DrawingStyle.Solid;
509        row2.RowSettings.ShowMarkers = false;
510        model.AddDataRow(row2);
511
512        MinAggregator aggregator = new MinAggregator();
513        aggregator.RowSettings.Label = "MinAggregator";
514        aggregator.RowSettings.Color = Color.Pink;
515        aggregator.RowSettings.Thickness = 3;
516        aggregator.RowSettings.Style = DrawingStyle.Solid;
517        aggregator.RowSettings.LineType = DataRowType.SingleValue;
518        aggregator.AddWatch(row1);
519        model.AddDataRow(aggregator);
520
521        MaxAggregator maxAggregator = new MaxAggregator();
522        maxAggregator.RowSettings.Label = "MaxAggregator";
523        maxAggregator.RowSettings.Color = Color.DeepSkyBlue;
524        maxAggregator.RowSettings.Thickness = 3;
525        maxAggregator.RowSettings.Style = DrawingStyle.Solid;
526        maxAggregator.RowSettings.LineType = DataRowType.SingleValue;
527        maxAggregator.AddWatch(row1);
528        model.AddDataRow(maxAggregator);
529
530        AvgAggregator avgAggregator = new AvgAggregator();
531        avgAggregator.RowSettings.Label = "AvgAggregator";
532        avgAggregator.RowSettings.Color = Color.Violet;
533        avgAggregator.RowSettings.Thickness = 3;
534        avgAggregator.RowSettings.Style = DrawingStyle.Solid;
535        avgAggregator.RowSettings.LineType = DataRowType.SingleValue;
536        avgAggregator.AddWatch(row1);
537        model.AddDataRow(avgAggregator);
538
539        double i = 0;
540
541
542        while (!_shouldStop && i <= 240) {
543          i += 0.2;
544          double newY = Math.Sin(i);
545          Console.WriteLine("working");
546          //row1.AddValue(rand.NextDouble() * 10);
547          row1.AddValue(newY * 10);
548          row2.AddValue(i * 2 - 15);
549          //System.Threading.Thread.Sleep(100);
550        }
551        Console.WriteLine("worker thread: terminating gracefully.");
552      }
553
554      public void DoWorkAvgLine() {
555        IDataRow row1 = new DataRow();
556        row1.RowSettings.Color = Color.Red;
557        row1.RowSettings.Thickness = 2;
558        row1.RowSettings.Label = "Sinus";
559        row1.RowSettings.Style = DrawingStyle.Solid;
560        row1.RowSettings.ShowMarkers = false;
561        model.AddDataRow(row1);
562
563        IDataRow row2 = new DataRow();
564        row2.RowSettings.Color = Color.Red;
565        row2.RowSettings.Thickness = 3;
566        row2.RowSettings.Label = "Growing";
567        row2.RowSettings.Style = DrawingStyle.Solid;
568        row2.RowSettings.ShowMarkers = false;
569        model.AddDataRow(row2);
570
571        AvgLineAggregator avgLineAggregator = new AvgLineAggregator();
572        avgLineAggregator.RowSettings.Label = "AvgLineAggregator";
573        avgLineAggregator.RowSettings.Color = Color.Violet;
574        avgLineAggregator.RowSettings.Thickness = 3;
575        avgLineAggregator.RowSettings.Style = DrawingStyle.Solid;
576        avgLineAggregator.RowSettings.LineType = DataRowType.Normal;
577        avgLineAggregator.RowSettings.ShowMarkers = false;
578        avgLineAggregator.AddWatch(row1);
579        avgLineAggregator.AddWatch(row2);
580        model.AddDataRow(avgLineAggregator);
581
582        double i = 0;
583
584        while (!_shouldStop && i <= 240) {
585          i += 0.2;
586          double newY = Math.Sin(i);
587          Console.WriteLine("working");
588          //row1.AddValue(rand.NextDouble() * 10);
589          row1.AddValue(newY * 10);
590          row2.AddValue(i * 2 - 15);
591          //Thread.Sleep(100);
592        }
593        Console.WriteLine("worker thread: terminating gracefully.");
594      }
595
596      public void DoWorkFloatingAvg() {
597        IDataRow row1 = new DataRow();
598        row1.RowSettings.Color = Color.Red;
599        row1.RowSettings.Thickness = 2;
600        row1.RowSettings.Label = "SinusHacked";
601        row1.RowSettings.Style = DrawingStyle.Solid;
602        row1.RowSettings.ShowMarkers = false;
603        model.AddDataRow(row1);
604
605        IDataRow row2 = new DataRow();
606        row2.RowSettings.Color = Color.Red;
607        row2.RowSettings.Thickness = 3;
608        row2.RowSettings.Label = "GrowingHacked";
609        row2.RowSettings.Style = DrawingStyle.Solid;
610        row2.RowSettings.ShowMarkers = false;
611        model.AddDataRow(row2);
612
613        FloatingAvgAggregator avgAggregator = new FloatingAvgAggregator();
614        avgAggregator.RowSettings.Thickness = 2;
615        avgAggregator.RowSettings.Label = "floatingAvg";
616        avgAggregator.RowSettings.Color = Color.Peru;
617        avgAggregator.RowSettings.ShowMarkers = false;
618        avgAggregator.RowSettings.Style = DrawingStyle.Solid;
619
620        avgAggregator.AddWatch(row1);
621        model.AddDataRow(avgAggregator);
622
623        FloatingAvgAggregator avgAggregator2 = new FloatingAvgAggregator();
624        avgAggregator2.RowSettings.Thickness = 2;
625        avgAggregator2.RowSettings.Label = "floatingAvg";
626        avgAggregator2.RowSettings.Color = Color.Aqua;
627        avgAggregator2.RowSettings.ShowMarkers = false;
628        avgAggregator2.RowSettings.Style = DrawingStyle.Solid;
629
630        avgAggregator2.AddWatch(row2);
631        model.AddDataRow(avgAggregator2);
632
633       
634        double i = 0;
635        Random rnd = new Random();
636
637        while (!_shouldStop && i <= 100) {
638          i += 0.2;
639          double newY = Math.Sin(i);
640
641          double hack = rnd.NextDouble() * i / 10;
642          row1.AddValue(newY * 10 + hack);
643
644          hack = rnd.NextDouble() * i / 10;
645          row2.AddValue(i * 2 - 15 + hack);
646          //Thread.Sleep(100);
647        }
648        Console.WriteLine("worker thread: terminating gracefully.");
649      }
650
651      public void RequestStop() {
652        _shouldStop = true;
653      }
654
655      // Volatile is used as hint to the compiler that this data
656      // member will be accessed by multiple threads.
657      private volatile bool _shouldStop;
658    }
659
660
661    [Test]
662    public void TestAggregatorMultiLine() {
663      LineChartTestForm f = new LineChartTestForm(model);
664
665      // Create the thread object. This does not start the thread.
666      Worker workerObject = new Worker(model);
667      Thread workerThread = new Thread(workerObject.DoWorkMultiLine);
668
669      // Start the worker thread.
670      workerThread.Start();
671
672      f.ShowDialog();
673      workerObject.RequestStop();
674    }
675
676    [Test]
677    public void TestAggregatorSingleLine() {
678      LineChartTestForm f = new LineChartTestForm(model);
679      model.Title = "SingleLineAggregator Tests";
680
681      // Create the thread object. This does not start the thread.
682      Worker workerObject = new Worker(model);
683      Thread workerThread = new Thread(workerObject.DoWorkSingleLine);
684
685      // Start the worker thread.
686      workerThread.Start();
687
688      f.ShowDialog();
689      workerObject.RequestStop();
690    }
691
692    [Test]
693    public void TestAggregatorAvgLine() {
694      LineChartTestForm f = new LineChartTestForm(model);
695      model.Title = "AvgLineTest";
696
697      // Create the thread object. This does not start the thread.
698      Worker workerObject = new Worker(model);
699      Thread workerThread = new Thread(workerObject.DoWorkAvgLine);
700
701      // Start the worker thread.
702      workerThread.Start();
703
704      f.ShowDialog();
705      workerObject.RequestStop();
706    }
707
708    [Test]
709    public void TestFloatingAvg() {
710      LineChartTestForm f = new LineChartTestForm(model);
711      model.Title = "FloatingAvg Test";
712      model.ViewSettings.LegendPosition = Legend.LegendPosition.Top;
713
714      // Create the thread object. This does not start the thread.
715      Worker workerObject = new Worker(model);
716      Thread workerThread = new Thread(workerObject.DoWorkFloatingAvg);
717
718      // Start the worker thread.
719      workerThread.Start();
720
721      f.ShowDialog();
722      workerObject.RequestStop();
723    }
724
725
726    [Test]
727    public void TestAutoZoomInConstructor() {
728      IDataRow row1 = new DataRow();
729      row1.RowSettings.Color = Color.Red;
730      row1.RowSettings.Thickness = 3;
731      row1.RowSettings.Style = DrawingStyle.Solid;
732
733      model.AddDataRow(row1);
734
735      row1.AddValue(10);
736      row1.AddValue(5);
737      row1.AddValue(7);
738      row1.AddValue(3);
739      row1.AddValue(10);
740      row1.AddValue(2);
741
742      LineChartTestForm f = new LineChartTestForm(model);
743      f.ShowDialog();
744    }
745
746
747    [Test]
748    public void TestSingleValueDataRows() {
749      LineChartTestForm f = new LineChartTestForm(model);
750
751      IDataRow row1 = new DataRow();
752      IDataRow row2 = new DataRow();
753      IDataRow row3 = new DataRow();
754
755      IDataRow row4 = new DataRow();
756      IDataRow row5 = new DataRow();
757      IDataRow row6 = new DataRow();
758
759      row1.RowSettings.Color = Color.Red;
760      row2.RowSettings.Color = Color.Green;
761      row3.RowSettings.Color = Color.Blue;
762
763      row4.RowSettings.Color = Color.DeepPink;
764      row5.RowSettings.Color = Color.Firebrick;
765      row6.RowSettings.Color = Color.DarkSlateGray;
766
767      row1.RowSettings.Thickness = 3;
768      row2.RowSettings.Thickness = 4;
769      row3.RowSettings.Thickness = 5;
770
771      row4.RowSettings.Thickness = 3;
772      row5.RowSettings.Thickness = 4;
773      row6.RowSettings.Thickness = 5;
774
775      row1.RowSettings.Label = "SingleValue";
776      row2.RowSettings.Label = "Gertschi";
777      row3.RowSettings.Label = "Maxi";
778
779      row4.RowSettings.Label = "Simon";
780      row5.RowSettings.Label = "klausmuellerwesternhagenunddierasperies";
781      row6.RowSettings.Label = "anyways";
782
783      row1.RowSettings.Style = DrawingStyle.Solid;
784      row2.RowSettings.Style = DrawingStyle.Solid;
785      row3.RowSettings.Style = DrawingStyle.Dashed;
786
787      row4.RowSettings.Style = DrawingStyle.Solid;
788      row5.RowSettings.Style = DrawingStyle.Solid;
789      row6.RowSettings.Style = DrawingStyle.Dashed;
790
791      row1.RowSettings.LineType = DataRowType.SingleValue;
792      row2.RowSettings.LineType = DataRowType.SingleValue;
793      row1.AddValue(12);
794
795      row2.AddValue(5);
796
797
798      row3.AddValue(2);
799      row3.AddValue(5);
800      row3.AddValue(9);
801      row3.AddValue(1);
802      row3.AddValue(3);
803
804
805      row4.AddValue(10);
806      row5.AddValue(11);
807      row6.AddValue(11);
808
809      model.AddDataRow(row1);
810      model.AddDataRow(row2);
811      model.AddDataRow(row3);
812      model.AddDataRow(row4);
813      model.AddDataRow(row5);
814      model.AddDataRow(row6);
815
816      f.ShowDialog();
817    }
818
819    [Test]
820    public void TestMainForm() {
821      MainForm f = new MainForm();
822      f.ShowDialog();
823    }
824
825
826    [Test]
827    public void TestPointLines() {
828      IDataRow row1 = new DataRow();
829      row1.RowSettings.Color = Color.Red;
830      row1.RowSettings.Thickness = 3;
831      row1.RowSettings.Style = DrawingStyle.Dashed;
832
833      row1.RowSettings.LineType = DataRowType.Points;
834      model.AddDataRow(row1);
835
836      row1.AddValue(10);
837      row1.AddValue(5);
838      row1.AddValue(7);
839      row1.AddValue(3);
840      row1.AddValue(10);
841      row1.AddValue(2);
842
843      LineChartTestForm f = new LineChartTestForm(model);
844      f.ShowDialog();
845    }
846
847
848  }
849}
Note: See TracBrowser for help on using the repository browser.