Skip to content

Commit 7370b61

Browse files
author
Aditya Narayan
committed
Fix path handling in test files for cross-platform support
Updated `CycloneBomProcessorTests.cs`: - Removed trailing backslash from `sourcePath`. - Used `Path.GetFullPath` and `Path.Combine` for `output.json` path. Updated `CreatorHelperTest.cs`: - Appended `Path.DirectorySeparatorChar` to `localPathforDownload`.
1 parent 2bae92c commit 7370b61

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ public void ParseCycloneDXBom_GivenInvlidBOMFilePath_ReturnsZeroComponents()
185185
public void ParseCycloneDXBom_GivenInCorrectJsonFile_ReturnsZeroComponents()
186186
{
187187
//Arrange
188-
string sourcePath = $"{Path.GetTempPath()}\\";
188+
string sourcePath = $"{Path.GetTempPath()}";
189189
File.WriteAllText(sourcePath + "output.json", "{[}");
190190

191191
//Act
192192
CycloneDXBomParser cycloneBomProcessor = new CycloneDXBomParser();
193-
Bom files = cycloneBomProcessor.ParseCycloneDXBom(sourcePath + "/output.json");
193+
Bom files = cycloneBomProcessor.ParseCycloneDXBom(Path.GetFullPath(Path.Combine(sourcePath, "output.json")));
194194

195195
//Assert
196196
Assert.IsNull(files.Components, "Returns Zero components in BOM");

src/LCT.SW360PackageCreator.UTest/CreatorHelperTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ public void Test_GetAttachmentUrlListForMvn()
746746
// Arrange
747747
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
748748
string outFolder = Path.GetDirectoryName(exePath);
749-
string localPathforDownload = Path.GetFullPath(Path.Combine(outFolder, "..", "..", "src", "LCT.SW360PackageCreator.UTest", "ComponentCreatorUTFiles"));
749+
string localPathforDownload = Path.GetFullPath(Path.Combine(outFolder, "..", "..", "src", "LCT.SW360PackageCreator.UTest", "ComponentCreatorUTFiles")) + Path.DirectorySeparatorChar;
750750

751751
var component = new ComparisonBomData
752752
{

0 commit comments

Comments
 (0)