Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch DataTestMethod to TestMethod #849

Merged
merged 5 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task FormatValidator_CanReadValidSbom()
}
}

[DataTestMethod]
[TestMethod]
[DataRow(FormatValidatorTestStrings.JsonMissingSpdxVersion, "spdxVersion")]
[DataRow(FormatValidatorTestStrings.JsonMissingSpdxDataLicense, "dataLicense")]
[DataRow(FormatValidatorTestStrings.JsonMissingDocumentNamespace, "documentNamespace")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ public void MissingPropertiesTest_ThrowsSHA256()
Assert.ThrowsException<ParserException>(() => result.Files.Select(f => f.ToSbomFile()).ToList());
}

[DataTestMethod]
DaveTryon marked this conversation as resolved.
Show resolved Hide resolved
[TestMethod]
[DataRow(SbomFileJsonStrings.JsonWith1FileMissingNameString)]
[DataRow(SbomFileJsonStrings.JsonWith1FileMissingIDString)]
[DataRow(SbomFileJsonStrings.JsonWith1FileMissingChecksumsString)]
[DataRow(SbomFileJsonStrings.JsonWith1FileMissingCopyrightAndPathString)]
[TestMethod]
public void MissingPropertiesTest_Throws(string json)
{
var bytes = Encoding.UTF8.GetBytes(json);
Expand All @@ -116,12 +115,11 @@ public void MissingPropertiesTest_Throws(string json)
_ = Assert.ThrowsException<ParserException>(() => this.Parse(parser));
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomFileJsonStrings.GoodJsonWith1FileAdditionalObjectPropertyString)]
[DataRow(SbomFileJsonStrings.GoodJsonWith1FileAdditionalArrayPropertyString)]
[DataRow(SbomFileJsonStrings.GoodJsonWith1FileAdditionalStringPropertyString)]
[DataRow(SbomFileJsonStrings.GoodJsonWith1FileAdditionalValueArrayPropertyString)]
[TestMethod]
public void IgnoresAdditionalPropertiesTest(string json)
{
var bytes = Encoding.UTF8.GetBytes(json);
Expand All @@ -134,11 +132,10 @@ public void IgnoresAdditionalPropertiesTest(string json)
Assert.AreEqual(1, result.FilesCount);
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomFileJsonStrings.MalformedJson)]
[DataRow(SbomFileJsonStrings.MalformedJsonEmptyObject)]
[DataRow(SbomFileJsonStrings.MalformedJsonEmptyObjectNoArrayEnd)]
[TestMethod]
public void MalformedJsonTest_Throws(string json)
{
var bytes = Encoding.UTF8.GetBytes(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void StreamEmptyTestThrowsException()
Assert.ThrowsException<EndOfStreamException>(() => new SPDXParser(stream));
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomPackageStrings.PackageJsonWith1PackageMissingDownloadLocation)]
[DataRow(SbomPackageStrings.PackageJsonWith1PackageMissingVersionInfo)]
public void MissingPropertiesTest_DoesNotThrow(string json)
Expand All @@ -61,7 +61,7 @@ public void MissingPropertiesTest_DoesNotThrow(string json)
var result = this.Parse(parser);
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomPackageStrings.PackageJsonWith1PackageMissingCopyrightText)]
[DataRow(SbomPackageStrings.PackageJsonWith1PackageMissingLicenseInfoFromFiles)]
[DataRow(SbomPackageStrings.PackageJsonWith1PackageMissingSupplier)]
Expand All @@ -83,7 +83,7 @@ public void MissingPropertiesTest_Throws(string json)
Assert.ThrowsException<ParserException>(() => this.Parse(parser));
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomPackageStrings.PackageJsonWith1PackageAdditionalString)]
[DataRow(SbomPackageStrings.PackageJsonWith1PackageAdditionalArray)]
[DataRow(SbomPackageStrings.PackageJsonWith1PackageAdditionalObject)]
Expand All @@ -98,11 +98,10 @@ public void IgnoresAdditionalPropertiesTest(string json)
var result = this.Parse(parser);
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomPackageStrings.MalformedJson)]
[DataRow(SbomPackageStrings.MalformedJsonEmptyObject)]
[DataRow(SbomPackageStrings.MalformedJsonEmptyObjectNoArrayEnd)]
[TestMethod]
public void MalformedJsonTest_Throws(string json)
{
var bytes = Encoding.UTF8.GetBytes(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void ParseMultiplePropertiesTest()
Assert.AreEqual(0, result.ReferencesCount);
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomParserStrings.JsonWithMissingFiles)]
[DataRow(SbomParserStrings.JsonWithMissingPackages)]
[DataRow(SbomParserStrings.JsonWithMissingRelationships)]
Expand All @@ -62,7 +62,7 @@ public void MissingPropertyThrows(string json)
Assert.ThrowsException<ParserException>(() => this.IterateAllPropertiesAsync(stream));
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomParserStrings.MalformedJson)]
[DataRow(SbomParserStrings.MalformedJsonIncorrectRefsType)]
[DataRow(SbomParserStrings.MalformedJsonIncorrectFilesType)]
Expand All @@ -76,7 +76,7 @@ public void MalformedJsonThrows(string json)
Assert.ThrowsException<ParserException>(() => this.IterateAllPropertiesAsync(stream));
}

[DataTestMethod]
[TestMethod]
[DataRow(SbomParserStrings.MalformedJsonEmptyJsonObject)]
[DataRow(SbomParserStrings.MalformedJsonEmptyArrayObject)]
public void MalformedJsonEmptyValuesDoesNotThrow(string json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ public void StreamEmptyTestReturnsNull()
Assert.ThrowsException<EndOfStreamException>(() => new SPDXParser(stream));
}

[DataTestMethod]
DaveTryon marked this conversation as resolved.
Show resolved Hide resolved
[TestMethod]
[DataRow(RelationshipStrings.JsonRelationshipsStringMissingElementId)]
[DataRow(RelationshipStrings.JsonRelationshipsStringMissingRelatedElement)]
[TestMethod]
public void MissingPropertiesTest_Throws(string json)
{
var bytes = Encoding.UTF8.GetBytes(json);
Expand All @@ -51,12 +50,11 @@ public void MissingPropertiesTest_Throws(string json)
Assert.ThrowsException<ParserException>(() => this.Parse(parser));
}

[DataTestMethod]
[TestMethod]
[DataRow(RelationshipStrings.GoodJsonWithRelationshipsStringAdditionalString)]
[DataRow(RelationshipStrings.GoodJsonWithRelationshipsStringAdditionalObject)]
[DataRow(RelationshipStrings.GoodJsonWithRelationshipsStringAdditionalArray)]
[DataRow(RelationshipStrings.GoodJsonWithRelationshipsStringAdditionalArrayNoKey)]
[TestMethod]
public void IgnoresAdditionalPropertiesTest(string json)
{
var bytes = Encoding.UTF8.GetBytes(json);
Expand All @@ -69,9 +67,8 @@ public void IgnoresAdditionalPropertiesTest(string json)
Assert.IsTrue(result.RelationshipsCount > 0);
}

[DataTestMethod]
[DataRow(RelationshipStrings.MalformedJsonRelationshipsString)]
[TestMethod]
[DataRow(RelationshipStrings.MalformedJsonRelationshipsString)]
public void MalformedJsonTest_Throws(string json)
{
var bytes = Encoding.UTF8.GetBytes(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ public void AddPackageUrlsTest_WithNonNullExternalRef_Success()
Assert.AreEqual(0, spdxPackage.ExternalReferences.Count());
}

[DataTestMethod]
[TestMethod]
[DataRow("pkg:npm/[email protected]", "pkg:npm/[email protected]")]
[DataRow("https://github.com/actions/virtual-environments", "https://github.com/actions/virtual-environments")]

public void AddPackageUrlsTest_WithSpecialCharacter_Success(string inputUrl, string expectedUrl)
{
spdxPackage = new SPDXPackage();
Expand Down
Loading