-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58b43dd
commit 4f6a769
Showing
11 changed files
with
9,090 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Snapshooter; | ||
using Snapshooter.Xunit; | ||
using CycloneDX.CLI; | ||
|
||
namespace CycloneDX.CLI.Tests | ||
{ | ||
public class ConvertTests | ||
{ | ||
[Fact] | ||
public async Task CanConvertFromXmlToJson() | ||
{ | ||
using (var tempDirectory = new TempDirectory()) | ||
{ | ||
var outputFilename = Path.Combine(tempDirectory.DirectoryPath, "bom.json"); | ||
var exitCode = await Program.Convert( | ||
Path.Combine("Resources", "bom-1.2.xml"), | ||
outputFilename, | ||
Models.InputFormat.autodetect, | ||
Commands.ConvertOutputFormat.autodetect); | ||
|
||
Assert.Equal(0, exitCode); | ||
var bom = File.ReadAllText(outputFilename); | ||
Snapshot.Match(bom); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task CanConvertFromJsonToXml() | ||
{ | ||
using (var tempDirectory = new TempDirectory()) | ||
{ | ||
var outputFilename = Path.Combine(tempDirectory.DirectoryPath, "bom.xml"); | ||
var exitCode = await Program.Convert( | ||
Path.Combine("Resources", "bom-1.2.json"), | ||
outputFilename, | ||
Models.InputFormat.autodetect, | ||
Commands.ConvertOutputFormat.autodetect); | ||
|
||
Assert.Equal(0, exitCode); | ||
var bom = File.ReadAllText(outputFilename); | ||
Snapshot.Match(bom); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task CanConvertToSpdxTag_v2_1() | ||
{ | ||
using (var tempDirectory = new TempDirectory()) | ||
{ | ||
var outputFilename = Path.Combine(tempDirectory.DirectoryPath, "bom.txt"); | ||
var exitCode = await Program.Convert( | ||
Path.Combine("Resources", "bom-1.2.xml"), | ||
outputFilename, | ||
Models.InputFormat.autodetect, | ||
Commands.ConvertOutputFormat.spdxtag_v2_1); | ||
|
||
Assert.Equal(0, exitCode); | ||
var bom = File.ReadAllText(outputFilename); | ||
Snapshot.Match(bom); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task CanConvertToSpdxTag_v2_2() | ||
{ | ||
using (var tempDirectory = new TempDirectory()) | ||
{ | ||
var outputFilename = Path.Combine(tempDirectory.DirectoryPath, "bom.txt"); | ||
var exitCode = await Program.Convert( | ||
Path.Combine("Resources", "bom-1.2.xml"), | ||
outputFilename, | ||
Models.InputFormat.autodetect, | ||
Commands.ConvertOutputFormat.spdxtag_v2_2); | ||
|
||
Assert.Equal(0, exitCode); | ||
var bom = File.ReadAllText(outputFilename); | ||
Snapshot.Match(bom); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.