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

#606 When multiple bom ref are found when cdx runs on a .sln allow bom generation. #831

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions CycloneDX.Tests/CycloneDX.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@
</ItemGroup>

<ItemGroup>
<None Update="FunctionalTests\Issue606\project2assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue606\project1assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue606\project2csproj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue606\project1csproj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue606\solution1sln.text">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue826alt-ProjectFileDoesntExistWithAssetsFile\project2assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
63 changes: 63 additions & 0 deletions CycloneDX.Tests/FunctionalTests/Issue606/Issue606.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.IO;
using System.IO.Abstractions;
using System.IO.Abstractions.TestingHelpers;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CycloneDX.Models;
using Xunit;

namespace CycloneDX.Tests.FunctionalTests
{
public class Issue606
{

readonly string testFileFolder = "Issue606";

private MockFileSystem getMockFS()
{
return new MockFileSystem(new Dictionary<string, MockFileData>
{
{
MockUnixSupport.Path("c:/projectPath/project.sln"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", testFileFolder, "project1csproj.xml")))
},{
MockUnixSupport.Path("c:/project1/project1.csproj"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", testFileFolder, "project2csproj.xml")))
},{
MockUnixSupport.Path("c:/project2/project2.csproj"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", testFileFolder, "project2csproj.xml")))
},{
MockUnixSupport.Path("c:/project1/obj/project.assets.json"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", testFileFolder, "project1assets.json")))
},{
MockUnixSupport.Path("c:/project2/obj/project.assets.json"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", testFileFolder, "project2assets.json")))
}
});
}

[Fact]
public async Task NoExceptionHappens()
{
// One day we might decide that we actually want an exception in this case

var options = new RunOptions
{
scanProjectReferences = true,
SolutionOrProjectFile = MockUnixSupport.Path("c:/ProjectPath/Project.sln"),
};

//Just test that there is no exception
var bom = await FunctionalTestHelper.Test(options, getMockFS());
}
}
}
Loading