public virtual void PolyPointCheckerTest()
        {
            PdfDocument doc = new PdfDocument(new PdfWriter(new MemoryStream()));

            doc.AddNewPage();
            ISvgNodeRenderer             root = new PolylineSvgNodeRenderer();
            IDictionary <String, String> polyLineAttributes = new Dictionary <String, String>();

            polyLineAttributes.Put(SvgConstants.Attributes.POINTS, "0,0 100,100 200,200 300,300");
            root.SetAttributesAndStyles(polyLineAttributes);
            SvgDrawContext context = new SvgDrawContext(null, null);
            PdfCanvas      cv      = new PdfCanvas(doc, 1);

            context.PushCanvas(cv);
            root.Draw(context);
            IList <Point> expectedPoints = new List <Point>();

            expectedPoints.Add(new Point(0, 0));
            expectedPoints.Add(new Point(75, 75));
            expectedPoints.Add(new Point(150, 150));
            expectedPoints.Add(new Point(225, 225));
            IList <Point> attributePoints = ((PolylineSvgNodeRenderer)root).GetPoints();

            NUnit.Framework.Assert.AreEqual(expectedPoints.Count, attributePoints.Count);
            for (int x = 0; x < attributePoints.Count; x++)
            {
                NUnit.Framework.Assert.AreEqual(expectedPoints[x], attributePoints[x]);
            }
        }
        public override ISvgNodeRenderer CreateDeepCopy()
        {
            PolylineSvgNodeRenderer copy = new PolylineSvgNodeRenderer();

            DeepCopyAttributesAndStyles(copy);
            return(copy);
        }
Esempio n. 3
0
        public virtual void DeepCopyTest()
        {
            PolylineSvgNodeRenderer expected = new PolylineSvgNodeRenderer();

            expected.SetAttribute(SvgConstants.Attributes.FILL, "blue");
            ISvgNodeRenderer actual = expected.CreateDeepCopy();

            NUnit.Framework.Assert.AreEqual(expected, actual);
        }
 public virtual void PolyLineInvalidAttributeTest01()
 {
     NUnit.Framework.Assert.That(() => {
         PdfDocument doc = new PdfDocument(new PdfWriter(new MemoryStream()));
         doc.AddNewPage();
         ISvgNodeRenderer root = new PolylineSvgNodeRenderer();
         IDictionary <String, String> polyLineAttributes = new Dictionary <String, String>();
         polyLineAttributes.Put(SvgConstants.Attributes.POINTS, "0,0 notAnum,alsoNotANum");
         root.SetAttributesAndStyles(polyLineAttributes);
         SvgDrawContext context = new SvgDrawContext(null, null);
         PdfCanvas cv           = new PdfCanvas(doc, 1);
         context.PushCanvas(cv);
         root.Draw(context);
     }
                                 , NUnit.Framework.Throws.InstanceOf <StyledXMLParserException>())
     ;
 }
        public virtual void PolylineRendererTest()
        {
            String      filename = "polylineRendererTest.pdf";
            PdfDocument doc      = new PdfDocument(new PdfWriter(destinationFolder + filename));

            doc.AddNewPage();
            ISvgNodeRenderer             root = new PolylineSvgNodeRenderer();
            IDictionary <String, String> polyLineAttributes = new Dictionary <String, String>();

            polyLineAttributes.Put(SvgConstants.Attributes.POINTS, "0,40 40,40 40,80 80,80 80,120 120,120 120,160");
            root.SetAttributesAndStyles(polyLineAttributes);
            SvgDrawContext context = new SvgDrawContext(null, null);
            PdfCanvas      cv      = new PdfCanvas(doc, 1);

            context.PushCanvas(cv);
            root.Draw(context);
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareVisually(destinationFolder + filename, sourceFolder
                                                                            + "cmp_" + filename, destinationFolder, "diff_"));
        }
        public virtual void PolyLineEmptyPointsListTest()
        {
            String      filename = "polyLineEmptyPointsListTest.pdf";
            PdfDocument doc      = new PdfDocument(new PdfWriter(destinationFolder + filename));

            doc.AddNewPage();
            ISvgNodeRenderer             root = new PolylineSvgNodeRenderer();
            IDictionary <String, String> polyLineAttributes = new Dictionary <String, String>();

            root.SetAttributesAndStyles(polyLineAttributes);
            SvgDrawContext context = new SvgDrawContext(null, null);
            PdfCanvas      cv      = new PdfCanvas(doc, 1);

            context.PushCanvas(cv);
            root.Draw(context);
            doc.Close();
            int numPoints = ((PolylineSvgNodeRenderer)root).GetPoints().Count;

            NUnit.Framework.Assert.AreEqual(numPoints, 0);
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareVisually(destinationFolder + filename, sourceFolder
                                                                            + "cmp_" + filename, destinationFolder, "diff_"));
        }