Skip to content

Commit 08371ea

Browse files
CopilotMalcolmnixon
andcommitted
Improve test naming and add edge case test; update requirements for renamed tests
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
1 parent 05293f8 commit 08371ea

10 files changed

+120
-107
lines changed

requirements.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ sections:
205205
other tools in the SPDX ecosystem.
206206
tests:
207207
- SpdxDocument_Validate_NoIssues
208-
- SpdxAnnotation_Validate_BadAnnotator
209-
- SpdxChecksum_Validate_BadAlgorithm
208+
- SpdxAnnotation_Validate_InvalidAnnotator
209+
- SpdxChecksum_Validate_InvalidAlgorithm
210210
- SpdxCreationInformation_Validate_MissingCreators
211211

212212
- title: Quality Requirements

test/DemaConsulting.SpdxModel.Tests/SpdxAnnotationTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ public void SpdxAnnotation_Enhance_AddsOrUpdatesInformationCorrectly()
154154
}
155155

156156
/// <summary>
157-
/// Tests the <see cref="SpdxAnnotation.Validate" /> method reports bad annotators
157+
/// Tests the <see cref="SpdxAnnotation.Validate" /> method reports bad annotators.
158158
/// </summary>
159159
[TestMethod]
160-
public void SpdxAnnotation_Validate_BadAnnotator()
160+
public void SpdxAnnotation_Validate_InvalidAnnotator()
161161
{
162162
// Arrange: Create a bad annotation
163163
var annotation = new SpdxAnnotation
@@ -178,10 +178,10 @@ public void SpdxAnnotation_Validate_BadAnnotator()
178178
}
179179

180180
/// <summary>
181-
/// Tests the <see cref="SpdxAnnotation.Validate" /> method reports bad dates
181+
/// Tests the <see cref="SpdxAnnotation.Validate" /> method reports bad dates.
182182
/// </summary>
183183
[TestMethod]
184-
public void SpdxAnnotation_Validate_BadDate()
184+
public void SpdxAnnotation_Validate_InvalidDate()
185185
{
186186
// Arrange: Create a bad annotation
187187
var annotation = new SpdxAnnotation
@@ -202,10 +202,10 @@ public void SpdxAnnotation_Validate_BadDate()
202202
}
203203

204204
/// <summary>
205-
/// Tests the <see cref="SpdxAnnotation.Validate" /> method reports bad annotation types
205+
/// Tests the <see cref="SpdxAnnotation.Validate" /> method reports bad annotation types.
206206
/// </summary>
207207
[TestMethod]
208-
public void SpdxAnnotation_Validate_BadType()
208+
public void SpdxAnnotation_Validate_InvalidType()
209209
{
210210
// Arrange: Create a bad annotation
211211
var annotation = new SpdxAnnotation
@@ -226,10 +226,10 @@ public void SpdxAnnotation_Validate_BadType()
226226
}
227227

228228
/// <summary>
229-
/// Tests the <see cref="SpdxAnnotation.Validate" /> method reports bad comments
229+
/// Tests the <see cref="SpdxAnnotation.Validate" /> method reports bad comments.
230230
/// </summary>
231231
[TestMethod]
232-
public void SpdxAnnotation_Validate_BadComment()
232+
public void SpdxAnnotation_Validate_InvalidComment()
233233
{
234234
// Arrange: Create a bad annotation
235235
var annotation = new SpdxAnnotation

test/DemaConsulting.SpdxModel.Tests/SpdxChecksumTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ public void SpdxChecksum_Enhance_AddsOrUpdatesInformationCorrectly()
134134
}
135135

136136
/// <summary>
137-
/// Tests the <see cref="SpdxChecksum.Validate" /> method reports bad algorithms
137+
/// Tests the <see cref="SpdxChecksum.Validate" /> method reports bad algorithms.
138138
/// </summary>
139139
[TestMethod]
140-
public void SpdxChecksum_Validate_BadAlgorithm()
140+
public void SpdxChecksum_Validate_InvalidAlgorithm()
141141
{
142142
// Arrange: Create a bad instance
143143
var checksum = new SpdxChecksum
@@ -156,10 +156,10 @@ public void SpdxChecksum_Validate_BadAlgorithm()
156156
}
157157

158158
/// <summary>
159-
/// Tests the <see cref="SpdxChecksum.Validate" /> method reports bad values
159+
/// Tests the <see cref="SpdxChecksum.Validate" /> method reports bad values.
160160
/// </summary>
161161
[TestMethod]
162-
public void SpdxChecksum_Validate_BadValue()
162+
public void SpdxChecksum_Validate_InvalidValue()
163163
{
164164
// Arrange: Create a bad instance
165165
var checksum = new SpdxChecksum

test/DemaConsulting.SpdxModel.Tests/SpdxCreationInformationTests.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,81 +88,81 @@ public void SpdxCreationInformation_Enhance_AddsOrUpdatesInformationCorrectly()
8888
}
8989

9090
/// <summary>
91-
/// Tests the <see cref="SpdxCreationInformation.Validate" /> method reports missing creators
91+
/// Tests the <see cref="SpdxCreationInformation.Validate" /> method reports missing creators.
9292
/// </summary>
9393
[TestMethod]
9494
public void SpdxCreationInformation_Validate_MissingCreators()
9595
{
96-
// Arrange: Create a bad creation information
96+
// Arrange: Create creation information with empty creators array
9797
var info = new SpdxCreationInformation
9898
{
9999
Creators = [],
100100
Created = "2010-01-29T18:30:22Z",
101101
Comment = "This package has been shipped in source and binary form."
102102
};
103103

104-
// Act: Perform validation on the SpdxCreationInformation instance.
104+
// Act: Perform validation on the SpdxCreationInformation instance
105105
var issues = new List<string>();
106106
info.Validate(issues);
107107

108-
// Assert: Verify that the validation fails and the error message includes the description
108+
// Assert: Verify that the validation reports the missing creators
109109
Assert.IsTrue(
110110
issues.Any(issue => issue.Contains("Document Invalid Creator Field - Empty")));
111111
}
112112

113113
/// <summary>
114-
/// Tests the <see cref="SpdxCreationInformation.Validate" /> method reports bad creators
114+
/// Tests the <see cref="SpdxCreationInformation.Validate" /> method reports invalid creators.
115115
/// </summary>
116116
[TestMethod]
117-
public void SpdxCreationInformation_Validate_BadCreator()
117+
public void SpdxCreationInformation_Validate_InvalidCreator()
118118
{
119-
// Arrange: Create a bad creation information
119+
// Arrange: Create creation information with invalid creator format
120120
var info = new SpdxCreationInformation
121121
{
122122
Creators = ["BadCreator"],
123123
Created = "2010-01-29T18:30:22Z",
124124
Comment = "This package has been shipped in source and binary form."
125125
};
126126

127-
// Act: Perform validation on the SpdxCreationInformation instance.
127+
// Act: Perform validation on the SpdxCreationInformation instance
128128
var issues = new List<string>();
129129
info.Validate(issues);
130130

131-
// Assert: Verify that the validation fails and the error message includes the description
131+
// Assert: Verify that the validation reports the invalid creator
132132
Assert.IsTrue(
133133
issues.Any(issue => issue.Contains("Document Invalid Creator Entry 'BadCreator'")));
134134
}
135135

136136
/// <summary>
137-
/// Tests the <see cref="SpdxCreationInformation.Validate" /> method reports bad created dates
137+
/// Tests the <see cref="SpdxCreationInformation.Validate" /> method reports invalid created dates.
138138
/// </summary>
139139
[TestMethod]
140-
public void SpdxCreationInformation_Validate_BadCreated()
140+
public void SpdxCreationInformation_Validate_InvalidCreatedDate()
141141
{
142-
// Arrange: Create a bad creation information
142+
// Arrange: Create creation information with invalid created date
143143
var info = new SpdxCreationInformation
144144
{
145145
Creators = ["Tool: LicenseFind-1.0", "Organization: ExampleCodeInspect ()"],
146146
Created = "BadDate",
147147
Comment = "This package has been shipped in source and binary form."
148148
};
149149

150-
// Act: Perform validation on the SpdxCreationInformation instance.
150+
// Act: Perform validation on the SpdxCreationInformation instance
151151
var issues = new List<string>();
152152
info.Validate(issues);
153153

154-
// Assert: Verify that the validation fails and the error message includes the description
154+
// Assert: Verify that the validation reports the invalid created date
155155
Assert.IsTrue(
156156
issues.Any(issue => issue.Contains("Document Invalid Created Field 'BadDate'")));
157157
}
158158

159159
/// <summary>
160-
/// Tests the <see cref="SpdxCreationInformation.Validate" /> method reports bad versions
160+
/// Tests the <see cref="SpdxCreationInformation.Validate" /> method reports invalid versions.
161161
/// </summary>
162162
[TestMethod]
163-
public void SpdxCreationInformation_Validate_BadVersion()
163+
public void SpdxCreationInformation_Validate_InvalidVersion()
164164
{
165-
// Arrange: Create a bad creation information
165+
// Arrange: Create creation information with invalid license list version
166166
var info = new SpdxCreationInformation
167167
{
168168
Creators = ["Tool: LicenseFind-1.0", "Organization: ExampleCodeInspect ()"],
@@ -171,11 +171,11 @@ public void SpdxCreationInformation_Validate_BadVersion()
171171
LicenseListVersion = "BadVersion"
172172
};
173173

174-
// Act: Perform validation on the SpdxCreationInformation instance.
174+
// Act: Perform validation on the SpdxCreationInformation instance
175175
var issues = new List<string>();
176176
info.Validate(issues);
177177

178-
// Assert: Verify that the validation fails and the error message includes the description
178+
// Assert: Verify that the validation reports the invalid license list version
179179
Assert.IsTrue(
180180
issues.Any(issue => issue.Contains("Document Invalid License List Version Field 'BadVersion'")));
181181
}

test/DemaConsulting.SpdxModel.Tests/SpdxDocumentTests.cs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -304,122 +304,117 @@ public void SpdxDocument_Validate_NoIssues()
304304
}
305305

306306
/// <summary>
307-
/// Tests the <see cref="SpdxDocument.Validate" /> method reports bad IDs.
307+
/// Tests the <see cref="SpdxDocument.Validate" /> method reports invalid IDs.
308308
/// </summary>
309309
[TestMethod]
310-
public void SpdxDocument_Validate_BadId()
310+
public void SpdxDocument_Validate_InvalidId()
311311
{
312+
// Arrange: Load and deserialize a valid SPDX document
312313
var json22Example = SpdxTestHelpers.GetEmbeddedResource(
313314
"DemaConsulting.SpdxModel.Tests.IO.Examples.SPDXJSONExample-v2.3.spdx.json");
314-
315-
// Deserialize the document
316315
var doc = Spdx2JsonDeserializer.Deserialize(json22Example);
317316
Assert.IsNotNull(doc);
318317

319-
// Corrupt the document
318+
// Arrange: Corrupt the document with invalid ID
320319
doc.Id = "BadId";
321320

322-
// Perform validation
321+
// Act: Perform validation
323322
var issues = new List<string>();
324323
doc.Validate(issues);
325324

326-
// Ensure issue reported
325+
// Assert: Verify issue is reported
327326
Assert.Contains("Document Invalid SPDX Identifier Field 'BadId'", issues);
328327
}
329328

330329
/// <summary>
331-
/// Tests the <see cref="SpdxDocument.Validate" /> method reports bad names.
330+
/// Tests the <see cref="SpdxDocument.Validate" /> method reports invalid names.
332331
/// </summary>
333332
[TestMethod]
334-
public void SpdxDocument_Validate_BadName()
333+
public void SpdxDocument_Validate_InvalidName()
335334
{
335+
// Arrange: Load and deserialize a valid SPDX document
336336
var json22Example = SpdxTestHelpers.GetEmbeddedResource(
337337
"DemaConsulting.SpdxModel.Tests.IO.Examples.SPDXJSONExample-v2.3.spdx.json");
338-
339-
// Deserialize the document
340338
var doc = Spdx2JsonDeserializer.Deserialize(json22Example);
341339
Assert.IsNotNull(doc);
342340

343-
// Corrupt the document
341+
// Arrange: Corrupt the document with empty name
344342
doc.Name = "";
345343

346-
// Perform validation
344+
// Act: Perform validation
347345
var issues = new List<string>();
348346
doc.Validate(issues);
349347

350-
// Ensure issue reported
348+
// Assert: Verify issue is reported
351349
Assert.Contains("Document Invalid Document Name Field - Empty", issues);
352350
}
353351

354352
/// <summary>
355-
/// Tests the <see cref="SpdxDocument.Validate" /> method reports bad versions.
353+
/// Tests the <see cref="SpdxDocument.Validate" /> method reports invalid versions.
356354
/// </summary>
357355
[TestMethod]
358-
public void SpdxDocument_Validate_BadVersion()
356+
public void SpdxDocument_Validate_InvalidVersion()
359357
{
358+
// Arrange: Load and deserialize a valid SPDX document
360359
var json22Example = SpdxTestHelpers.GetEmbeddedResource(
361360
"DemaConsulting.SpdxModel.Tests.IO.Examples.SPDXJSONExample-v2.3.spdx.json");
362-
363-
// Deserialize the document
364361
var doc = Spdx2JsonDeserializer.Deserialize(json22Example);
365362
Assert.IsNotNull(doc);
366363

367-
// Corrupt the document
364+
// Arrange: Corrupt the document with invalid version
368365
doc.Version = "BadVersion";
369366

370-
// Perform validation
367+
// Act: Perform validation
371368
var issues = new List<string>();
372369
doc.Validate(issues);
373370

374-
// Ensure issue reported
371+
// Assert: Verify issue is reported
375372
Assert.Contains("Document Invalid SPDX Version Field 'BadVersion'", issues);
376373
}
377374

378375
/// <summary>
379-
/// Tests the <see cref="SpdxDocument.Validate" /> method reports bad data licenses.
376+
/// Tests the <see cref="SpdxDocument.Validate" /> method reports invalid data licenses.
380377
/// </summary>
381378
[TestMethod]
382-
public void SpdxDocument_Validate_BadDataLicense()
379+
public void SpdxDocument_Validate_InvalidDataLicense()
383380
{
381+
// Arrange: Load and deserialize a valid SPDX document
384382
var json22Example = SpdxTestHelpers.GetEmbeddedResource(
385383
"DemaConsulting.SpdxModel.Tests.IO.Examples.SPDXJSONExample-v2.3.spdx.json");
386-
387-
// Deserialize the document
388384
var doc = Spdx2JsonDeserializer.Deserialize(json22Example);
389385
Assert.IsNotNull(doc);
390386

391-
// Corrupt the document
387+
// Arrange: Corrupt the document with invalid data license
392388
doc.DataLicense = "BadLicense";
393389

394-
// Perform validation
390+
// Act: Perform validation
395391
var issues = new List<string>();
396392
doc.Validate(issues);
397393

398-
// Ensure issue reported
394+
// Assert: Verify issue is reported
399395
Assert.Contains("Document Invalid Data License Field 'BadLicense'", issues);
400396
}
401397

402398
/// <summary>
403-
/// Tests the <see cref="SpdxDocument.Validate" /> method reports bad data licenses.
399+
/// Tests the <see cref="SpdxDocument.Validate" /> method reports invalid namespaces.
404400
/// </summary>
405401
[TestMethod]
406-
public void SpdxDocument_Validate_BadNameSpace()
402+
public void SpdxDocument_Validate_InvalidNameSpace()
407403
{
404+
// Arrange: Load and deserialize a valid SPDX document
408405
var json22Example = SpdxTestHelpers.GetEmbeddedResource(
409406
"DemaConsulting.SpdxModel.Tests.IO.Examples.SPDXJSONExample-v2.3.spdx.json");
410-
411-
// Deserialize the document
412407
var doc = Spdx2JsonDeserializer.Deserialize(json22Example);
413408
Assert.IsNotNull(doc);
414409

415-
// Corrupt the document
410+
// Arrange: Corrupt the document with empty namespace
416411
doc.DocumentNamespace = "";
417412

418-
// Perform validation
413+
// Act: Perform validation
419414
var issues = new List<string>();
420415
doc.Validate(issues);
421416

422-
// Ensure issue reported
417+
// Assert: Verify issue is reported
423418
Assert.Contains("Document Invalid SPDX Document Namespace Field - Empty", issues);
424419
}
425420

@@ -470,7 +465,7 @@ public void SpdxDocument_Validate_DuplicatePackageIds()
470465
/// Tests the <see cref="SpdxDocument.Validate" /> method detects bad relationships.
471466
/// </summary>
472467
[TestMethod]
473-
public void SpdxDocument_Validate_BadRelationship()
468+
public void SpdxDocument_Validate_InvalidRelationship()
474469
{
475470
// Arrange: Create a sample SPDX document with a relationship to a non-existent package
476471
var doc = new SpdxDocument

0 commit comments

Comments
 (0)