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

add slnx support #130

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ProjectsCollector(IMsBuildAbstraction msBuild)

public IEnumerable<string> GetProjects(string inputPath)
{
return Path.GetExtension(inputPath).Equals(".sln")
return Path.GetExtension(inputPath).StartsWith(".sln")
? _msBuild.GetProjectsFromSolution(Path.GetFullPath(inputPath)).Where(File.Exists).Select(Path.GetFullPath)
: new[] { Path.GetFullPath(inputPath) };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task License_Should_Be_Available_And_Match_Expected_License(KeyValu
try
{
using var driver = new DisposableWebDriver();
driver.Navigate().GoToUrl(mappedValue.Key.ToString());
await driver.Navigate().GoToUrlAsync(mappedValue.Key.ToString());

await Verify(driver.FindElement(By.TagName("body")).Text).HashParameters().UseStringComparer(CompareLicense);
return;
Expand All @@ -32,14 +32,14 @@ public async Task License_Should_Be_Available_And_Match_Expected_License(KeyValu
throw;
}
retryCount++;
TestContext.Out.WriteLine($"Failed to check license for the {retryCount} time - retrying");
TestContext.Out.WriteLine(e);
await TestContext.Out.WriteLineAsync($"Failed to check license for the {retryCount} time - retrying");
await TestContext.Out.WriteLineAsync(e.ToString());
}
}

}

private Task<CompareResult> CompareLicense(string received, string verified, IReadOnlyDictionary<string, object> context)
private static Task<CompareResult> CompareLicense(string received, string verified, IReadOnlyDictionary<string, object> context)
{
return Task.FromResult(new CompareResult((!string.IsNullOrWhiteSpace(verified)) && received.Contains(verified)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void GetProjects_Should_ReturnProjectsAsListDirectly(string projectFile)
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("A.slnx")]
public void GetProjects_Should_QueryMsBuildToGetProjectsForSolutionFiles(string solutionFile)
{
_ = _uut.GetProjects(solutionFile);
Expand All @@ -54,6 +55,7 @@ public void GetProjects_Should_QueryMsBuildToGetProjectsForSolutionFiles(string
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("C.slnx")]
public void GetProjects_Should_ReturnEmptyArray_If_SolutionContainsNoProjects(string solutionFile)
{
_msBuild.GetProjectsFromSolution(Arg.Any<string>()).Returns(Enumerable.Empty<string>());
Expand All @@ -67,6 +69,7 @@ public void GetProjects_Should_ReturnEmptyArray_If_SolutionContainsNoProjects(st
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("B.slnx")]
public void GetProjects_Should_ReturnEmptyArray_If_SolutionContainsProjectsThatDontExist(string solutionFile)
{
IEnumerable<string> projects = _fixture.CreateMany<string>();
Expand All @@ -81,6 +84,7 @@ public void GetProjects_Should_ReturnEmptyArray_If_SolutionContainsProjectsThatD
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("C.slnx")]
public void GetProjects_Should_ReturnArrayOfProjects_If_SolutionContainsProjectsThatDoExist(string solutionFile)
{
string[] projects = _fixture.CreateMany<string>().ToArray();
Expand All @@ -96,6 +100,7 @@ public void GetProjects_Should_ReturnArrayOfProjects_If_SolutionContainsProjects
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("A.slnx")]
public void GetProjects_Should_ReturnOnlyExistingProjectsInSolutionFile(string solutionFile)
{
string[] existingProjects = _fixture.CreateMany<string>().ToArray();
Expand All @@ -120,6 +125,14 @@ public async Task GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionF
await Verify(string.Join(",", result), _osPlatformSpecificVerifySettings);
}

[Test, Ignore("Ignore this specific test as long as msbuild does not fully support slnx solutions everywhere")]
public async Task GetProjectsFromXmlSolution_Should_ReturnProjectsInActualSolutionFileRelativePath()
{
var msbuild = new MsBuildAbstraction();
IEnumerable<string> result = msbuild.GetProjectsFromSolution("../../../../targets/slnx/slnx.slnx");
await Verify(string.Join(",", result), _osPlatformSpecificVerifySettings);
}

[Test]
public async Task GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath()
{
Expand Down
8 changes: 8 additions & 0 deletions tests/targets/slnx/slnx.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Solution>
<Configurations>
<BuildType Name="Debug" />
<BuildType Name="Release" />
<BuildType Name="TestWindows" />
</Configurations>
<Project Path="../ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj" Id="875c0575-95c4-4006-a910-bb1555c90c75" />
</Solution>
Loading