forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGivenDotnetTestInvocation.cs
45 lines (38 loc) · 1.97 KB
/
GivenDotnetTestInvocation.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using TestCommand = Microsoft.DotNet.Cli.Commands.Test.TestCommand;
namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
[Collection(TestConstants.UsesStaticTelemetryState)]
public class GivenDotnetTestInvocation : IClassFixture<NullCurrentSessionIdFixture>
{
private static readonly string[] ExpectedPrefix = ["-maxcpucount", "-verbosity:m", "-tlp:default=auto", "-nologo", "-restore", "-nologo", "-target:VSTest", "-property:NuGetInteractive=false"];
private static readonly string WorkingDirectory =
TestPathUtilities.FormatAbsolutePath(nameof(GivenDotnetTestInvocation));
[Theory]
[InlineData(new string[] { "--disable-build-servers" },
new string[] {
"--property:UseRazorBuildServer=false",
"--property:UseSharedCompilation=false",
"/nodeReuse:false",
"-property:VSTestArtifactsProcessingMode=collect",
"-property:VSTestSessionCorrelationId=<testSessionCorrelationId>"
})]
public void MsbuildInvocationIsCorrect(string[] args, string[] expectedAdditionalArgs)
{
CommandDirectoryContext.PerformActionWithBasePath(WorkingDirectory, () =>
{
Telemetry.Telemetry.DisableForTests();
expectedAdditionalArgs = expectedAdditionalArgs
.Select(arg => arg.Replace("<cwd>", WorkingDirectory))
.ToArray();
var testSessionCorrelationId = "<testSessionCorrelationId>";
var msbuildPath = "<msbuildpath>";
TestCommand.FromArgs(args, testSessionCorrelationId, msbuildPath)
.GetArgumentTokensToMSBuild()
.Should()
.BeEquivalentTo([.. ExpectedPrefix, .. expectedAdditionalArgs]);
});
}
}
}