GivenDotnetTestForwardDotnetRootEnvironmentVariables.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. using Microsoft.DotNet.Tools.Test.Utilities;
  4. namespace Microsoft.DotNet.Cli.Test.Tests
  5. {
  6. public class VSTestForwardDotnetRootEnvironmentVariables : SdkTest
  7. {
  8. private const string TestAppName = "VSTestForwardDotnetRootEnvironmentVariables";
  9. public VSTestForwardDotnetRootEnvironmentVariables(ITestOutputHelper log) : base(log)
  10. {
  11. }
  12. private readonly string[] ConsoleLoggerOutputDetailed = new[] { "--logger", "console;verbosity=detailed" };
  13. [Fact]
  14. public void ShouldForwardDotnetRootEnvironmentVariablesIfNotProvided()
  15. {
  16. var testAsset = _testAssetsManager.CopyTestAsset(TestAppName)
  17. .WithSource()
  18. .WithVersionVariables();
  19. var command = new DotnetTestCommand(Log, disableNewOutput: true).WithWorkingDirectory(testAsset.Path);
  20. command.EnvironmentToRemove.Add("DOTNET_ROOT");
  21. command.EnvironmentToRemove.Add("DOTNET_ROOT(x86)");
  22. var result = command.Execute(ConsoleLoggerOutputDetailed);
  23. if (!TestContext.IsLocalized())
  24. {
  25. result.StdOut
  26. .Should().Contain("Total tests: 1")
  27. .And.Contain("Passed: 1")
  28. .And.Contain("Passed TestForwardDotnetRootEnvironmentVariables")
  29. .And.Contain("VSTEST_WINAPPHOST_");
  30. }
  31. result.ExitCode.Should().Be(0);
  32. }
  33. }
  34. }