Skip to content

Commit

Permalink
Add test case for adding projects outside solution dir descendants
Browse files Browse the repository at this point in the history
  • Loading branch information
edvilme committed Feb 14, 2025
1 parent c82cd2e commit 600b6fe
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26006.2
MinimumVisualStudioVersion = 10.0.40219.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Solution />
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

namespace Lib
{
public class Library
{
public static string GetMessage()
{
return "Message from Lib";
}
}
}
18 changes: 18 additions & 0 deletions test/dotnet-sln.Tests/GivenDotnetSlnAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,24 @@ public void WhenSolutionFolderIsPassedWithDirectorySeparatorFolderStructureIsCor
.Should().BeVisuallyEquivalentTo(expectedSlnContents);
}

[Theory]
[InlineData("sln", ".sln")]
[InlineData("sln", ".slnx")]
[InlineData("solution", ".sln")]
[InlineData("solution", ".slnx")]
public void WhenAddingProjectOutsideDirectoryItShouldNotAddSolutionFolders(string solutionCommand, string solutionExtension)
{
var projectDirectory = _testAssetsManager
.CopyTestAsset("TestAppWithSlnAndCsprojInParentDir", identifier: $"GivenDotnetSlnAdd-{solutionCommand}{solutionExtension}")
.WithSource()
.Path;
var projectToAdd = Path.Combine("..", "Lib", "Lib.csproj");
var cmd = new DotnetCommand(Log)
.WithWorkingDirectory(Path.Join(projectDirectory, "Dir"))
.Execute(solutionCommand, $"App{solutionExtension}", "add", projectToAdd);
cmd.Should().Pass(); // TODO: Check actual contents
}

private string GetExpectedSlnContents(
string slnPath,
string slnTemplateName,
Expand Down

0 comments on commit 600b6fe

Please sign in to comment.