Add support for accepting directories to add and remove reference commands.
This commit adds support for specifying directories containing a single project to both the `add reference` and `remove reference` commands. Fixes issue #7343.
This commit is contained in:
parent
bcf13b93cc
commit
1ddf5c87c7
19 changed files with 125 additions and 76 deletions
|
@ -559,7 +559,7 @@ Commands:
|
|||
.WithProject(lib.CsProjName)
|
||||
.Execute("\"IDoNotExist.csproj\"");
|
||||
cmd.Should().Fail();
|
||||
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ReferenceDoesNotExist, "IDoNotExist.csproj"));
|
||||
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, "IDoNotExist.csproj"));
|
||||
lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ Commands:
|
|||
.WithProject(lib.CsProjPath)
|
||||
.Execute($"\"{setup.ValidRefCsprojPath}\" \"IDoNotExist.csproj\"");
|
||||
cmd.Should().Fail();
|
||||
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ReferenceDoesNotExist, "IDoNotExist.csproj"));
|
||||
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, "IDoNotExist.csproj"));
|
||||
lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
|
||||
}
|
||||
|
||||
|
@ -693,5 +693,55 @@ Commands:
|
|||
cmd.StdErr.Should().MatchRegex(" - net45");
|
||||
net45lib.CsProjContent().Should().BeEquivalentTo(csProjContent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenDirectoryContainingProjectIsGivenReferenceIsAdded()
|
||||
{
|
||||
var setup = Setup();
|
||||
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||
|
||||
var result = new AddReferenceCommand()
|
||||
.WithWorkingDirectory(setup.TestRoot)
|
||||
.WithProject(lib.CsProjPath)
|
||||
.Execute($"\"{Path.GetDirectoryName(setup.ValidRefCsprojPath)}\"");
|
||||
|
||||
result.Should().Pass();
|
||||
result.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"ValidRef\ValidRef.csproj"));
|
||||
result.StdErr.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenDirectoryContainsNoProjectsItCancelsWholeOperation()
|
||||
{
|
||||
var setup = Setup();
|
||||
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||
|
||||
var reference = "Empty";
|
||||
var result = new AddReferenceCommand()
|
||||
.WithWorkingDirectory(setup.TestRoot)
|
||||
.WithProject(lib.CsProjPath)
|
||||
.Execute(reference);
|
||||
|
||||
result.Should().Fail();
|
||||
result.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
|
||||
result.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindAnyProjectInDirectory, reference));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenDirectoryContainsMultipleProjectsItCancelsWholeOperation()
|
||||
{
|
||||
var setup = Setup();
|
||||
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||
|
||||
var reference = "MoreThanOne";
|
||||
var result = new AddReferenceCommand()
|
||||
.WithWorkingDirectory(setup.TestRoot)
|
||||
.WithProject(lib.CsProjPath)
|
||||
.Execute(reference);
|
||||
|
||||
result.Should().Fail();
|
||||
result.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
|
||||
result.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneProjectInDirectory, reference));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue