public void PlaneXml(string rootPoint, string unitVector, string xml) { var plane = new Plane(Point3D.Parse(rootPoint), UnitVector3D.Parse(unitVector)); var result = AssertXml.XmlSerializerRoundTrip(plane, xml); Assert.AreEqual(plane, result); }
public void AngleXml(string vs, string xml) { var angle = Angle.Parse(vs); var result = AssertXml.XmlSerializerRoundTrip(angle, xml); Assert.AreEqual(angle.Radians, result.Radians, Tolerance); }
public void Circle2DXml(string point, double radius, string xml) { var center = Point2D.Parse(point); var c = new Circle2D(center, radius); var result = AssertXml.XmlSerializerRoundTrip(c, xml); Assert.AreEqual(c, result); }
public void Vector3DXml() { var v = new Vector3D(1, -2, 3); const string Xml = @"<Vector3D X=""1"" Y=""-2"" Z=""3"" />"; var result = AssertXml.XmlSerializerRoundTrip(v, Xml); Assert.AreEqual(v, result); }
public void QuaternionXml() { var q = new Quaternion(1, 2, 3, 4); const string Xml = @"<Quaternion W=""1"" X=""2"" Y=""3"" Z=""4"" />"; var result = AssertXml.XmlSerializerRoundTrip(q, Xml); Assert.AreEqual(q, result); }
public void Point2DXml() { var p = new Point2D(1, 2); const string Xml = @"<Point2D X=""1"" Y=""2"" />"; var result = AssertXml.XmlSerializerRoundTrip(p, Xml); Assert.AreEqual(p, result); }
public void Ray3DXml(string ps, string vs, bool asElements, string xml) { var ray = new Ray3D(Point3D.Parse(ps), UnitVector3D.Parse(vs)); var result = AssertXml.XmlSerializerRoundTrip(ray, xml); Assert.AreEqual(ray, result); AssertGeometry.AreEqual(ray, result, Tolerance); }
public void LineSegement2DXml(string p1s, string p2s, string xml) { Point2D p1 = Point2D.Parse(p1s); Point2D p2 = Point2D.Parse(p2s); var l = new LineSegment2D(p1, p2); var result = AssertXml.XmlSerializerRoundTrip(l, xml); Assert.AreEqual(l, result); }
public void EulerAnglesXml() { var q = new Quaternion(0, 0, 0, 0); var eulerAngles = q.ToEulerAngles(); const string Xml = @"<EulerAngles><Alpha Value=""0""></Alpha><Beta Value=""0""></Beta><Gamma Value=""0""></Gamma></EulerAngles>"; var result = AssertXml.XmlSerializerRoundTrip(eulerAngles, Xml); Assert.AreEqual(eulerAngles, result); }
public void PolyLine3DXml() { var points = "0, -1.5, 0; 0,1,0; 1,1,0"; var p = new PolyLine3D(from x in points.Split(';') select Point3D.Parse(x)); const string Xml = @"<PolyLine3D><Points><Point X=""0.25"" Y=""0"" /><Point X=""0.5"" Y=""1"" /><Point X=""1"" Y=""-1"" /></Points></PolyLine3D>"; var result = AssertXml.XmlSerializerRoundTrip(p, Xml); Assert.AreEqual(p, result); }
public void PolyLine2DXml() { var points = from x in new string[] { "0.25,0", "0.5,1", "1,-1" } select Point2D.Parse(x); var p = new PolyLine2D(points); const string Xml = @"<PolyLine2D><Points><Point X=""0.25"" Y=""0"" /><Point X=""0.5"" Y=""1"" /><Point X=""1"" Y=""-1"" /></Points></PolyLine2D>"; var result = AssertXml.XmlSerializerRoundTrip(p, Xml); Assert.AreEqual(p, result); }
public void CoordinateSystemXml() { var cs = new CoordinateSystem(new Point3D(1, -2, 3), new Vector3D(0, 1, 0), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); string xml = @" <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>"; var result = AssertXml.XmlSerializerRoundTrip(cs, xml); AssertGeometry.AreEqual(cs, result); }
public void XmlContainerRoundtrip() { var container = new AssertXml.Container <Angle> { Value1 = Angle.FromRadians(1), Value2 = Angle.FromRadians(2), }; var expected = "<ContainerOfAngle>\r\n" + " <Value1 Value=\"1\"></Value1>\r\n" + " <Value2 Value=\"2\"></Value2>\r\n" + "</ContainerOfAngle>"; var roundTrip = AssertXml.XmlSerializerRoundTrip(container, expected); Assert.AreEqual(container.Value1, roundTrip.Value1); Assert.AreEqual(container.Value2, roundTrip.Value2); }
public void XmlContainerRoundtrip() { var container = new AssertXml.Container <Point3D> { Value1 = new Point3D(1, 2, 3), Value2 = new Point3D(4, 5, 6) }; var expected = "<ContainerOfPoint3D>\r\n" + " <Value1 X=\"1\" Y=\"2\" Z=\"3\"></Value1>\r\n" + " <Value2 X=\"4\" Y=\"5\" Z=\"6\"></Value2>\r\n" + "</ContainerOfPoint3D>"; var roundTrip = AssertXml.XmlSerializerRoundTrip(container, expected); AssertGeometry.AreEqual(container.Value1, roundTrip.Value1); AssertGeometry.AreEqual(container.Value2, roundTrip.Value2); }
public void XmlContainerRoundtrip() { var container = new AssertXml.Container <Vector2D> { Value1 = new Vector2D(1, 2), Value2 = new Vector2D(3, 4) }; var expected = "<ContainerOfVector2D>\r\n" + " <Value1 X=\"1\" Y=\"2\"></Value1>\r\n" + " <Value2 X=\"3\" Y=\"4\"></Value2>\r\n" + "</ContainerOfVector2D>"; var roundTrip = AssertXml.XmlSerializerRoundTrip(container, expected); AssertGeometry.AreEqual(container.Value1, roundTrip.Value1); AssertGeometry.AreEqual(container.Value2, roundTrip.Value2); }
public void XmlContainerRoundtrip() { var container = new AssertXml.Container <UnitVector3D> { Value1 = UnitVector3D.Create(0.2672612419124244, -0.53452248382484879, 0.80178372573727319), Value2 = UnitVector3D.Create(1, 0, 0) }; var expected = "<ContainerOfUnitVector3D>\r\n" + " <Value1 X=\"0.2672612419124244\" Y=\"-0.53452248382484879\" Z=\"0.80178372573727319\"></Value1>\r\n" + " <Value2 X=\"1\" Y=\"0\" Z=\"0\"></Value2>\r\n" + "</ContainerOfUnitVector3D>"; var roundTrip = AssertXml.XmlSerializerRoundTrip(container, expected); AssertGeometry.AreEqual(container.Value1, roundTrip.Value1); AssertGeometry.AreEqual(container.Value2, roundTrip.Value2); }
public void SerializeDeserialize() { var v = new Vector3D(1, -2, 3); const string Xml = @"<Vector3D X=""1"" Y=""-2"" Z=""3"" />"; const string ElementXml = @"<Vector3D><X>1</X><Y>-2</Y><Z>3</Z></Vector3D>"; var roundTrip = AssertXml.XmlSerializerRoundTrip(v, Xml); AssertGeometry.AreEqual(v, roundTrip); var serializer = new XmlSerializer(typeof(Vector3D)); var actuals = new[] { Vector3D.ReadFrom(XmlReader.Create(new StringReader(Xml))), Vector3D.ReadFrom(XmlReader.Create(new StringReader(ElementXml))), (Vector3D)serializer.Deserialize(new StringReader(Xml)), (Vector3D)serializer.Deserialize(new StringReader(ElementXml)) }; foreach (var actual in actuals) { AssertGeometry.AreEqual(v, actual); } }