Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/TraceClient.Tests/InstallIdTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> { { "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<string, string> { { "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()
{
Expand Down
32 changes: 32 additions & 0 deletions tests/TraceClient.Tests/TraceClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> { { "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<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("Version", "9.9.9"),
new KeyValuePair<string, string>(" 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()
{
Expand Down
Loading