Add tests for behavior of tools that target previous major version of shared framework
This commit is contained in:
parent
8615c30063
commit
01d3895b24
7 changed files with 162 additions and 2 deletions
|
@ -91,6 +91,82 @@ namespace Microsoft.DotNet.Tests
|
|||
.And.Pass();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void IfPreviousVersionOfSharedFrameworkIsNotInstalled_ToolsTargetingItFail(bool toolPrefersCLIRuntime)
|
||||
{
|
||||
var testInstance = TestAssets.Get("AppWithToolDependency")
|
||||
.CreateInstance(identifier: toolPrefersCLIRuntime ? "preferCLIRuntime" : "")
|
||||
.WithSourceFiles()
|
||||
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages);
|
||||
|
||||
testInstance = testInstance.WithProjectChanges(project =>
|
||||
{
|
||||
var ns = project.Root.Name.Namespace;
|
||||
|
||||
var toolReference = project.Descendants(ns + "DotNetCliToolReference")
|
||||
.Where(tr => tr.Attribute("Include").Value == "dotnet-portable")
|
||||
.Single();
|
||||
|
||||
toolReference.Attribute("Include").Value =
|
||||
toolPrefersCLIRuntime ? "dotnet-portable-v1-prefercli" : "dotnet-portable-v1";
|
||||
});
|
||||
|
||||
testInstance = testInstance.WithRestoreFiles();
|
||||
|
||||
new BuildCommand()
|
||||
.WithProjectDirectory(testInstance.Root)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new GenericCommand(toolPrefersCLIRuntime ? "portable-v1-prefercli" : "portable-v1")
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.Execute()
|
||||
.Should().Fail();
|
||||
}
|
||||
|
||||
[RequiresSpecificFrameworkTheory("netcoreapp1.1")]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void IfPreviousVersionOfSharedFrameworkIsInstalled_ToolsTargetingItRun(bool toolPrefersCLIRuntime)
|
||||
{
|
||||
var testInstance = TestAssets.Get("AppWithToolDependency")
|
||||
.CreateInstance(identifier: toolPrefersCLIRuntime ? "preferCLIRuntime" : "")
|
||||
.WithSourceFiles()
|
||||
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages);
|
||||
|
||||
testInstance = testInstance.WithProjectChanges(project =>
|
||||
{
|
||||
var ns = project.Root.Name.Namespace;
|
||||
|
||||
var toolReference = project.Descendants(ns + "DotNetCliToolReference")
|
||||
.Where(tr => tr.Attribute("Include").Value == "dotnet-portable")
|
||||
.Single();
|
||||
|
||||
toolReference.Attribute("Include").Value =
|
||||
toolPrefersCLIRuntime ? "dotnet-portable-v1-prefercli" : "dotnet-portable-v1";
|
||||
});
|
||||
|
||||
testInstance = testInstance.WithRestoreFiles();
|
||||
|
||||
new BuildCommand()
|
||||
.WithProjectDirectory(testInstance.Root)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var result =
|
||||
new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes)
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.Execute(toolPrefersCLIRuntime ? "portable-v1-prefercli" : "portable-v1");
|
||||
|
||||
result.Should().Pass()
|
||||
.And.HaveStdOutContaining("I'm running on shared framework version 1.1.1!");
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanInvokeToolWhosePackageNameIsDifferentFromDllName()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue