Core.Shapes.Sketch CreateSketch(SketchType sketchType)
        {
            var sketch = new Core.Shapes.Sketch();

            Assert.IsNotNull(sketch);

            var body = TestGeomGenerator.CreateBody(sketch);

            body.Rotation = new Quaternion(Dir.DZ.ToVec(), new Vec(0.4, 0.5, 0.1));

            sketch.Points.Add(0, new Pnt2d(0, 30));
            sketch.Points.Add(1, new Pnt2d(20, 30));
            sketch.Segments.Add(0, new SketchSegmentLine(0, 1));

            sketch.Points.Add(2, new Pnt2d(30, 0));
            sketch.Points.Add(3, new Pnt2d(30, 20));
            sketch.Segments.Add(1, new SketchSegmentArc(1, 2, 3));

            sketch.Points.Add(4, new Pnt2d(10, 0));
            sketch.Points.Add(5, new Pnt2d(0, -20));
            sketch.Segments.Add(2, new SketchSegmentBezier(2, 4, 5));

            sketch.Segments.Add(3, new SketchSegmentLine(5, 0));

            if (sketchType == SketchType.MultiCurve)
            {
                sketch.Points.Add(6, new Pnt2d(5, 10));
                sketch.Points.Add(7, new Pnt2d(10, 0));
                sketch.Points.Add(8, new Pnt2d(5, -10));
                sketch.Segments.Add(4, new SketchSegmentLine(6, 7));
                sketch.Segments.Add(5, new SketchSegmentLine(7, 8));
                sketch.Segments.Add(6, new SketchSegmentLine(8, 6));
            }
            return(sketch);
        }
        public void OneInvalidSegment()
        {
            // Create a sketch with one valid and one invalid line.
            // This should result in a valid brep with one edge, throwing
            // a warning instead of an error.

            var sketch = new Core.Shapes.Sketch();

            Assert.IsNotNull(sketch);
            sketch.Points.Add(0, new Pnt2d(0, 30));
            sketch.Points.Add(1, new Pnt2d(20, 30));
            sketch.Segments.Add(0, new SketchSegmentLine(0, 1));
            sketch.Segments.Add(1, new SketchSegmentLine(1, 1));

            Assert.IsTrue(sketch.Make(Shape.MakeFlags.None));
            Assert.IsNotNull(sketch.GetBRep());
            Assert.AreEqual(1, sketch.GetBRep().Edges().Count);

            var messages = Context.Current.MessageHandler.GetEntityMessages(sketch);

            Assert.AreEqual(1, messages.Count);
            Assert.AreEqual(MessageSeverity.Warning, messages[0].Severity);
        }