Пример #1
0
 public void DrawWithDataTest()
 {
     var linesNumber = 1000;
     var pointsNumber = linesNumber + 1;
     TestDrawingWrapper drawing = StartDataGeneration(TestSinusDataProviderService.Create(pointsNumber), pointsNumber, linesNumber);
     Assert.IsTrue(drawing.Lines.Count >= 9, $"drawn lines for axis {drawing.Lines.Count} less than generated {9}");
     Assert.IsTrue(drawing.Texts.Count > 5);
     Assert.IsTrue(drawing.MeasureTexts.Count > 0);
     Assert.IsTrue(drawing.Flushes.Count == 1, $"Flushes count = {drawing.Flushes.Count}");
 }
Пример #2
0
        public static void CreateBaseServices(int testPointNumber, out IGridState gridState, out IDataDrawState graphState, out IDataService dataService, out IScaleService scaleService)
        {
            var provider = TestSinusDataProviderService.Create(testPointNumber);

            TestFactory.CreateBaseServices(null, provider,
                                           out gridState, out graphState,
                                           out IItemFormatter itemFormatter, out IMargin margin,
                                           out dataService, out scaleService);
            provider.Run();
        }
Пример #3
0
        private static IDrawing StartCreateAndDrawDataLines(int pointsNumber, bool drawInBitmap, bool runProvider)
        {
            var linesNumber = pointsNumber - 1;
            var linesToDraw = 0;
            IDataProviderService provider = null;

            TestDrawingWrapper drawingTester = null;
            DrawingBuffer      buffer        = null;
            Drawing2DWrapper   drawingBitmap = null;
            IDrawing           drawing       = null;
            var size = new Size(800, 600);

            if (drawInBitmap)
            {
                size          = new Size(8000, 4500);
                buffer        = new DrawingBuffer(size);
                drawingBitmap = new Drawing2DWrapper(buffer.Graphics);
                drawing       = drawingBitmap;
            }
            else
            {
                drawingTester = new TestDrawingWrapper(100);
                drawing       = drawingTester;
            }

            IScaleService           scaleService           = null;
            IDataService            dataService            = null;
            var                     controller             = GraphControlFactory.CreateController();
            IBufferedDrawingService bufferedDrawingService = new BufferedDrawingService();
            int                     receivedPoints         = 0;

            try
            {
                // Create all services
                provider = TestSinusDataProviderService.Create(pointsNumber);
                var view = TestDataView.Create(controller, provider, bufferedDrawingService);

                var margin  = new Margin(100, 5, 5, 60);
                var options = new DataDrawOptions(size, true, true, null, new DataDrawState());
                scaleService = controller.GetInstance <IScaleService>();
                scaleService.UpdateScale(options); // to prepare scaling service without presenter

                dataService = controller.GetInstance <IDataService>();

                dataService.DataUpdated += (sender, e) =>
                {
                    scaleService.UpdateScale(options);
                    drawingTester?.Reset();
                    view.Draw(drawing, options, margin);
                    receivedPoints += e.Items.Count;
                };

                if (pointsNumber > 0)
                {
                    provider.Run();

                    // Wait to draw at least test points
                    while (receivedPoints < pointsNumber)
                    {
                        Thread.Sleep(0);
                    }
                }
                else
                {
                    view.Draw(drawing, options, margin);
                }

                linesToDraw = dataService.GetItems(scaleService.State.X1, scaleService.State.X2).Count();
            }
            finally
            {
                bufferedDrawingService.Dispose();
            }

            Assert.IsTrue(bufferedDrawingService.LastQueueOverflow.Ticks == 0, $"drawing queue overflow, last time: {bufferedDrawingService.LastQueueOverflow.ToLongTimeString()}");

            Assert.IsTrue(linesToDraw == pointsNumber,
                          $"dataService.GetItems({new DateTime((long)scaleService.State.X1 * TimeSpan.TicksPerMillisecond).ToString("HH:mm:ss.fff")}"
                          + $", {new DateTime((long)scaleService.State.X1 * TimeSpan.TicksPerMillisecond).ToString("HH:mm:ss.fff")}) {linesToDraw} ({dataService.ItemCount}) != generated points {pointsNumber}");

            if (!drawInBitmap)
            {
                Assert.IsTrue(drawingTester.Lines.Count >= linesNumber, $"lines count is {drawingTester.Lines.Count} less than {linesNumber}");
            }

            return(drawing);
        }