GivenDotnetTestContainsMSBuildParameters.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.Cli.Utils;
  4. using Microsoft.DotNet.Tools.Test.Utilities;
  5. namespace Microsoft.DotNet.Cli.Test.Tests
  6. {
  7. public class GivenDotnetTestContainsMSBuildParameters : SdkTest
  8. {
  9. private const string TestAppName = "VSTestMSBuildParameters";
  10. private const string MSBuildParameter = "/p:Version=1.2.3";
  11. public GivenDotnetTestContainsMSBuildParameters(ITestOutputHelper log) : base(log)
  12. {
  13. }
  14. [InlineData($"{TestAppName}.csproj")]
  15. [InlineData(null)]
  16. [Theory]
  17. public void ItPassesEnvironmentVariablesFromCommandLineParametersWhenRunningViaCsproj(string projectName)
  18. {
  19. var testAsset = _testAssetsManager.CopyTestAsset(TestAppName)
  20. .WithSource()
  21. .WithVersionVariables();
  22. var testRoot = testAsset.Path;
  23. CommandResult result = (projectName is null ? new DotnetTestCommand(Log, disableNewOutput: true) : new DotnetTestCommand(Log, disableNewOutput: true, projectName))
  24. .WithWorkingDirectory(testRoot)
  25. .Execute("--logger", "console;verbosity=detailed", MSBuildParameter);
  26. if (!TestContext.IsLocalized())
  27. {
  28. result.StdOut
  29. .Should().Contain("Total tests: 1")
  30. .And.Contain("Passed: 1")
  31. .And.Contain("Passed TestMSBuildParameters");
  32. }
  33. result.ExitCode.Should().Be(0);
  34. }
  35. }
  36. }