forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGivenThatDotNetRunsCommands.cs
More file actions
69 lines (60 loc) · 2.58 KB
/
GivenThatDotNetRunsCommands.cs
File metadata and controls
69 lines (60 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable
using Microsoft.DotNet.Configurer;
using LocalizableStrings = Microsoft.DotNet.Cli.Utils.LocalizableStrings;
namespace Microsoft.DotNet.Tests
{
public class GivenThatDotNetRunsCommands : SdkTest
{
public GivenThatDotNetRunsCommands(ITestOutputHelper log) : base(log)
{
}
[Fact]
public void UnresolvedPlatformReferencesFailAsExpected()
{
var testInstance = _testAssetsManager.CopyTestAsset("TestProjectWithUnresolvedPlatformDependency", testAssetSubdirectory: "NonRestoredTestProjects")
.WithSource();
new RestoreCommand(testInstance)
.Execute("/p:SkipInvalidConfigurations=true")
.Should()
.Fail();
new DotnetCommand(Log)
.WithWorkingDirectory(testInstance.Path)
.Execute("crash")
.Should().Fail()
.And.HaveStdErrContaining(LocalizableStrings.NoExecutableFoundMatchingCommandErrorMessage)
.And.HaveStdOutContaining(string.Format(LocalizableStrings.NoExecutableFoundMatchingCommand, "dotnet-crash"));
}
[Theory]
[InlineData("")]
[InlineData(null)]
public void GivenAMissingHomeVariableItExecutesHelpCommandSuccessfully(string value)
{
new DotnetCommand(Log)
.WithEnvironmentVariable(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "USERPROFILE" : "HOME", value)
.WithEnvironmentVariable(CliFolderPathCalculator.DotnetHomeVariableName, "")
.Execute("--help")
.Should()
.Pass()
.And
.HaveStdOutContaining(LocalizableStrings.DotNetSdkInfo);
}
[Fact]
public void GivenASpecifiedDotnetCliHomeVariableItPrintsUsageMessage()
{
var home = _testAssetsManager.CreateTestDirectory(identifier: "DOTNET_HOME").Path;
new DotnetCommand(Log)
.WithEnvironmentVariable(CliFolderPathCalculator.DotnetHomeVariableName, home)
.Execute("-d", "help")
.Should()
.Pass()
.And
.HaveStdOutContaining(
string.Format(
LocalizableStrings.DotnetCliHomeUsed,
home,
CliFolderPathCalculator.DotnetHomeVariableName));
}
}
}