• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 11160366986

03 Oct 2024 10:33AM UTC coverage: 76.234% (+0.04%) from 76.19%
11160366986

push

github

web-flow
Merge pull request #422 from DomCR/dedicated-boundingbox-tests

Dedicated boundingbox tests

4893 of 7113 branches covered (68.79%)

Branch coverage included in aggregate %.

92 of 119 new or added lines in 12 files covered. (77.31%)

3 existing lines in 2 files now uncovered.

19656 of 25089 relevant lines covered (78.35%)

33305.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.67
/src/ACadSharp/Entities/Hatch.BoundaryPath.cs
1
using ACadSharp.Attributes;
2
using CSMath;
3
using CSUtilities.Extensions;
4
using System.Collections.Generic;
5
using System.Collections.ObjectModel;
6
using System.Collections.Specialized;
7
using System.Linq;
8

9
namespace ACadSharp.Entities
10
{
11
        public partial class Hatch
12
        {
13
                public partial class BoundaryPath : IGeometricEntity
14
                {
15
                        /// <summary>
16
                        /// Flag that indicates that this boundary path is formed by a polyline.
17
                        /// </summary>
18
                        public bool IsPolyline { get { return this.Edges.OfType<Polyline>().Any(); } }
9,192✔
19

20
                        /// <summary>
21
                        /// Boundary path type flag
22
                        /// </summary>
23
                        [DxfCodeValue(92)]
24
                        public BoundaryPathFlags Flags
25
                        {
26
                                get
27
                                {
921✔
28
                                        if (this.IsPolyline)
921✔
29
                                        {
1✔
30
                                                this._flags = this._flags.AddFlag(BoundaryPathFlags.Polyline);
1✔
31
                                        }
1✔
32
                                        else
33
                                        {
920✔
34
                                                this._flags = this._flags.RemoveFlag(BoundaryPathFlags.Polyline);
920✔
35
                                        }
920✔
36

37
                                        return this._flags;
921✔
38
                                }
921✔
39
                                set
40
                                {
713✔
41
                                        this._flags = value;
713✔
42
                                }
713✔
43
                        }
44

45
                        /// <summary>
46
                        /// Number of edges in this boundary path.
47
                        /// </summary>
48
                        /// <remarks>
49
                        /// Only if boundary is not a polyline.
50
                        /// </remarks>
51
                        [DxfCodeValue(DxfReferenceType.Count, 93)]
52
                        public ObservableCollection<Edge> Edges { get; private set; } = new();
10,420✔
53

54
                        /// <summary>
55
                        /// Source boundary objects.
56
                        /// </summary>
57
                        [DxfCodeValue(DxfReferenceType.Count, 97)]
58
                        public List<Entity> Entities { get; set; } = new List<Entity>();
1,637✔
59

60
                        private BoundaryPathFlags _flags;
61

62
                        /// <summary>
63
                        /// Default constructor.
64
                        /// </summary>
65
                        public BoundaryPath()
716✔
66
                        {
716✔
67
                                this.Edges.CollectionChanged += this.onEdgesCollectionChanged;
716✔
68
                        }
716✔
69

70
                        /// <inheritdoc/>
71
                        public BoundingBox GetBoundingBox()
72
                        {
1✔
73
                                BoundingBox box = BoundingBox.Null;
1✔
74

75
                                foreach (Edge edge in this.Edges)
5✔
76
                                {
1✔
77
                                        box = box.Merge(edge.GetBoundingBox());
1✔
78
                                }
1✔
79

80
                                foreach (Entity entity in this.Entities)
3!
NEW
81
                                {
×
NEW
82
                                        box = box.Merge(entity.GetBoundingBox());
×
NEW
83
                                }
×
84

85
                                return box;
1✔
86
                        }
1✔
87

88
                        /// <inheritdoc/>
89
                        public BoundaryPath Clone()
90
                        {
×
NEW
91
                                BoundaryPath path = (BoundaryPath)this.MemberwiseClone();
×
92

NEW
93
                                path.Entities = new List<Entity>();
×
NEW
94
                                path.Entities.AddRange(this.Entities.Select(e => (Entity)e.Clone()));
×
95

NEW
96
                                path.Edges = new ObservableCollection<Edge>(
×
NEW
97
                                        this.Edges.Select(e => e.Clone()));
×
98

NEW
99
                                return path;
×
UNCOV
100
                        }
×
101

102
                        private void onEdgesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
103
                        {
2,857✔
104
                                switch (e.Action)
2,857✔
105
                                {
106
                                        case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
107
                                                this.onAdd(e);
2,857✔
108
                                                break;
2,855✔
109
                                        case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
110
                                                break;
×
111
                                        case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
112
                                                break;
×
113
                                        case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
114
                                                break;
×
115
                                        case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
116
                                                break;
×
117
                                }
118
                        }
2,855✔
119

120
                        private void onAdd(NotifyCollectionChangedEventArgs e)
121
                        {
2,857✔
122
                                foreach (Edge edge in e.NewItems)
14,283✔
123
                                {
2,857✔
124
                                        if (this.Edges.Count > 1 && this.IsPolyline)
2,857✔
125
                                        {
2✔
126
                                                throw new System.InvalidOperationException();
2✔
127
                                        }
128
                                }
2,855✔
129
                        }
2,855✔
130
                }
131
        }
132
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc