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

MeindertN / RoboClerk / 14626972474

23 Apr 2025 07:59PM UTC coverage: 78.447% (-4.1%) from 82.581%
14626972474

push

github

MeindertN
WIP: Fixed existing tests

1142 of 1418 branches covered (80.54%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

179 existing lines in 5 files now uncovered.

3728 of 4790 relevant lines covered (77.83%)

103.44 hits per line

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

15.24
/RoboClerk/PluginSupport/DataSourcePluginBase.cs
1
using System;
2
using System.Collections.Generic;
3
using System.IO.Abstractions;
4
using System.Reflection;
5
using System.Text;
6
using System.Text.RegularExpressions;
7

8
namespace RoboClerk
9
{
10
    public abstract class DataSourcePluginBase : PluginBase, IDataSourcePlugin
11
    {
12
        protected List<RequirementItem> systemRequirements = new List<RequirementItem>();
17✔
13
        protected List<RequirementItem> softwareRequirements = new List<RequirementItem>();
17✔
14
        protected List<RequirementItem> documentationRequirements = new List<RequirementItem>();
17✔
15
        protected List<SoftwareSystemTestItem> testCases = new List<SoftwareSystemTestItem>();
17✔
16
        protected List<AnomalyItem> anomalies = new List<AnomalyItem>();
17✔
17
        protected List<RiskItem> risks = new List<RiskItem>();
17✔
18
        protected List<SOUPItem> soup = new List<SOUPItem>();
17✔
19
        protected List<DocContentItem> docContents = new List<DocContentItem>();
17✔
20
        protected List<UnitTestItem> unitTests = new List<UnitTestItem>();
17✔
21
        protected List<ExternalDependency> dependencies = new List<ExternalDependency>();
17✔
22
        protected List<TestResult> testResults = new List<TestResult>();
17✔
23
        //we also keep track of any items that have been eliminated
24
        protected List<EliminatedRequirementItem> eliminatedSystemRequirements = new List<EliminatedRequirementItem>();
17✔
25
        protected List<EliminatedRequirementItem> eliminatedSoftwareRequirements = new List<EliminatedRequirementItem>();
17✔
26
        protected List<EliminatedRequirementItem> eliminatedDocumentationRequirements = new List<EliminatedRequirementItem>();
17✔
27
        protected List<EliminatedSoftwareSystemTestItem> eliminatedSoftwareSystemTests = new List<EliminatedSoftwareSystemTestItem>();
17✔
28
        protected List<EliminatedRiskItem> eliminatedRisks = new List<EliminatedRiskItem>();
17✔
29
        protected List<EliminatedDocContentItem> eliminatedDocContents = new List<EliminatedDocContentItem>();
17✔
30
        protected List<EliminatedSOUPItem> eliminatedSOUP = new List<EliminatedSOUPItem>();
17✔
31
        protected List<EliminatedAnomalyItem> eliminatedAnomalies = new List<EliminatedAnomalyItem>();
17✔
32

33
        public DataSourcePluginBase(IFileSystem fileSystem)
34
            :base(fileSystem)
17✔
35
        {
17✔
36

37
        }
17✔
38

39
        public abstract void RefreshItems();
40

41
        public IEnumerable<AnomalyItem> GetAnomalies()
UNCOV
42
        {
×
43
            return anomalies;
×
44
        }
×
45

46
        public IEnumerable<RequirementItem> GetSystemRequirements()
UNCOV
47
        {
×
48
            return systemRequirements;
×
49
        }
×
50

51
        public IEnumerable<RequirementItem> GetSoftwareRequirements()
UNCOV
52
        {
×
53
            return softwareRequirements;
×
54
        }
×
55

56
        public IEnumerable<RequirementItem> GetDocumentationRequirements()
UNCOV
57
        {
×
58
            return documentationRequirements;
×
59
        }
×
60

61
        public IEnumerable<DocContentItem> GetDocContents()
UNCOV
62
        {
×
63
            return docContents;
×
64
        }
×
65

66
        public IEnumerable<SoftwareSystemTestItem> GetSoftwareSystemTests()
UNCOV
67
        {
×
68
            return testCases;
×
69
        }
×
70

71
        public IEnumerable<RiskItem> GetRisks()
UNCOV
72
        {
×
UNCOV
73
            return risks;
×
UNCOV
74
        }
×
75

76
        public IEnumerable<SOUPItem> GetSOUP()
UNCOV
77
        {
×
78
            return soup;
×
79
        }
×
80

81
        public IEnumerable<UnitTestItem> GetUnitTests()
82
        {
1✔
83
            return unitTests;
1✔
84
        }
1✔
85

86
        public IEnumerable<ExternalDependency> GetDependencies()
UNCOV
87
        {
×
88
            return dependencies;
×
89
        }
×
90

91
        public IEnumerable<TestResult> GetTestResults()
92
        {
×
93
            return testResults;
×
94
        }
×
95

96
        public IEnumerable<EliminatedRequirementItem> GetEliminatedSystemRequirements()
97
        {
×
98
            return eliminatedSystemRequirements;
×
99
        }
×
100

101
        public IEnumerable<EliminatedRequirementItem> GetEliminatedSoftwareRequirements()
UNCOV
102
        {
×
103
            return eliminatedSoftwareRequirements;
×
104
        }
×
105

106
        public IEnumerable<EliminatedRequirementItem> GetEliminatedDocumentationRequirements()
107
        {
×
108
            return eliminatedDocumentationRequirements;
×
UNCOV
109
        }
×
110

111
        public IEnumerable<EliminatedSoftwareSystemTestItem> GetEliminatedSoftwareSystemTests()
UNCOV
112
        {
×
113
            return eliminatedSoftwareSystemTests;
×
114
        }
×
115

116
        public IEnumerable<EliminatedRiskItem> GetEliminatedRisks()
UNCOV
117
        {
×
118
            return eliminatedRisks;
×
UNCOV
119
        }
×
120

121
        public IEnumerable<EliminatedDocContentItem> GetEliminatedDocContents()
122
        {
×
123
            return eliminatedDocContents;
×
124
        }
×
125

126
        public IEnumerable<EliminatedAnomalyItem> GetEliminatedAnomalies()
UNCOV
127
        {
×
128
            return eliminatedAnomalies;
×
129
        }
×
130

131
        public IEnumerable<EliminatedSOUPItem> GetEliminatedSOUP()
132
        {
×
UNCOV
133
            return eliminatedSOUP;
×
134
        }
×
135

136
        protected void ClearAllItems()
137
        {
×
138
            systemRequirements.Clear();
×
139
            softwareRequirements.Clear();
×
140
            documentationRequirements.Clear();
×
UNCOV
141
            testCases.Clear();
×
142
            anomalies.Clear();
×
143
            risks.Clear();
×
144
            soup.Clear();
×
145
            docContents.Clear();
×
146
            unitTests.Clear();
×
147
            dependencies.Clear();
×
148
            testResults.Clear();
×
UNCOV
149
            eliminatedSystemRequirements.Clear();
×
UNCOV
150
            eliminatedSoftwareRequirements.Clear();
×
UNCOV
151
            eliminatedDocumentationRequirements.Clear();
×
UNCOV
152
            eliminatedSoftwareSystemTests.Clear();
×
153
        }
×
154

155
        private string EscapeNonTablePipes(string text)
156
        {
×
157
            string tableBlockPattern = @"(?ms)(^\|===\s*$.*?^\|===\s*$)";
×
158

159
            // Use Regex.Split with a capturing group so that the table blocks are kept in the result.
160
            string[] segments = Regex.Split(text, tableBlockPattern);
×
161
            var sb = new StringBuilder();
×
162

163
            foreach (string segment in segments)
×
164
            {
×
165
                // If the segment itself matches our table block pattern, leave it unmodified.
166
                if (Regex.IsMatch(segment, @"(?ms)^\|===\s*$.*?^\|===\s*$"))
×
167
                {
×
168
                    sb.Append(segment);
×
UNCOV
169
                }
×
170
                else
UNCOV
171
                {
×
172
                    // Otherwise, escape any unescaped "|" in this segment.
UNCOV
173
                    string processed = Regex.Replace(segment, @"(?<!\\)\|", @"\|");
×
UNCOV
174
                    sb.Append(processed);
×
UNCOV
175
                }
×
UNCOV
176
            }
×
UNCOV
177
            return sb.ToString();
×
UNCOV
178
        }
×
179

180
        private void ScrubItemsFields<T>(IEnumerable<T> items)
UNCOV
181
        {
×
UNCOV
182
            foreach (var obj in items)
×
UNCOV
183
            {
×
UNCOV
184
                Type type = obj.GetType();
×
UNCOV
185
                PropertyInfo[] properties = type.GetProperties();
×
186

UNCOV
187
                foreach (PropertyInfo property in properties)
×
UNCOV
188
                {
×
UNCOV
189
                    if (property.PropertyType == typeof(string) && property.CanWrite)
×
UNCOV
190
                    {
×
UNCOV
191
                        string currentValue = (string)property.GetValue(obj);
×
UNCOV
192
                        if (currentValue != null)
×
UNCOV
193
                        {
×
194
                            // Escape pipes in non-table parts of the content.
UNCOV
195
                            string newValue = EscapeNonTablePipes(currentValue);
×
UNCOV
196
                            property.SetValue(obj, newValue);
×
UNCOV
197
                        }
×
UNCOV
198
                    }
×
UNCOV
199
                }
×
UNCOV
200
            }
×
UNCOV
201
        }
×
202

203
        // with the exception of docContent items, all other items are visualized
204
        // in tables and they need to escape the | character
205
        protected void ScrubItemContents()
UNCOV
206
        {
×
UNCOV
207
            ScrubItemsFields(systemRequirements);
×
UNCOV
208
            ScrubItemsFields(softwareRequirements);
×
UNCOV
209
            ScrubItemsFields(documentationRequirements);
×
UNCOV
210
            ScrubItemsFields(testCases);
×
UNCOV
211
            foreach (var testCase in testCases)
×
UNCOV
212
            {
×
UNCOV
213
                ScrubItemsFields(testCase.TestCaseSteps);
×
UNCOV
214
            }
×
UNCOV
215
            ScrubItemsFields(anomalies);
×
UNCOV
216
            ScrubItemsFields(risks);
×
UNCOV
217
            ScrubItemsFields(soup);
×
UNCOV
218
            ScrubItemsFields(unitTests);
×
UNCOV
219
            ScrubItemsFields(dependencies);
×
UNCOV
220
            ScrubItemsFields(testResults);
×
UNCOV
221
        }
×
222
    }
223
}
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