Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive_Milestone3/sources/HeuristicLab.Visualization.Test/3.2/LineChartTests.cs @ 4483

Last change on this file since 4483 was 1993, checked in by mstoeger, 16 years ago

added many new persisted properties.
removed useless comments.
added XmlSupport class since the code for setting xml attributes is always the same.
#639

File size: 24.8 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 SimpleTestAggregator() {
364      LineChartTestForm f = new LineChartTestForm(model);
365
366      IDataRow row1 = new DataRow();
367      row1.RowSettings.Label = "row";
368      row1.RowSettings.Color = Color.Red;
369      row1.RowSettings.Thickness = 3;
370      row1.RowSettings.Style = DrawingStyle.Solid;
371
372      model.AddDataRow(row1);
373
374
375      MaxAggregator aggregator = new MaxAggregator();
376      aggregator.RowSettings.Label = "MinAggregator";
377      aggregator.RowSettings.Color = Color.Pink;
378      aggregator.RowSettings.Thickness = 5;
379      aggregator.RowSettings.Style = DrawingStyle.Solid;
380      aggregator.RowSettings.LineType = DataRowType.SingleValue;
381      aggregator.AddWatch(row1);
382
383      model.AddDataRow(aggregator);
384
385      row1.AddValue(10);
386      row1.AddValue(5);
387      row1.AddValue(7);
388      row1.AddValue(3);
389      row1.AddValue(10);
390      row1.AddValue(2);
391
392      f.ShowDialog();
393    }
394
395
396    public class Worker {
397      // This method will be called when the thread is started.
398      private readonly ChartDataRowsModel model;
399
400      public Worker(ChartDataRowsModel model) {
401        this.model = model;
402      }
403
404      public void DoWorkMultiLine() {
405        IDataRow row1 = new DataRow();
406        row1.RowSettings.Color = Color.Red;
407        row1.RowSettings.Thickness = 2;
408        row1.RowSettings.Label = "Sinus";
409        row1.RowSettings.Style = DrawingStyle.Solid;
410        row1.RowSettings.ShowMarkers = false;
411        model.AddDataRow(row1);
412
413        IDataRow row2 = new DataRow();
414        row2.RowSettings.Color = Color.Red;
415        row2.RowSettings.Thickness = 3;
416        row2.RowSettings.Label = "Growing";
417        row2.RowSettings.Style = DrawingStyle.Solid;
418        row2.RowSettings.ShowMarkers = false;
419        model.AddDataRow(row2);
420
421        AvgAggregator multiAvgAggregator = new AvgAggregator();
422        multiAvgAggregator.RowSettings.Label = "MultiAvgAggregator";
423        multiAvgAggregator.RowSettings.Color = Color.DarkOliveGreen;
424        multiAvgAggregator.RowSettings.Thickness = 3;
425        multiAvgAggregator.RowSettings.Style = DrawingStyle.Solid;
426        multiAvgAggregator.RowSettings.LineType = DataRowType.SingleValue;
427        multiAvgAggregator.RowSettings.ShowMarkers = false;
428        multiAvgAggregator.AddWatch(row1);
429        multiAvgAggregator.AddWatch(row2);
430        model.AddDataRow(multiAvgAggregator);
431
432        MaxAggregator multiMaxAggregator = new MaxAggregator();
433        multiMaxAggregator.RowSettings.Label = "MultiMaxAggregator";
434        multiMaxAggregator.RowSettings.Color = Color.DarkKhaki;
435        multiMaxAggregator.RowSettings.Thickness = 3;
436        multiMaxAggregator.RowSettings.Style = DrawingStyle.Solid;
437        multiMaxAggregator.RowSettings.LineType = DataRowType.SingleValue;
438        multiMaxAggregator.RowSettings.ShowMarkers = false;
439        multiMaxAggregator.AddWatch(row1);
440        multiMaxAggregator.AddWatch(row2);
441        model.AddDataRow(multiMaxAggregator);
442
443        MinAggregator multiMinAggregator = new MinAggregator();
444        multiMinAggregator.RowSettings.Label = "MultiMinAggregator";
445        multiMinAggregator.RowSettings.Color = Color.DarkRed;
446        multiMinAggregator.RowSettings.Thickness = 3;
447        multiMinAggregator.RowSettings.Style = DrawingStyle.Solid;
448        multiMinAggregator.RowSettings.LineType = DataRowType.SingleValue;
449        multiMinAggregator.RowSettings.ShowMarkers = false;
450        multiMinAggregator.AddWatch(row1);
451        multiMinAggregator.AddWatch(row2);
452        model.AddDataRow(multiMinAggregator);
453
454        //        AvgLineAggregator multiLineAvgAggregator = new AvgLineAggregator {
455        //                                                                           Label = "MultiLineAvgAggregator",
456        //                                                                           Color = Color.Red,
457        //                                                                           Thickness = 4,
458        //                                                                           Style = DrawingStyle.Solid,
459        //                                                                           LineType = DataRowType.Normal,
460        //                                                                           ShowMarkers = false
461        //                                                                         };
462        //        multiLineAvgAggregator.AddWatch(row1);
463        //        multiLineAvgAggregator.AddWatch(row2);
464        //        multiLineAvgAggregator.AddValue(0);
465        //        model.AddDataRow(multiLineAvgAggregator);
466
467        double i = 0;
468
469
470        while (!_shouldStop && i <= 24) {
471          i += 0.2;
472          double newY = Math.Sin(i);
473          Console.WriteLine("working");
474          //row1.AddValue(rand.NextDouble() * 10);
475          row1.AddValue(newY * 10);
476          row2.AddValue(i * 2 - 15);
477          Thread.Sleep(100);
478        }
479        Console.WriteLine("worker thread: terminating gracefully.");
480      }
481
482      public void DoWorkSingleLine() {
483        IDataRow row1 = new DataRow();
484        row1.RowSettings.Color = Color.Red;
485        row1.RowSettings.Thickness = 2;
486        row1.RowSettings.Label = "Sinus";
487        row1.RowSettings.Style = DrawingStyle.Solid;
488        row1.RowSettings.ShowMarkers = false;
489        model.AddDataRow(row1);
490
491        IDataRow row2 = new DataRow();
492        row2.RowSettings.Color = Color.Red;
493        row2.RowSettings.Thickness = 3;
494        row2.RowSettings.Label = "Growing";
495        row2.RowSettings.Style = DrawingStyle.Solid;
496        row2.RowSettings.ShowMarkers = false;
497        model.AddDataRow(row2);
498
499        MinAggregator aggregator = new MinAggregator();
500        aggregator.RowSettings.Label = "MinAggregator";
501        aggregator.RowSettings.Color = Color.Pink;
502        aggregator.RowSettings.Thickness = 3;
503        aggregator.RowSettings.Style = DrawingStyle.Solid;
504        aggregator.RowSettings.LineType = DataRowType.SingleValue;
505        aggregator.AddWatch(row1);
506        model.AddDataRow(aggregator);
507
508        MaxAggregator maxAggregator = new MaxAggregator();
509        maxAggregator.RowSettings.Label = "MaxAggregator";
510        maxAggregator.RowSettings.Color = Color.DeepSkyBlue;
511        maxAggregator.RowSettings.Thickness = 3;
512        maxAggregator.RowSettings.Style = DrawingStyle.Solid;
513        maxAggregator.RowSettings.LineType = DataRowType.SingleValue;
514        maxAggregator.AddWatch(row1);
515        model.AddDataRow(maxAggregator);
516
517        AvgAggregator avgAggregator = new AvgAggregator();
518        avgAggregator.RowSettings.Label = "AvgAggregator";
519        avgAggregator.RowSettings.Color = Color.Violet;
520        avgAggregator.RowSettings.Thickness = 3;
521        avgAggregator.RowSettings.Style = DrawingStyle.Solid;
522        avgAggregator.RowSettings.LineType = DataRowType.SingleValue;
523        avgAggregator.AddWatch(row1);
524        model.AddDataRow(avgAggregator);
525
526        double i = 0;
527
528
529        while (!_shouldStop && i <= 240) {
530          i += 0.2;
531          double newY = Math.Sin(i);
532          Console.WriteLine("working");
533          //row1.AddValue(rand.NextDouble() * 10);
534          row1.AddValue(newY * 10);
535          row2.AddValue(i * 2 - 15);
536          //System.Threading.Thread.Sleep(100);
537        }
538        Console.WriteLine("worker thread: terminating gracefully.");
539      }
540
541      public void DoWorkAvgLine() {
542        IDataRow row1 = new DataRow();
543        row1.RowSettings.Color = Color.Red;
544        row1.RowSettings.Thickness = 2;
545        row1.RowSettings.Label = "Sinus";
546        row1.RowSettings.Style = DrawingStyle.Solid;
547        row1.RowSettings.ShowMarkers = false;
548        model.AddDataRow(row1);
549
550        IDataRow row2 = new DataRow();
551        row2.RowSettings.Color = Color.Red;
552        row2.RowSettings.Thickness = 3;
553        row2.RowSettings.Label = "Growing";
554        row2.RowSettings.Style = DrawingStyle.Solid;
555        row2.RowSettings.ShowMarkers = false;
556        model.AddDataRow(row2);
557
558        AvgLineAggregator avgLineAggregator = new AvgLineAggregator();
559        avgLineAggregator.RowSettings.Label = "AvgLineAggregator";
560        avgLineAggregator.RowSettings.Color = Color.Violet;
561        avgLineAggregator.RowSettings.Thickness = 3;
562        avgLineAggregator.RowSettings.Style = DrawingStyle.Solid;
563        avgLineAggregator.RowSettings.LineType = DataRowType.Normal;
564        avgLineAggregator.RowSettings.ShowMarkers = false;
565        avgLineAggregator.AddWatch(row1);
566        avgLineAggregator.AddWatch(row2);
567        model.AddDataRow(avgLineAggregator);
568
569        double i = 0;
570
571        while (!_shouldStop && i <= 240) {
572          i += 0.2;
573          double newY = Math.Sin(i);
574          Console.WriteLine("working");
575          //row1.AddValue(rand.NextDouble() * 10);
576          row1.AddValue(newY * 10);
577          row2.AddValue(i * 2 - 15);
578          //Thread.Sleep(100);
579        }
580        Console.WriteLine("worker thread: terminating gracefully.");
581      }
582
583      public void DoWorkFloatingAvg() {
584        IDataRow row1 = new DataRow();
585        row1.RowSettings.Color = Color.Red;
586        row1.RowSettings.Thickness = 2;
587        row1.RowSettings.Label = "SinusHacked";
588        row1.RowSettings.Style = DrawingStyle.Solid;
589        row1.RowSettings.ShowMarkers = false;
590        model.AddDataRow(row1);
591
592        IDataRow row2 = new DataRow();
593        row2.RowSettings.Color = Color.Red;
594        row2.RowSettings.Thickness = 3;
595        row2.RowSettings.Label = "GrowingHacked";
596        row2.RowSettings.Style = DrawingStyle.Solid;
597        row2.RowSettings.ShowMarkers = false;
598        model.AddDataRow(row2);
599
600        FloatingAvgAggregator avgAggregator = new FloatingAvgAggregator();
601        avgAggregator.RowSettings.Thickness = 2;
602        avgAggregator.RowSettings.Label = "floatingAvg";
603        avgAggregator.RowSettings.Color = Color.Peru;
604        avgAggregator.RowSettings.ShowMarkers = false;
605        avgAggregator.RowSettings.Style = DrawingStyle.Solid;
606
607        avgAggregator.AddWatch(row1);
608        model.AddDataRow(avgAggregator);
609
610        FloatingAvgAggregator avgAggregator2 = new FloatingAvgAggregator();
611        avgAggregator2.RowSettings.Thickness = 2;
612        avgAggregator2.RowSettings.Label = "floatingAvg";
613        avgAggregator2.RowSettings.Color = Color.Aqua;
614        avgAggregator2.RowSettings.ShowMarkers = false;
615        avgAggregator2.RowSettings.Style = DrawingStyle.Solid;
616
617        avgAggregator2.AddWatch(row2);
618        model.AddDataRow(avgAggregator2);
619
620       
621        double i = 0;
622        Random rnd = new Random();
623
624        while (!_shouldStop && i <= 100) {
625          i += 0.2;
626          double newY = Math.Sin(i);
627
628          double hack = rnd.NextDouble() * i / 10;
629          row1.AddValue(newY * 10 + hack);
630
631          hack = rnd.NextDouble() * i / 10;
632          row2.AddValue(i * 2 - 15 + hack);
633          //Thread.Sleep(100);
634        }
635        Console.WriteLine("worker thread: terminating gracefully.");
636      }
637
638      public void RequestStop() {
639        _shouldStop = true;
640      }
641
642      // Volatile is used as hint to the compiler that this data
643      // member will be accessed by multiple threads.
644      private volatile bool _shouldStop;
645    }
646
647
648    [Test]
649    public void TestAggregatorMultiLine() {
650      LineChartTestForm f = new LineChartTestForm(model);
651
652      // Create the thread object. This does not start the thread.
653      Worker workerObject = new Worker(model);
654      Thread workerThread = new Thread(workerObject.DoWorkMultiLine);
655
656      // Start the worker thread.
657      workerThread.Start();
658
659      f.ShowDialog();
660      workerObject.RequestStop();
661    }
662
663    [Test]
664    public void TestAggregatorSingleLine() {
665      LineChartTestForm f = new LineChartTestForm(model);
666      model.Title = "SingleLineAggregator Tests";
667
668      // Create the thread object. This does not start the thread.
669      Worker workerObject = new Worker(model);
670      Thread workerThread = new Thread(workerObject.DoWorkSingleLine);
671
672      // Start the worker thread.
673      workerThread.Start();
674
675      f.ShowDialog();
676      workerObject.RequestStop();
677    }
678
679    [Test]
680    public void TestAggregatorAvgLine() {
681      LineChartTestForm f = new LineChartTestForm(model);
682      model.Title = "AvgLineTest";
683
684      // Create the thread object. This does not start the thread.
685      Worker workerObject = new Worker(model);
686      Thread workerThread = new Thread(workerObject.DoWorkAvgLine);
687
688      // Start the worker thread.
689      workerThread.Start();
690
691      f.ShowDialog();
692      workerObject.RequestStop();
693    }
694
695    [Test]
696    public void TestFloatingAvg() {
697      LineChartTestForm f = new LineChartTestForm(model);
698      model.Title = "FloatingAvg Test";
699      model.ViewSettings.LegendPosition = Legend.LegendPosition.Top;
700
701      // Create the thread object. This does not start the thread.
702      Worker workerObject = new Worker(model);
703      Thread workerThread = new Thread(workerObject.DoWorkFloatingAvg);
704
705      // Start the worker thread.
706      workerThread.Start();
707
708      f.ShowDialog();
709      workerObject.RequestStop();
710    }
711
712
713    [Test]
714    public void TestAutoZoomInConstructor() {
715      IDataRow row1 = new DataRow();
716      row1.RowSettings.Color = Color.Red;
717      row1.RowSettings.Thickness = 3;
718      row1.RowSettings.Style = DrawingStyle.Solid;
719
720      model.AddDataRow(row1);
721
722      row1.AddValue(10);
723      row1.AddValue(5);
724      row1.AddValue(7);
725      row1.AddValue(3);
726      row1.AddValue(10);
727      row1.AddValue(2);
728
729      LineChartTestForm f = new LineChartTestForm(model);
730      f.ShowDialog();
731    }
732
733
734    [Test]
735    public void TestSingleValueDataRows() {
736      LineChartTestForm f = new LineChartTestForm(model);
737
738      IDataRow row1 = new DataRow();
739      IDataRow row2 = new DataRow();
740      IDataRow row3 = new DataRow();
741
742      IDataRow row4 = new DataRow();
743      IDataRow row5 = new DataRow();
744      IDataRow row6 = new DataRow();
745
746      row1.RowSettings.Color = Color.Red;
747      row2.RowSettings.Color = Color.Green;
748      row3.RowSettings.Color = Color.Blue;
749
750      row4.RowSettings.Color = Color.DeepPink;
751      row5.RowSettings.Color = Color.Firebrick;
752      row6.RowSettings.Color = Color.DarkSlateGray;
753
754      row1.RowSettings.Thickness = 3;
755      row2.RowSettings.Thickness = 4;
756      row3.RowSettings.Thickness = 5;
757
758      row4.RowSettings.Thickness = 3;
759      row5.RowSettings.Thickness = 4;
760      row6.RowSettings.Thickness = 5;
761
762      row1.RowSettings.Label = "SingleValue";
763      row2.RowSettings.Label = "Gertschi";
764      row3.RowSettings.Label = "Maxi";
765
766      row4.RowSettings.Label = "Simon";
767      row5.RowSettings.Label = "klausmuellerwesternhagenunddierasperies";
768      row6.RowSettings.Label = "anyways";
769
770      row1.RowSettings.Style = DrawingStyle.Solid;
771      row2.RowSettings.Style = DrawingStyle.Solid;
772      row3.RowSettings.Style = DrawingStyle.Dashed;
773
774      row4.RowSettings.Style = DrawingStyle.Solid;
775      row5.RowSettings.Style = DrawingStyle.Solid;
776      row6.RowSettings.Style = DrawingStyle.Dashed;
777
778      row1.RowSettings.LineType = DataRowType.SingleValue;
779      row2.RowSettings.LineType = DataRowType.SingleValue;
780      row1.AddValue(12);
781
782      row2.AddValue(5);
783
784
785      row3.AddValue(2);
786      row3.AddValue(5);
787      row3.AddValue(9);
788      row3.AddValue(1);
789      row3.AddValue(3);
790
791
792      row4.AddValue(10);
793      row5.AddValue(11);
794      row6.AddValue(11);
795
796      model.AddDataRow(row1);
797      model.AddDataRow(row2);
798      model.AddDataRow(row3);
799      model.AddDataRow(row4);
800      model.AddDataRow(row5);
801      model.AddDataRow(row6);
802
803      f.ShowDialog();
804    }
805
806    [Test]
807    public void TestMainForm() {
808      MainForm f = new MainForm();
809      f.ShowDialog();
810    }
811
812
813    [Test]
814    public void TestPointLines() {
815      IDataRow row1 = new DataRow();
816      row1.RowSettings.Color = Color.Red;
817      row1.RowSettings.Thickness = 3;
818      row1.RowSettings.Style = DrawingStyle.Dashed;
819
820      row1.RowSettings.LineType = DataRowType.Points;
821      model.AddDataRow(row1);
822
823      row1.AddValue(10);
824      row1.AddValue(5);
825      row1.AddValue(7);
826      row1.AddValue(3);
827      row1.AddValue(10);
828      row1.AddValue(2);
829
830      LineChartTestForm f = new LineChartTestForm(model);
831      f.ShowDialog();
832    }
833
834
835  }
836}
Note: See TracBrowser for help on using the repository browser.