Exemplo n.º 1
0
        public void XmlTests(string p1s, string p2s, string xml)
        {
            Point3D p1 = Point3D.Parse(p1s);
            Point3D p2 = Point3D.Parse(p2s);
            var     l  = new Line3D(p1, p2);

            AssertXml.XmlRoundTrips(l, xml, (e, a) => AssertGeometry.AreEqual(e, a));
        }
Exemplo n.º 2
0
        public void XmlRoundTrips()
        {
            var          cs       = new CoordinateSystem(new Point3D(1, -2, 3), new Vector3D(0, 1, 0), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0));
            const string expected = @"
<CoordinateSystem>
    <Origin X=""1"" Y=""-2"" Z=""3"" />
    <XAxis X=""0"" Y=""1"" Z=""0"" />
    <YAxis X=""0"" Y=""0"" Z=""1"" />
    <ZAxis X=""1"" Y=""0"" Z=""0"" />
</CoordinateSystem>";

            AssertXml.XmlRoundTrips(cs, expected, (e, a) => AssertGeometry.AreEqual(e, a));
        }
Exemplo n.º 3
0
        public void XmlRoundTrips()
        {
            var uv         = new UnitVector3D(0.2672612419124244, -0.53452248382484879, 0.80178372573727319);
            var xml        = @"<UnitVector3D X=""0.2672612419124244"" Y=""-0.53452248382484879"" Z=""0.80178372573727319"" />";
            var elementXml = @"<UnitVector3D><X>0.2672612419124244</X><Y>-0.53452248382484879</Y><Z>0.80178372573727319</Z></UnitVector3D>";

            AssertXml.XmlRoundTrips(uv, xml, (e, a) => AssertGeometry.AreEqual(e, a));
            var serializer = new XmlSerializer(typeof(UnitVector3D));
            var actuals    = new[]
            {
                UnitVector3D.ReadFrom(XmlReader.Create(new StringReader(xml))),
                (UnitVector3D)serializer.Deserialize(new StringReader(xml)),
                (UnitVector3D)serializer.Deserialize(new StringReader(elementXml))
            };

            foreach (var actual in actuals)
            {
                AssertGeometry.AreEqual(uv, actual);
            }
        }
Exemplo n.º 4
0
        public void XmlRoundtrip()
        {
            var          p          = new Point3D(1, -2, 3);
            const string Xml        = @"<Point3D X=""1"" Y=""-2"" Z=""3"" />";
            const string ElementXml = @"<Point3D><X>1</X><Y>-2</Y><Z>3</Z></Point3D>";

            AssertXml.XmlRoundTrips(p, Xml, (expected, actual) => AssertGeometry.AreEqual(expected, actual));
            var serializer = new XmlSerializer(typeof(Point3D));

            var actuals = new[]
            {
                Point3D.ReadFrom(XmlReader.Create(new StringReader(Xml))),
                Point3D.ReadFrom(XmlReader.Create(new StringReader(ElementXml))),
                (Point3D)serializer.Deserialize(new StringReader(Xml)),
                (Point3D)serializer.Deserialize(new StringReader(ElementXml))
            };

            foreach (var actual in actuals)
            {
                AssertGeometry.AreEqual(p, actual);
            }
        }
Exemplo n.º 5
0
        public void XmlRountrip()
        {
            var          p          = new Point2D(1, 2);
            const string Xml        = @"<Point2D X=""1"" Y=""2"" />";
            const string ElementXml = @"<Point2D><X>1</X><Y>2</Y></Point2D>";

            AssertXml.XmlRoundTrips(p, Xml, (e, a) => AssertGeometry.AreEqual(e, a));
            var serializer = new XmlSerializer(typeof(Point2D));

            var actuals = new[]
            {
                Point2D.ReadFrom(XmlReader.Create(new StringReader(Xml))),
                Point2D.ReadFrom(XmlReader.Create(new StringReader(ElementXml))),
                (Point2D)serializer.Deserialize(new StringReader(Xml)),
                (Point2D)serializer.Deserialize(new StringReader(ElementXml))
            };

            foreach (var actual in actuals)
            {
                AssertGeometry.AreEqual(p, actual);
            }
        }
Exemplo n.º 6
0
        public void XmlRoundtrip()
        {
            const string Xml        = @"<Vector2D X=""1"" Y=""2"" />";
            const string ElementXml = @"<Vector2D><X>1</X><Y>2</Y></Vector2D>";
            var          v          = new Vector2D(1, 2);

            AssertXml.XmlRoundTrips(v, Xml, (e, a) => AssertGeometry.AreEqual(e, a));

            var serializer = new XmlSerializer(typeof(Vector2D));


            var actuals = new[]
            {
                Vector2D.ReadFrom(XmlReader.Create(new StringReader(Xml))),
                Vector2D.ReadFrom(XmlReader.Create(new StringReader(ElementXml))),
                (Vector2D)serializer.Deserialize(new StringReader(Xml)),
                (Vector2D)serializer.Deserialize(new StringReader(ElementXml))
            };

            foreach (var actual in actuals)
            {
                AssertGeometry.AreEqual(v, actual);
            }
        }
Exemplo n.º 7
0
        public void XmlRoundTrips(string p1s, string xml)
        {
            var plane = Plane.Parse(p1s);

            AssertXml.XmlRoundTrips(plane, xml, (e, a) => AssertGeometry.AreEqual(e, a));
        }
Exemplo n.º 8
0
        public void XmlTests(string ps, string vs, bool asElements, string xml)
        {
            var ray = new Ray3D(Point3D.Parse(ps), UnitVector3D.Parse(vs));

            AssertXml.XmlRoundTrips(ray, xml, (e, a) => AssertGeometry.AreEqual(e, a, 1e-6));
        }