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

DomCR / ACadSharp / 13817713986

12 Mar 2025 05:27PM UTC coverage: 76.2% (-0.01%) from 76.21%
13817713986

push

github

web-flow
Merge pull request #576 from DomCR/issue-575_write-group

Write Group

5490 of 7909 branches covered (69.41%)

Branch coverage included in aggregate %.

66 of 106 new or added lines in 8 files covered. (62.26%)

3 existing lines in 2 files now uncovered.

21657 of 27717 relevant lines covered (78.14%)

75614.07 hits per line

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

53.33
/src/ACadSharp/Objects/Collections/GroupCollection.cs
1
using ACadSharp.Entities;
2
using System;
3
using System.Collections.Generic;
4
using System.Linq;
5
using System.Text.RegularExpressions;
6

7
namespace ACadSharp.Objects.Collections
8
{
9
        public class GroupCollection : ObjectDictionaryCollection<Group>
10
        {
11
                public GroupCollection(CadDictionary dictionary) : base(dictionary)
569✔
12
                {
569✔
13
                        this._dictionary = dictionary;
569✔
14
                }
569✔
15

16
                /// <inheritdoc/>
17
                public override void Add(Group entry)
18
                {
2✔
19
                        foreach (var e in entry.Entities)
7✔
20
                        {
1✔
21
                                if (e.Document != this._dictionary.Document)
1!
22
                                {
1✔
23
                                        throw new InvalidOperationException("Entities in a group must be in the same document as the group being added.");
1✔
24
                                }
NEW
25
                        }
×
26

27
                        if (entry.IsUnnamed)
1✔
28
                        {
1✔
29
                                int next = 0;
1✔
30
                                foreach (Group group in this.Where(g => g.IsUnnamed))
3!
NEW
31
                                {
×
NEW
32
                                        var num = int.Parse(Regex.Match(group.Name, @"\d+").Value);
×
NEW
33
                                        if (num > next)
×
NEW
34
                                        {
×
NEW
35
                                                next = num;
×
NEW
36
                                        }
×
NEW
37
                                }
×
38

39
                                entry.Name = $"*D{next++}";
1✔
40
                        }
1✔
41

42
                        base.Add(entry);
1✔
43
                }
1✔
44

45
                /// <summary>
46
                /// Creates a group with a collection of entities.
47
                /// </summary>
48
                /// <remarks>
49
                /// The entities must be assigned to the owner <see cref="CadDocument"/> of this collection.
50
                /// </remarks>
51
                /// <param name="entities"></param>
52
                /// <returns></returns>
53
                public Group CreateGroup(IEnumerable<Entity> entities)
NEW
54
                {
×
NEW
55
                        return this.CreateGroup(string.Empty, entities);
×
NEW
56
                }
×
57

58
                /// <summary>
59
                /// Creates a group with a collection of entities.
60
                /// </summary>
61
                /// <remarks>
62
                /// The entities must be assigned to the owner <see cref="CadDocument"/> of this collection.
63
                /// </remarks>
64
                /// <param name="name"></param>
65
                /// <param name="entities"></param>
66
                /// <returns></returns>
67
                public Group CreateGroup(string name, IEnumerable<Entity> entities)
NEW
68
                {
×
NEW
69
                        var group = new Group(name);
×
NEW
70
                        this.Add(group);
×
NEW
71
                        group.AddRange(entities);
×
NEW
72
                        return group;
×
NEW
73
                }
×
74
        }
75
}
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