forked from CycloneDX/cyclonedx-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jesper Olsson <[email protected]>
- Loading branch information
1 parent
3d71d1f
commit 6f3d960
Showing
7 changed files
with
3,868 additions
and
0 deletions.
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
75 changes: 75 additions & 0 deletions
75
...s/FunctionalTests/Issue911-depsOnSeveralTargetFrameworks/DepsOnSeveralTargetFrameworks.cs
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,75 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Abstractions.TestingHelpers; | ||
using System.Threading.Tasks; | ||
using CycloneDX.Models; | ||
using Xunit; | ||
|
||
namespace CycloneDX.Tests.FunctionalTests | ||
{ | ||
/// <summary> | ||
/// Some dependencies reference different dependency versions based on the project's target framework. | ||
/// For example, [email protected] references [email protected] when targeting net6.0 | ||
/// but references [email protected] when targeting net8.0 | ||
/// | ||
/// This test ensures that the generated SBOM lists both versions as children. | ||
/// | ||
/// Given a dependency, D1, which may | ||
/// a solution file, S1. | ||
/// and S1 contains two project files, P1 and P2 | ||
/// and P1 targets net6.0 | ||
/// and P1 references [email protected] | ||
/// and P2 targets net8.0 | ||
/// and P2 references [email protected] | ||
/// When scanning S1 | ||
/// Then the dependencies of | ||
/// [email protected] should be a child of [email protected] | ||
/// and [email protected] should be a child of [email protected] | ||
/// </summary> | ||
public class DepsOnSeveralTargetFrameworks | ||
{ | ||
private MockFileData Source(string file) | ||
{ | ||
return new MockFileData(File.ReadAllText( | ||
Path.Combine("FunctionalTests", "Issue911-depsOnSeveralTargetFrameworks", file))); | ||
} | ||
|
||
private MockFileSystem getMockFS() | ||
{ | ||
return new MockFileSystem(new Dictionary<string, MockFileData> | ||
{ | ||
{ | ||
MockUnixSupport.Path("c:/ProjectPath/sln.sln"), Source("solution1sln.text") | ||
},{ | ||
MockUnixSupport.Path("c:/ProjectPath/project1/Project1.csproj"), Source("project1csproj.xml") | ||
},{ | ||
MockUnixSupport.Path("c:/ProjectPath/project1/obj/project.assets.json"), Source("project1assets.json") | ||
},{ | ||
MockUnixSupport.Path("c:/ProjectPath/project2/Project2.csproj"), Source("project2csproj.xml") | ||
},{ | ||
MockUnixSupport.Path("c:/ProjectPath/project2/obj/project.assets.json"), Source("project2assets.json") | ||
} | ||
}); | ||
} | ||
|
||
[Fact (Skip = "#911 is not yet corrected")] | ||
public async Task NoExceptionHappens() | ||
{ | ||
var options = new RunOptions | ||
{ | ||
scanProjectReferences = true, | ||
SolutionOrProjectFile = MockUnixSupport.Path("c:/ProjectPath/sln.sln") | ||
}; | ||
|
||
var bom = await FunctionalTestHelper.Test(options, getMockFS()); | ||
FunctionalTestHelper.AssertHasDependencyWithChild( | ||
bom, | ||
"pkg:nuget/[email protected]", | ||
"pkg:nuget/[email protected]"); | ||
FunctionalTestHelper.AssertHasDependencyWithChild( | ||
bom, | ||
"pkg:nuget/[email protected]", | ||
"pkg:nuget/[email protected]"); | ||
} | ||
} | ||
} |
Oops, something went wrong.