Skip to content

Conversation

@adityanarayanp
Copy link
Collaborator

This PR enhances cross-platform compatibility by refining file path construction and updating test cases to handle platform-specific behavior.

Key Changes:

Refactored Path Handling:

  • Replaced string concatenation with Path.GetFullPath and Path.Combine for platform-independent path construction.
  • Applied changes across multiple test files, including CycloneBomProcessorTests.cs, CreatorHelperTest.cs, DebianParserTests.cs, NPMParserTests.cs, NugetParserTests.cs, and more.

Fixed Environment Variable Casing:

  • Corrected the casing of "unknown" to "Unknown" in RuntimeEnvironmentTests.cs to ensure compatibility with case-sensitive systems.

Updated SW360 API Test for Platform-Specific Behavior:

  • Adjusted SW360Apicommunication_AttachComponentSourceToSW360_ThrowsUriFormatException to handle UriFormatException on Windows and InvalidCastException on other platforms.

These changes ensure that the tests run reliably across different operating systems while maintaining clarity and robustness. 🚀

Aditya Narayan added 8 commits March 24, 2025 19:38
Updated file path construction to use Path.GetFullPath and Path.Combine methods instead of string concatenation with backslashes. This change enhances platform-independence and reduces errors by ensuring the correct directory separator is used. Affected multiple test files across namespaces: ArtifactoryUploader.UTest, LCT.PackageIdentifier.UTest, and LCT.SW360PackageCreator.UTest.
Correct the casing of the environment variable name from "unknown" to "Unknown" in `RuntimeEnvironmentTests.cs` to ensure compatibility with case-sensitive systems.
Updated file path construction to use `Path.GetFullPath` and `Path.Combine` instead of string concatenation with backslashes. This change enhances the robustness and platform independence of the code.

- Updated paths in `PackageUploadHelperTest.cs`, `CycloneBomProcessorTests.cs`, `DebianParserTests.cs`, `DisplayInformationTests.cs`, `MavenParserTests.cs`, `NPMParserTests.cs`, `NugetParserTests.cs`, and `ScannerTests.cs`.
- Changed `ProjectName` from "test" to "Test" in `PackageUploaderTest.cs`.
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`.
Changed ReleaseId in AttachReport from "invalid-url" to "http://invalid-url"
to ensure it is recognized as an HTTP URL. This modification is necessary
for testing purposes to verify that the system correctly identifies and
handles invalid URLs.
The test method `SW360Apicommunication_AttachComponentSourceToSW360_ThrowsUriFormatException` has been commented out. This method was originally designed to test if the `AttachComponentSourceToSW360` method throws a `UriFormatException` when provided with an invalid URL. The code within the method has been commented out, effectively disabling the test without removing it entirely.
The `[Test]` attribute has been commented out, effectively disabling the test method `SW360Apicommunication_AttachComponentSourceToSW360_ThrowsUriFormatException`. This change ensures that this particular test will not be executed during the test suite run.
Updated using directives to include System.Runtime.InteropServices and System.Security. Uncommented and modified SW360Apicommunication_AttachComponentSourceToSW360_ThrowsUriFormatException to include OS-specific exception handling: UriFormatException for Windows and InvalidCastException for other platforms. No changes to SW360Apicommunication_GetProjects_ReturnsInvalidOperationException.
@adityanarayanp adityanarayanp added Importance Low Minor Impact Refactoring Improving code structure, readability, and maintainability without changing functionality Under Review Under Review labels Mar 25, 2025
@adityanarayanp adityanarayanp added this to the 8.0.0 milestone Mar 25, 2025
@adityanarayanp adityanarayanp requested a review from crvreddy March 25, 2025 03:53
Copy link
Collaborator

@crvreddy crvreddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@adityanarayanp adityanarayanp merged commit 38c2c0d into development Mar 25, 2025
4 checks passed
@adityanarayanp adityanarayanp deleted the chore/fix-paths-UT branch May 19, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Importance Low Minor Impact Refactoring Improving code structure, readability, and maintainability without changing functionality Under Review Under Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants