Skip to content

Commit 86b3e5d

Browse files
committed
update tests with targetframeworkeval telemetry
1 parent 5649fb6 commit 86b3e5d

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreAppForTelemetry.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ public GivenThatWeWantToBuildANetCoreAppAndPassingALogger(ITestOutputHelper log)
1111
{
1212
}
1313

14+
private string CreateTargetFrameworkEvalTelemetryJson(
15+
string targetFrameworkVersion,
16+
string targetPlatformIdentifier = "null",
17+
string runtimeIdentifier = "null",
18+
string selfContained = "null",
19+
string useApphost = "null",
20+
string outputType = "Library",
21+
string useArtifactsOutput = "null",
22+
string artifactsPathLocationType = "null",
23+
string useMonoRuntime = "null",
24+
string publishAot = "null",
25+
string publishTrimmed = "null",
26+
string publishSelfContained = "null",
27+
string publishReadyToRun = "null",
28+
string publishReadyToRunComposite = "false",
29+
string publishProtocol = "null",
30+
string configuration = "Debug")
31+
{
32+
return $"{{\"EventName\":\"targetframeworkeval\",\"Properties\":{{\"TargetFrameworkVersion\":\"{targetFrameworkVersion}\",\"RuntimeIdentifier\":\"{runtimeIdentifier}\",\"SelfContained\":\"{selfContained}\",\"UseApphost\":\"{useApphost}\",\"OutputType\":\"{outputType}\",\"UseArtifactsOutput\":\"{useArtifactsOutput}\",\"ArtifactsPathLocationType\":\"{artifactsPathLocationType}\",\"TargetPlatformIdentifier\":\"{targetPlatformIdentifier}\",\"UseMonoRuntime\":\"{useMonoRuntime}\",\"PublishAot\":\"{publishAot}\",\"PublishTrimmed\":\"{publishTrimmed}\",\"PublishSelfContained\":\"{publishSelfContained}\",\"PublishReadyToRun\":\"{publishReadyToRun}\",\"PublishReadyToRunComposite\":\"{publishReadyToRunComposite}\",\"PublishProtocol\":\"{publishProtocol}\",\"Configuration\":\"{configuration}\"}}";
33+
}
34+
1435
[CoreMSBuildOnlyFact]
1536
public void It_collects_TargetFramework_version_and_other_properties()
1637
{
@@ -32,7 +53,8 @@ public void It_collects_TargetFramework_version_and_other_properties()
3253
buildCommand
3354
.Execute(TelemetryTestLogger)
3455
.StdOut.Should()
35-
.Contain($"{{\"EventName\":\"targetframeworkeval\",\"Properties\":{{\"TargetFrameworkVersion\":\".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\",\"TargetPlatformIdentifier\":\"null\",\"UseMonoRuntime\":\"null\",\"PublishAot\":\"null\",\"Configuration\":\"Debug\"}}");
56+
.Contain(CreateTargetFrameworkEvalTelemetryJson(
57+
$".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}"));
3658
}
3759

3860
[CoreMSBuildOnlyFact]
@@ -59,11 +81,13 @@ public void It_collects_multi_TargetFramework_version_and_other_properties()
5981

6082
result
6183
.StdOut.Should()
62-
.Contain(
63-
"{\"EventName\":\"targetframeworkeval\",\"Properties\":{\"TargetFrameworkVersion\":\".NETFramework,Version=v4.6\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\",\"TargetPlatformIdentifier\":\"Windows\",\"UseMonoRuntime\":\"null\",\"PublishAot\":\"null\",\"Configuration\":\"Debug\"}")
84+
.Contain(CreateTargetFrameworkEvalTelemetryJson(
85+
".NETFramework,Version=v4.6",
86+
targetPlatformIdentifier: "Windows",
87+
publishReadyToRunComposite: "null"))
6488
.And
65-
.Contain(
66-
$"{{\"EventName\":\"targetframeworkeval\",\"Properties\":{{\"TargetFrameworkVersion\":\".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\",\"TargetPlatformIdentifier\":\"null\",\"UseMonoRuntime\":\"null\",\"PublishAot\":\"null\",\"Configuration\":\"Debug\"}}");
89+
.Contain(CreateTargetFrameworkEvalTelemetryJson(
90+
$".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}"));
6791
}
6892
}
6993
}

0 commit comments

Comments
 (0)