Provides methods to assert against the svg schema.
コード例 #1
0
        public void ExportToString_TestPlot_ValidSvgString()
        {
            var plotModel = new PlotModel("Test plot");

            plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
            var rc  = new ShapesRenderContext(null);
            var svg = SvgExporter.ExportToString(plotModel, 800, 500, false, rc);

            SvgAssert.IsValidElement(svg);
        }
コード例 #2
0
        public void ExportToString_TestPlot_ValidSvgString()
        {
            var plotModel = new PlotModel {
                Title = "Test plot"
            };

            plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
            var svg = SvgExporter.ExportToString(plotModel, 800, 500, false);

            SvgAssert.IsValidElement(svg);
        }
コード例 #3
0
        public void SaveSvg_TestPlot_ValidSvgFile()
        {
            var plotModel = TestModels.CreateTestModel1();

            const string FileName = "PlotModelTests_Test1.svg";
            var          rc       = new ShapesRenderContext(null);
            var          svg      = plotModel.ToSvg(800, 500, false, rc);

            File.WriteAllText(FileName, svg);
            SvgAssert.IsValidFile(FileName);
        }
コード例 #4
0
        public void ToSvg_TestPlot_ValidSvgString()
        {
            var plotModel = TestModels.CreateTestModel1();

            var rc   = new ShapesRenderContext(null);
            var svg1 = plotModel.ToSvg(800, 500, true, rc);

            SvgAssert.IsValidDocument(svg1);
            var svg2 = plotModel.ToSvg(800, 500, false, rc);

            SvgAssert.IsValidElement(svg2);
        }
コード例 #5
0
        public void WriteText()
        {
            const string FileName = "SvgWriterTests_WriteText.svg";

            using (var s = File.Create(FileName))
            {
                using (var w = new SvgWriter(s, 200, 200))
                {
                    w.WriteText(new ScreenPoint(10, 10), "Hello world!", OxyColors.Black, "Arial", 20, FontWeights.Bold);
                }
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #6
0
        public void Export_TestPlot_ValidSvgString()
        {
            var          plotModel = new PlotModel("Test plot");
            const string FileName  = "SvgExporterTests_Plot1.svg";

            plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
            using (var s = File.Create(FileName))
            {
                var rc = new ShapesRenderContext(null);
                SvgExporter.Export(plotModel, s, 800, 500, true, rc);
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #7
0
        public void Export_TestPlot_ValidSvgString()
        {
            var plotModel = new PlotModel {
                Title = "Test plot"
            };
            const string FileName = "SvgExporterTests_Plot1.svg";

            plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
            using (var s = File.Create(FileName))
            {
                SvgExporter.Export(plotModel, s, 800, 500, true);
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #8
0
        public void WritePolyline()
        {
            const string FileName = "SvgWriterTests_WritePolyLine.svg";

            using (var s = File.Create(FileName))
            {
                using (var w = new SvgWriter(s, 200, 200))
                {
                    w.WritePolyline(
                        CreatePointList(),
                        w.CreateStyle(OxyColors.Blue, OxyColors.Black, 2, LineStyleHelper.GetDashArray(LineStyle.Solid)));
                }
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #9
0
        public void WriteLine()
        {
            const string FileName = "SvgWriterTests_WriteLine.svg";

            using (var s = File.Create(FileName))
            {
                using (var w = new SvgWriter(s, 200, 200))
                {
                    w.WriteLine(
                        new ScreenPoint(10, 10),
                        new ScreenPoint(150, 80),
                        w.CreateStyle(OxyColors.Undefined, OxyColors.Black, 2, LineStyle.Solid.GetDashArray()));
                }
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #10
0
        public void WriteClippedImage()
        {
            const string FileName = "SvgWriterTests_WriteClippedImage.svg";
            var          image    = CreateImage();

            using (var s = File.Create(FileName))
            {
                using (var w = new SvgWriter(s, 400, 400))
                {
                    w.WriteImage(0, 0, 400, 200, image);
                    w.WriteRectangle(100, 50, 200, 100, w.CreateStyle(OxyColors.Undefined, OxyColors.Black, 1));
                    w.WriteImage(1, 0.5, 2, 1, 100, 250, 200, 100, image);
                }
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #11
0
        public void WriteClippedEllipse()
        {
            const string FileName = "SvgWriterTests_WriteClippedEllipse.svg";

            using (var s = File.Create(FileName))
            {
                using (var w = new SvgWriter(s, 200, 200))
                {
                    w.WriteRectangle(5, 5, 95, 45, w.CreateStyle(OxyColors.LightGreen, OxyColors.Undefined, 0));
                    w.BeginClip(5, 5, 95, 45);
                    w.WriteEllipse(10, 10, 100, 60, w.CreateStyle(OxyColors.Blue, OxyColors.Black, 2));
                    w.EndClip();
                    w.Flush();
                }
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #12
0
        public void WriteRectangle()
        {
            const string FileName = "SvgWriterTests_WriteRectangle.svg";

            using (var s = File.Create(FileName))
            {
                using (var w = new SvgWriter(s, 200, 200))
                {
                    w.WriteRectangle(
                        10,
                        20,
                        150,
                        80,
                        w.CreateStyle(OxyColors.Green, OxyColors.Black, 2, LineStyle.Solid.GetDashArray()));
                }
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #13
0
        public void WriteImage()
        {
            const string FileName = "SvgWriterTests_WriteImage.svg";
            var          image    = CreateImage();

            using (var s = File.Create(FileName))
            {
                using (var w = new SvgWriter(s, 500, 300))
                {
                    for (int y = 0; y <= 200; y += 20)
                    {
                        w.WriteLine(new ScreenPoint(0, y), new ScreenPoint(400, y), w.CreateStyle(OxyColors.Undefined, OxyColors.Black, 1));
                    }

                    w.WriteImage(0, 0, 400, 200, image);
                }
            }

            SvgAssert.IsValidFile(FileName);
        }
コード例 #14
0
        public void WriteEllipse()
        {
            const string FileName = "SvgWriterTests_WriteEllipse.svg";

            using (var s = File.Create(FileName))
            {
                using (var w = new SvgWriter(s, 200, 200))
                {
                    w.WriteEllipse(
                        10,
                        10,
                        100,
                        60,
                        w.CreateStyle(OxyColors.Blue, OxyColors.Black, 2, LineStyle.Solid.GetDashArray()),
                        EdgeRenderingMode.Adaptive);
                }
            }

            SvgAssert.IsValidFile(FileName);
        }