public virtual void DummyProcessingTestCorrectNested() { //Setup nodes iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGCircle = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("circle"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGPath = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("path"), ""); INode root = new JsoupElementNode(jsoupSVGRoot); root.AddChild(new JsoupElementNode(jsoupSVGCircle)); root.AddChild(new JsoupElementNode(jsoupSVGPath)); INode nestedSvg = new JsoupElementNode(jsoupSVGRoot); nestedSvg.AddChild(new JsoupElementNode(jsoupSVGCircle)); nestedSvg.AddChild(new JsoupElementNode(jsoupSVGCircle)); root.AddChild(nestedSvg); //Run DefaultSvgProcessor processor = new DefaultSvgProcessor(); ISvgConverterProperties props = new DummySvgConverterProperties(); ISvgNodeRenderer rootActual = processor.Process(root, props).GetRootRenderer(); //setup expected IBranchSvgNodeRenderer rootExpected = new DummyBranchSvgNodeRenderer("svg"); rootExpected.AddChild(new DummySvgNodeRenderer("circle")); rootExpected.AddChild(new DummySvgNodeRenderer("path")); IBranchSvgNodeRenderer nestedSvgRend = new DummyBranchSvgNodeRenderer("svg"); nestedSvgRend.AddChild(new DummySvgNodeRenderer("circle")); nestedSvgRend.AddChild(new DummySvgNodeRenderer("circle")); rootExpected.AddChild(nestedSvgRend); //Compare NUnit.Framework.Assert.AreEqual(rootActual, rootExpected); }
public virtual void ProcessNodeWithCustomFactory() { INode svg = new JsoupElementNode(new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), "")); DummySvgConverterProperties props = new DummySvgConverterProperties(); IBranchSvgNodeRenderer node = (IBranchSvgNodeRenderer)SvgConverter.Process(svg, props).GetRootRenderer(); NUnit.Framework.Assert.IsTrue(node is DummySvgNodeRenderer); NUnit.Framework.Assert.AreEqual(0, node.GetChildren().Count); NUnit.Framework.Assert.IsNull(node.GetParent()); }
public virtual void ResourceResolverInstanceCustomResolverTest() { //TODO DEVSIX-3814: remove in version 7.2 DummySvgConverterProperties properties = new DummySvgConverterProperties(); SvgConverterUnitTest.TestSvgProcessorResult testSvgProcessorResult = new SvgConverterUnitTest.TestSvgProcessorResult (this); ResourceResolver currentResolver = SvgConverter.GetResourceResolver(testSvgProcessorResult, properties); NUnit.Framework.Assert.IsNotNull(currentResolver); }
public virtual void ResourceResolverInstanceTest() { DummySvgConverterProperties properties = new DummySvgConverterProperties(); SvgProcessorContext context = new SvgProcessorContext(properties); ResourceResolver initialResolver = context.GetResourceResolver(); SvgProcessorResult svgProcessorResult = new SvgProcessorResult(new Dictionary <String, ISvgNodeRenderer>(), new SvgTagSvgNodeRenderer(), context); ResourceResolver currentResolver = SvgConverter.GetResourceResolver(svgProcessorResult, properties); NUnit.Framework.Assert.AreEqual(initialResolver, currentResolver); }
public virtual void DummyProcessingNoSvgTagInInput() { NUnit.Framework.Assert.That(() => { iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("polygon"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGCircle = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("circle"), ""); INode root = new JsoupElementNode(jsoupSVGRoot); root.AddChild(new JsoupElementNode(jsoupSVGCircle)); //Run DefaultSvgProcessor processor = new DefaultSvgProcessor(); ISvgConverterProperties props = new DummySvgConverterProperties(); processor.Process(root, props).GetRootRenderer(); } , NUnit.Framework.Throws.InstanceOf <SvgProcessingException>().With.Message.EqualTo(SvgLogMessageConstant.NOROOT)) ; }
public virtual void DummyProcessingTestNodeHasNullChild() { iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGCircle = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("circle"), ""); INode root = new JsoupElementNode(jsoupSVGRoot); root.AddChild(new JsoupElementNode(jsoupSVGCircle)); root.AddChild(null); root.AddChild(new JsoupElementNode(jsoupSVGCircle)); //Run DefaultSvgProcessor processor = new DefaultSvgProcessor(); ISvgConverterProperties props = new DummySvgConverterProperties(); ISvgNodeRenderer rootActual = processor.Process(root, props).GetRootRenderer(); //setup expected ISvgNodeRenderer rootExpected = new DummySvgNodeRenderer("svg"); NUnit.Framework.Assert.AreEqual(rootExpected, rootActual); }
public virtual void DummyProcessingSvgTagIsNotRootOfInput() { iText.StyledXmlParser.Jsoup.Nodes.Element jsoupRandomElement = new iText.StyledXmlParser.Jsoup.Nodes.Element (iText.StyledXmlParser.Jsoup.Parser.Tag.ValueOf("body"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGCircle = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("circle"), ""); INode root = new JsoupElementNode(jsoupRandomElement); INode svg = new JsoupElementNode(jsoupSVGRoot); svg.AddChild(new JsoupElementNode(jsoupSVGCircle)); root.AddChild(svg); //Run DefaultSvgProcessor processor = new DefaultSvgProcessor(); ISvgConverterProperties props = new DummySvgConverterProperties(); ISvgNodeRenderer rootActual = processor.Process(root, props).GetRootRenderer(); //setup expected IBranchSvgNodeRenderer rootExpected = new DummyBranchSvgNodeRenderer("svg"); rootExpected.AddChild(new DummySvgNodeRenderer("circle")); NUnit.Framework.Assert.AreEqual(rootActual, rootExpected); }