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

MeindertN / RoboClerk / 17884132551

20 Sep 2025 07:49PM UTC coverage: 84.243% (+0.09%) from 84.152%
17884132551

push

github

MeindertN
WIP: results are now linked items that get linked to the test items (both unit and system tests).

1903 of 2353 branches covered (80.88%)

Branch coverage included in aggregate %.

40 of 49 new or added lines in 5 files covered. (81.63%)

5828 of 6824 relevant lines covered (85.4%)

128.01 hits per line

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

97.46
/RoboClerk/DataSources/DataSourcesBase.cs
1
using RoboClerk.Configuration;
2
using RoboClerk.Items;
3
using System;
4
using System.Collections.Generic;
5
using System.IO;
6
using System.IO.Abstractions;
7
using System.Linq;
8
using System.Text.Json;
9

10
namespace RoboClerk
11
{
12
    public abstract class DataSourcesBase : IDataSources
13
    {
14
        protected readonly IConfiguration configuration = null;
51✔
15
        protected readonly IFileSystem fileSystem = null;
51✔
16
        protected static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
1✔
17

18
        public DataSourcesBase(IConfiguration configuration, IFileSystem fileSystem)
51✔
19
        {
51✔
20
            this.configuration = configuration;
51✔
21
            this.fileSystem = fileSystem;
51✔
22
        }
51✔
23

24
        public abstract List<SOUPItem> GetAllSOUP();
25

26
        public abstract List<EliminatedSOUPItem> GetAllEliminatedSOUP();
27

28
        public abstract List<RiskItem> GetAllRisks();
29

30
        public abstract List<EliminatedRiskItem> GetAllEliminatedRisks();
31

32
        public abstract List<ExternalDependency> GetAllExternalDependencies();
33

34
        public abstract List<TestResult> GetAllTestResults();
35

36
        public abstract List<UnitTestItem> GetAllUnitTests();
37

38
        public abstract List<RequirementItem> GetAllSoftwareRequirements();
39

40
        public abstract List<EliminatedRequirementItem> GetAllEliminatedSoftwareRequirements();
41

42
        public abstract List<RequirementItem> GetAllSystemRequirements();
43

44
        public abstract List<EliminatedRequirementItem> GetAllEliminatedSystemRequirements();
45

46
        public abstract List<RequirementItem> GetAllDocumentationRequirements();
47

48
        public abstract List<EliminatedRequirementItem> GetAllEliminatedDocumentationRequirements();
49

50
        public abstract List<DocContentItem> GetAllDocContents();
51

52
        public abstract List<EliminatedDocContentItem> GetAllEliminatedDocContents();
53

54
        public abstract List<SoftwareSystemTestItem> GetAllSoftwareSystemTests();
55

56
        public abstract List<EliminatedSoftwareSystemTestItem> GetAllEliminatedSoftwareSystemTests();
57

58
        public abstract List<AnomalyItem> GetAllAnomalies();
59

60
        public abstract List<EliminatedAnomalyItem> GetAllEliminatedAnomalies();
61

62
        public List<LinkedItem> GetItems(TraceEntity te)
63
        {
24✔
64
            if (te.ID == "SystemRequirement")
24✔
65
            {
7✔
66
                return GetAllSystemRequirements().Cast<LinkedItem>().ToList();
7✔
67
            }
68
            else if (te.ID == "SoftwareRequirement")
17✔
69
            {
6✔
70
                return GetAllSoftwareRequirements().Cast<LinkedItem>().ToList();
6✔
71
            }
72
            else if (te.ID == "SoftwareSystemTest")
11✔
73
            {
1✔
74
                return GetAllSoftwareSystemTests().Cast<LinkedItem>().ToList();
1✔
75
            }
76
            else if (te.ID == "UnitTest")
10✔
77
            {
1✔
78
                return GetAllUnitTests().Cast<LinkedItem>().ToList();
1✔
79
            }
80
            else if (te.ID == "TestResult")
9!
NEW
81
            {
×
NEW
82
                return GetAllTestResults().Cast<LinkedItem>().ToList();
×
83
            }
84
            else if (te.ID == "Risk")
9✔
85
            {
1✔
86
                return GetAllRisks().Cast<LinkedItem>().ToList();
1✔
87
            }
88
            else if (te.ID == "SOUP")
8✔
89
            {
1✔
90
                return GetAllSOUP().Cast<LinkedItem>().ToList();
1✔
91
            }
92
            else if (te.ID == "Anomaly")
7✔
93
            {
1✔
94
                return GetAllAnomalies().Cast<LinkedItem>().ToList();
1✔
95
            }
96
            else if (te.ID == "DocumentationRequirement")
6✔
97
            {
2✔
98
                return GetAllDocumentationRequirements().Cast<LinkedItem>().ToList();
2✔
99
            }
100
            else if (te.ID == "DocContent")
4✔
101
            {
2✔
102
                return GetAllDocContents().Cast<LinkedItem>().ToList();
2✔
103
            }
104
            else if (te.ID == "Eliminated")
2✔
105
            {
1✔
106
                return  GetAllEliminatedRisks().Cast<LinkedItem>()
1✔
107
                        .Concat(GetAllEliminatedSystemRequirements())
1✔
108
                        .Concat(GetAllEliminatedSoftwareRequirements())
1✔
109
                        .Concat(GetAllEliminatedDocumentationRequirements())
1✔
110
                        .Concat(GetAllEliminatedSoftwareSystemTests())
1✔
111
                        .Concat(GetAllEliminatedAnomalies())
1✔
112
                        .Concat(GetAllEliminatedDocContents())
1✔
113
                        .Concat(GetAllEliminatedSOUP())
1✔
114
                        .ToList();
1✔
115
            }
116
            else
117
            {
1✔
118
                throw new Exception($"No datasource available for unknown trace entity: {te.ID}");
1✔
119
            }
120
        }
23✔
121

122
        public SOUPItem GetSOUP(string id)
123
        {
3✔
124
            List<SOUPItem> list = GetAllSOUP();
3✔
125
            return list.Find(f => (f.ItemID == id));
6✔
126
        }
3✔
127

128
        public EliminatedSOUPItem GetEliminatedSOUP(string id)
129
        {
1✔
130
            List<EliminatedSOUPItem> list = GetAllEliminatedSOUP();
1✔
131
            return list.Find(f => (f.ItemID == id));
2✔
132
        }
1✔
133

134
        public RiskItem GetRisk(string id)
135
        {
3✔
136
            List<RiskItem> list = GetAllRisks();
3✔
137
            return list.Find(f => (f.ItemID == id));
6✔
138
        }
3✔
139

140
        public EliminatedRiskItem GetEliminatedRisk(string id)
141
        {
1✔
142
            List<EliminatedRiskItem> list = GetAllEliminatedRisks();
1✔
143
            return list.Find(f => (f.ItemID == id));
2✔
144
        }
1✔
145

146
        public UnitTestItem GetUnitTest(string id)
147
        {
3✔
148
            var items = GetAllUnitTests();
3✔
149
            return items.Find(f => (f.ItemID == id));
7✔
150
        }
3✔
151

152
        public RequirementItem GetSoftwareRequirement(string id)
153
        {
3✔
154
            var reqs = GetAllSoftwareRequirements();
3✔
155
            return reqs.Find(f => (f.ItemID == id));
6✔
156
        }
3✔
157

158
        public EliminatedRequirementItem GetEliminatedSoftwareRequirement(string id)
159
        {
1✔
160
            var reqs = GetAllEliminatedSoftwareRequirements();
1✔
161
            return reqs.Find(f => (f.ItemID == id));
2✔
162
        }
1✔
163

164
        public RequirementItem GetSystemRequirement(string id)
165
        {
3✔
166
            var reqs = GetAllSystemRequirements();
3✔
167
            return reqs.Find(f => (f.ItemID == id));
6✔
168
        }
3✔
169

170
        public EliminatedRequirementItem GetEliminatedSystemRequirement(string id)
171
        {
1✔
172
            var reqs = GetAllEliminatedSystemRequirements();
1✔
173
            return reqs.Find(f => (f.ItemID == id));
2✔
174
        }
1✔
175

176
        public RequirementItem GetDocumentationRequirement(string id)
177
        {
3✔
178
            var reqs = GetAllDocumentationRequirements();
3✔
179
            return reqs.Find(f => (f.ItemID == id));
6✔
180
        }
3✔
181

182
        public EliminatedRequirementItem GetEliminatedDocumentationRequirement(string id)
183
        {
1✔
184
            var reqs = GetAllEliminatedDocumentationRequirements();
1✔
185
            return reqs.Find(f => (f.ItemID == id));
2✔
186
        }
1✔
187

188
        public DocContentItem GetDocContent(string id)
189
        {
3✔
190
            var items = GetAllDocContents();
3✔
191
            return items.Find(f => (f.ItemID == id));
6✔
192
        }
3✔
193

194
        public EliminatedDocContentItem GetEliminatedDocContent(string id)
195
        {
1✔
196
            var items = GetAllEliminatedDocContents();
1✔
197
            return items.Find(f => (f.ItemID == id));
2✔
198
        }
1✔
199

200
        public SoftwareSystemTestItem GetSoftwareSystemTest(string id)
201
        {
3✔
202
            var items = GetAllSoftwareSystemTests();
3✔
203
            return items.Find(f => (f.ItemID == id));
6✔
204
        }
3✔
205

206
        public EliminatedSoftwareSystemTestItem GetEliminatedSoftwareSystemTestItem(string id)
207
        {
1✔
208
            var items = GetAllEliminatedSoftwareSystemTests();
1✔
209
            return items.Find(f => (f.ItemID == id));
2✔
210
        }
1✔
211

212
        public AnomalyItem GetAnomaly(string id)
213
        {
3✔
214
            var items = GetAllAnomalies();
3✔
215
            return items.Find(f => (f.ItemID == id));
6✔
216
        }
3✔
217

218
        public EliminatedAnomalyItem GetEliminatedAnomaly(string id)
219
        {
1✔
220
            var items = GetAllEliminatedAnomalies();
1✔
221
            return items.Find(f => (f.ItemID == id));
2✔
222
        }
1✔
223

224
        public Item GetItem(string id) //this will not return eliminated items
225
        {
21✔
226
            var sreq = GetAllSoftwareRequirements();
21✔
227
            int idx = -1;
21✔
228
            if ((idx = sreq.FindIndex(o => o.ItemID == id)) >= 0)
62✔
229
            {
1✔
230
                return sreq[idx];
1✔
231
            }
232
            sreq = GetAllSystemRequirements();
20✔
233
            if ((idx = sreq.FindIndex(o => o.ItemID == id)) >= 0)
56✔
234
            {
11✔
235
                return sreq[idx];
11✔
236
            }
237
            sreq = GetAllDocumentationRequirements();
9✔
238
            if ((idx = sreq.FindIndex(o => o.ItemID == id)) >= 0)
26✔
239
            {
1✔
240
                return sreq[idx];
1✔
241
            }
242
            var dcont = GetAllDocContents();
8✔
243
            if ((idx = dcont.FindIndex(o => o.ItemID == id)) >= 0)
23✔
244
            {
1✔
245
                return dcont[idx];
1✔
246
            }
247
            var tcase = GetAllSoftwareSystemTests();
7✔
248
            if ((idx = tcase.FindIndex(o => o.ItemID == id)) >= 0)
20✔
249
            {
1✔
250
                return tcase[idx];
1✔
251
            }
252
            var utest = GetAllUnitTests();
6✔
253
            if ((idx = utest.FindIndex(o => o.ItemID == id)) >= 0)
25✔
254
            {
1✔
255
                return utest[idx];
1✔
256
            }
257
            var testResults = GetAllTestResults();
5✔
258
            if ((idx = testResults.FindIndex(o => o.ItemID == id)) >= 0)
5!
NEW
259
            {
×
NEW
260
                return testResults[idx];
×
261
            }
262
            var anomalies = GetAllAnomalies();
5✔
263
            if ((idx = anomalies.FindIndex(o => o.ItemID == id)) >= 0)
14✔
264
            {
1✔
265
                return anomalies[idx];
1✔
266
            }
267
            var SOUPs = GetAllSOUP();
4✔
268
            if ((idx = SOUPs.FindIndex(o => o.ItemID == id)) >= 0)
11✔
269
            {
1✔
270
                return SOUPs[idx];
1✔
271
            }
272
            var Risks = GetAllRisks();
3✔
273
            if ((idx = Risks.FindIndex(o => o.ItemID == id)) >= 0)
8✔
274
            {
1✔
275
                return Risks[idx];
1✔
276
            }
277
            return null;
2✔
278
        }
21✔
279

280
        public string GetConfigValue(string key)
281
        {
2✔
282
            return configuration.ConfigVals.GetValue(key);
2✔
283
        }
2✔
284

285
        public string GetTemplateFile(string fileName)
286
        {
1✔
287
            return fileSystem.File.ReadAllText(fileSystem.Path.Join(configuration.TemplateDir, fileName));
1✔
288
        }
1✔
289

290
        public Stream GetFileStreamFromTemplateDir(string fileName)
291
        {
5✔
292
            var stream = fileSystem.FileStream.New(fileSystem.Path.Join(configuration.TemplateDir, fileName), FileMode.Open);
5✔
293
            return stream;
5✔
294
        }
5✔
295

296
        public string ToJSON()
297
        {
1✔
298
            CheckpointDataStorage storage = new CheckpointDataStorage();
1✔
299
            storage.SystemRequirements = GetAllSystemRequirements();
1✔
300
            storage.SoftwareRequirements = GetAllSoftwareRequirements();
1✔
301
            storage.DocumentationRequirements = GetAllDocumentationRequirements();
1✔
302
            storage.DocContents = GetAllDocContents();
1✔
303
            storage.Risks = GetAllRisks().ToList();
1✔
304
            storage.UnitTests = GetAllUnitTests();
1✔
305
            storage.SoftwareSystemTests = GetAllSoftwareSystemTests();
1✔
306
            storage.SOUPs = GetAllSOUP();
1✔
307
            storage.Anomalies = GetAllAnomalies();
1✔
308
            storage.EliminatedSystemRequirements = GetAllEliminatedSystemRequirements();
1✔
309
            storage.EliminatedSoftwareRequirements = GetAllEliminatedSoftwareRequirements();
1✔
310
            storage.EliminatedDocumentationRequirements = GetAllEliminatedDocumentationRequirements();
1✔
311
            storage.EliminatedSoftwareSystemTests = GetAllEliminatedSoftwareSystemTests();
1✔
312
            storage.EliminatedRisks = GetAllEliminatedRisks();
1✔
313

314
            var options = new JsonSerializerOptions { WriteIndented = true };
1✔
315
            return JsonSerializer.Serialize(storage, options);
1✔
316
        }
1✔
317
    }
318
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc