public virtual void LineRendererTest() { String filename = "lineSvgRendererTest.pdf"; PdfDocument doc = new PdfDocument(new PdfWriter(destinationFolder + filename)); doc.AddNewPage(); IDictionary <String, String> lineProperties = new Dictionary <String, String>(); lineProperties.Put("x1", "100"); lineProperties.Put("y1", "800"); lineProperties.Put("x2", "300"); lineProperties.Put("y2", "800"); lineProperties.Put("stroke", "green"); lineProperties.Put("stroke-width", "25"); LineSvgNodeRenderer root = new LineSvgNodeRenderer(); root.SetAttributesAndStyles(lineProperties); 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().CompareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); }
public virtual void InvalidAttributeTest01() { NUnit.Framework.Assert.That(() => { PdfDocument doc = new PdfDocument(new PdfWriter(new MemoryStream())); doc.AddNewPage(); ISvgNodeRenderer root = new LineSvgNodeRenderer(); IDictionary <String, String> lineProperties = new Dictionary <String, String>(); lineProperties.Put("x1", "1"); lineProperties.Put("y1", "800"); lineProperties.Put("x2", "notAnum"); lineProperties.Put("y2", "alsoNotANum"); root.SetAttributesAndStyles(lineProperties); SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.PushCanvas(cv); root.Draw(context); } , NUnit.Framework.Throws.InstanceOf <StyledXMLParserException>().With.Message.EqualTo(MessageFormatUtil.Format(iText.StyledXmlParser.LogMessageConstant.NAN, "notAnum"))) ; }
public virtual void EmptyPointsListTest() { String filename = "lineEmptyPointsListTest.pdf"; PdfDocument doc = new PdfDocument(new PdfWriter(destinationFolder + filename)); doc.AddNewPage(); ISvgNodeRenderer root = new LineSvgNodeRenderer(); IDictionary <String, String> lineProperties = new Dictionary <String, String>(); root.SetAttributesAndStyles(lineProperties); SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.PushCanvas(cv); root.Draw(context); doc.Close(); int numPoints = ((LineSvgNodeRenderer)root).attributesAndStyles.Count; NUnit.Framework.Assert.AreEqual(numPoints, 0); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); }
public virtual void InvalidAttributeTest02() { IDictionary <String, String> lineProperties = new Dictionary <String, String>(); lineProperties.Put("x1", "100"); lineProperties.Put("y1", "800"); lineProperties.Put("x2", "1 0"); lineProperties.Put("y2", "0 2 0"); lineProperties.Put("stroke", "orange"); String filename = "invalidAttributes02.pdf"; PdfDocument doc = new PdfDocument(new PdfWriter(destinationFolder + filename)); doc.AddNewPage(); LineSvgNodeRenderer root = new LineSvgNodeRenderer(); root.SetAttributesAndStyles(lineProperties); SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.PushCanvas(cv); root.Draw(context); doc.Close(); }