public static void Read_XmlDocumentWithTwoEqualSegmentsInInnerLoop_ReturnsLayerGeometryWithExpectedInnerLoop() { // Setup CultureInfo invariantCulture = CultureInfo.InvariantCulture; const double point1 = 1.1; const double point2 = 2.2; string pointString1 = XmlConvert.ToString(point1); string pointString2 = XmlConvert.ToString(point2); XDocument bytes = GetXmlDocument( string.Format(invariantCulture, "<GeometrySurface><OuterLoop/><InnerLoops><GeometryLoop>" + "<CurveList><GeometryCurve>" + "<HeadPoint><X>{0}</X><Y>0.1</Y><Z>{0}</Z></HeadPoint>" + "<EndPoint><X>{1}</X><Y>0.1</Y><Z>{1}</Z></EndPoint>" + "</GeometryCurve><GeometryCurve>" + "<HeadPoint><X>{0}</X><Y>0.1</Y><Z>{0}</Z></HeadPoint>" + "<EndPoint><X>{1}</X><Y>0.1</Y><Z>{1}</Z></EndPoint>" + "</GeometryCurve></CurveList></GeometryLoop></InnerLoops></GeometrySurface>", pointString1, pointString2)); var reader = new SoilLayer2DGeometryReader(); // Call SoilLayer2DGeometry geometry = reader.Read(bytes); // Assert Assert.NotNull(geometry); Assert.AreEqual(new SoilLayer2DLoop(new[] { new Segment2D(new Point2D(point1, point1), new Point2D(point2, point2)), new Segment2D(new Point2D(point2, point2), new Point2D(point1, point1)) }), geometry.InnerLoops.ElementAt(0)); }
public void Constructor_ExpectedPropertiesSet() { // Setup var outerLoop = new SoilLayer2DLoop(new Segment2D[0]); IEnumerable <SoilLayer2DLoop> innerLoops = Enumerable.Empty <SoilLayer2DLoop>(); // Call var geometry = new SoilLayer2DGeometry(outerLoop, innerLoops); // Assert Assert.AreSame(outerLoop, geometry.OuterLoop); Assert.AreSame(innerLoops, geometry.InnerLoops); }
public static void Read_XmlDocumentWithScrambledSegmentsInInnerLoop_ReturnsLayerGeometryWithInnerLoopWithSortedSegments( [Values(true, false)] bool firstSegmentInverted, [Values(true, false)] bool secondSegmentInverted) { // Setup CultureInfo invariantCulture = CultureInfo.InvariantCulture; double point1 = firstSegmentInverted ? 2.2 : 1.1; double point2 = firstSegmentInverted ? 1.1 : 2.2; double point3 = secondSegmentInverted ? 3.3 : 2.2; double point4 = secondSegmentInverted ? 2.2 : 3.3; const double point5 = 3.3; const double point6 = 1.1; string pointString1 = XmlConvert.ToString(point1); string pointString2 = XmlConvert.ToString(point2); string pointString3 = XmlConvert.ToString(point3); string pointString4 = XmlConvert.ToString(point4); string pointString5 = XmlConvert.ToString(point5); string pointString6 = XmlConvert.ToString(point6); XDocument bytes = GetXmlDocument( string.Format(invariantCulture, "<GeometrySurface><OuterLoop/><InnerLoops><GeometryLoop>" + "<CurveList><GeometryCurve>" + "<HeadPoint><X>{0}</X><Y>0.1</Y><Z>{0}</Z></HeadPoint>" + "<EndPoint><X>{1}</X><Y>0.1</Y><Z>{1}</Z></EndPoint>" + "</GeometryCurve><GeometryCurve>" + "<HeadPoint><X>{2}</X><Y>0.1</Y><Z>{2}</Z></HeadPoint>" + "<EndPoint><X>{3}</X><Y>0.1</Y><Z>{3}</Z></EndPoint>" + "</GeometryCurve><GeometryCurve>" + "<HeadPoint><X>{4}</X><Y>0.1</Y><Z>{4}</Z></HeadPoint>" + "<EndPoint><X>{5}</X><Y>0.1</Y><Z>{5}</Z></EndPoint>" + "</GeometryCurve></CurveList></GeometryLoop></InnerLoops></GeometrySurface>", pointString1, pointString2, pointString3, pointString4, pointString5, pointString6)); var reader = new SoilLayer2DGeometryReader(); // Call SoilLayer2DGeometry geometry = reader.Read(bytes); // Assert Assert.NotNull(geometry); Assert.AreEqual(new SoilLayer2DLoop(new[] { new Segment2D(new Point2D(1.1, 1.1), new Point2D(2.2, 2.2)), new Segment2D(new Point2D(2.2, 2.2), new Point2D(3.3, 3.3)), new Segment2D(new Point2D(3.3, 3.3), new Point2D(1.1, 1.1)) }), geometry.InnerLoops.ElementAt(0)); }
public void Read_XmlDocumentWithEmptyInnerLoopsAndEmptyOuterLoop_ReturnsLayerGeometryWithoutInnerLoopsAndWithEmptyOuterLoop() { // Setup XDocument xmlDoc = GetXmlDocument("<GeometrySurface><OuterLoop/><InnerLoops/></GeometrySurface>"); var reader = new SoilLayer2DGeometryReader(); // Call SoilLayer2DGeometry geometry = reader.Read(xmlDoc); // Assert Assert.NotNull(geometry); CollectionAssert.IsEmpty(geometry.OuterLoop.Segments); Assert.AreEqual(0, geometry.InnerLoops.Count()); }