public void EmptyElementHasZeroPolygons() { var reader = new SvgReader(new System.Xml.Linq.XElement("test")); IEnumerable <Polygon> lp = reader.ExtractPolygons(); Assert.AreEqual(0, lp.Count()); }
public void XmlWithOneElementHasCorrectPolygon() { var reader = new SvgReader(System.Xml.Linq.XElement.Parse( " <svg><polygon\n points=\"1088.95,2511.82 1169.85,2570.6 1138.95,2475.49 1058.05,2416.71 \" /></svg>" )); IEnumerable <Polygon> lp = reader.ExtractPolygons(); Assert.IsTrue(lp.Where(poly => poly.Vertices.Where(pt => Math.Abs(pt.X - 1058.05) < 1e-8 && Math.Abs(pt.Y - 2416.71) < 1e-8).Any()).Any()); }
public void XmlWithOneElementHasOnePolygon() { var reader = new SvgReader(System.Xml.Linq.XElement.Parse( " <svg><polygon\n points=\"1088.95,2511.82 1169.85,2570.6 1138.95,2475.49 1058.05,2416.71 \" transform=\"matrix(0.05880683,0,0,0.0624649,-51.602926,-159.78388)\" /></svg>" )); IEnumerable <Polygon> lp = reader.ExtractPolygons(); Assert.AreEqual(1, lp.Count()); }
public void XmlWithTwoElementHasTwoPolygons() { var reader = new SvgReader(System.Xml.Linq.XElement.Parse( "<svg>" + "<polygon\n points=\"1,2 3,4 5,6 \" />" + "<polygon\n points=\"1088.95,2511.82 1169.85,2570.6 1138.95,2475.49 1058.05,2416.71 \"/></svg>" )); IEnumerable <Polygon> lp = reader.ExtractPolygons(); Assert.AreEqual(2, lp.Count()); }
public void DefaultFillForUndefinedColor() { var source = System.Xml.Linq.XElement.Parse( "<svg>" + "<polygon\n points=\"1,2 3,4 5,6 \" style=\"fill:#bcdaa0;stroke:#000000;stroke-width:1\"/>" + "</svg>" ); var reader = new SvgReader(source); IEnumerable <Polygon> lp = reader.ExtractPolygons(); Assert.AreEqual("fill:#bcdaa0", lp.First().Color); }
public void XmlWithTwoNestedElementsHasTwoPolygons() { var reader = new SvgReader(System.Xml.Linq.XElement.Parse( "<svg>" + "<polygon\n points=\"1,2 3,4 5,6 \"/>" + "<group>" + "<polygon\n points=\"3,4 5,6 7,8\"/>" + "</group>" + "</svg>" )); IEnumerable <Polygon> lp = reader.ExtractPolygons(); Assert.AreEqual(2, lp.Count()); }