diff --git a/tests/TraceClient.Tests/InstallIdTest.cs b/tests/TraceClient.Tests/InstallIdTest.cs index f495474..69a4913 100644 --- a/tests/TraceClient.Tests/InstallIdTest.cs +++ b/tests/TraceClient.Tests/InstallIdTest.cs @@ -342,6 +342,33 @@ public void Report_ANullInstallTagDoesNotDisplaceTheConfiguredId() _server.Received.Single().Body); } + [Fact] + public void Report_AnEmptyInstallTagStillWinsOverTheConfiguredId() + { + var client = new TraceClient(_server.BaseUrl, "MyGame", "1.2.3", key: "k", installId: "configured"); + + client.Report("startup", tags: new Dictionary { { "install", "" } }); + client.Close(); + + // Unlike a null value, an empty one is a tag: it is sent, and the configured ID is not added. + Assert.Equal("{\"application\":\"MyGame\",\"name\":\"startup\",\"tags\":{\"install\":\"\",\"version\":\"1.2.3\"}}", + _server.Received.Single().Body); + } + + [Fact] + public void Report_OnlyTheExactLowercaseInstallKeyCountsAsTheEventsOwn() + { + var client = new TraceClient(_server.BaseUrl, "MyGame", "1.2.3", key: "k", installId: "configured"); + + client.Report("startup", tags: new Dictionary { { "Install", "own" } }); + client.Close(); + + // Keys are compared ordinally, so "Install" is an ordinary tag and the configured ID is still added. + Assert.Equal("{\"application\":\"MyGame\",\"name\":\"startup\"," + + "\"tags\":{\"Install\":\"own\",\"version\":\"1.2.3\",\"install\":\"configured\"}}", + _server.Received.Single().Body); + } + [Fact] public void Report_NeverAddsTheInstallTagPastTheTagLimit() { diff --git a/tests/TraceClient.Tests/TraceClientTest.cs b/tests/TraceClient.Tests/TraceClientTest.cs index 13b23e1..e186bfe 100644 --- a/tests/TraceClient.Tests/TraceClientTest.cs +++ b/tests/TraceClient.Tests/TraceClientTest.cs @@ -593,6 +593,38 @@ public void Report_ANullVersionTagDoesNotDisplaceTheProgramVersion() _server.Received.Single().Body); } + [Fact] + public void Report_AnEmptyVersionTagStillWinsOverTheProgramVersion() + { + var client = new TraceClient(_server.BaseUrl, "MyGame", "1.2.3", key: "k"); + + client.Report("startup", tags: new Dictionary { { "version", "" } }); + client.Close(); + + // Unlike a null value, an empty one is a tag: it is sent, and the program's version is not added. + Assert.Equal("{\"application\":\"MyGame\",\"name\":\"startup\",\"tags\":{\"version\":\"\"}}", + _server.Received.Single().Body); + } + + [Fact] + public void Report_OnlyTheExactLowercaseVersionKeyCountsAsTheEventsOwn() + { + var client = new TraceClient(_server.BaseUrl, "MyGame", "1.2.3", key: "k"); + var tags = new List> + { + new KeyValuePair("Version", "9.9.9"), + new KeyValuePair(" version", "8.8.8"), + }; + + client.Report("startup", tags: tags); + client.Close(); + + // Keys are compared ordinally and untrimmed, so both are ordinary tags and the program's version is added. + Assert.Equal("{\"application\":\"MyGame\",\"name\":\"startup\"," + + "\"tags\":{\"Version\":\"9.9.9\",\" version\":\"8.8.8\",\"version\":\"1.2.3\"}}", + _server.Received.Single().Body); + } + [Fact] public void Report_NeverModifiesTheCallersDictionary() {