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
20 changes: 20 additions & 0 deletions tests/TraceClient.Tests/InstallIdTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,26 @@ public void Report_AnEventsOwnInstallTagWins()
_server.Received.Single().Body);
}

[Fact]
public void Report_AnEventsOwnInstallTagPastTheLimitDropsTheEventRatherThanFallingBack()
{
var log = new ConcurrentQueue<string>();
var client = new TraceClient(_server.BaseUrl, "MyGame", "1.2.3", key: "k", log: log.Enqueue,
installId: "configured");

client.Report("startup", tags: new Dictionary<string, string> { { "install", new string('i', TraceClient.MaxLength + 1) } });
client.Report("command", tags: new Dictionary<string, string> { { "install", new string('i', TraceClient.MaxLength) } });
client.Close();

// The event's own tag wins even when the server would reject it, so the
// configured ID is not sent in its place: the whole event is dropped.
Assert.Equal("[trace] dropped startup: tag install longer than " + TraceClient.MaxLength + " characters",
Assert.Single(log));
Assert.Equal("{\"application\":\"MyGame\",\"name\":\"command\","
+ "\"tags\":{\"install\":\"" + new string('i', TraceClient.MaxLength) + "\",\"version\":\"1.2.3\"}}",
_server.Received.Single().Body);
}

[Fact]
public void Report_ANullInstallTagDoesNotDisplaceTheConfiguredId()
{
Expand Down
19 changes: 19 additions & 0 deletions tests/TraceClient.Tests/TraceClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,25 @@ public void Report_AnEmptyVersionTagStillWinsOverTheProgramVersion()
_server.Received.Single().Body);
}

[Fact]
public void Report_AnEventsOwnVersionTagPastTheLimitDropsTheEventRatherThanFallingBack()
{
var log = new ConcurrentQueue<string>();
var client = new TraceClient(_server.BaseUrl, "MyGame", "1.2.3", key: "k", log: log.Enqueue);

client.Report("startup", tags: new Dictionary<string, string> { { "version", new string('9', TraceClient.MaxLength + 1) } });
client.Report("command", tags: new Dictionary<string, string> { { "version", new string('9', TraceClient.MaxLength) } });
client.Close();

// The event's own tag wins even when the server would reject it, so the
// program's version is not sent in its place: the whole event is dropped.
Assert.Equal("[trace] dropped startup: tag version longer than " + TraceClient.MaxLength + " characters",
Assert.Single(log));
Assert.Equal("{\"application\":\"MyGame\",\"name\":\"command\","
+ "\"tags\":{\"version\":\"" + new string('9', TraceClient.MaxLength) + "\"}}",
_server.Received.Single().Body);
}

[Fact]
public void Report_OnlyTheExactLowercaseVersionKeyCountsAsTheEventsOwn()
{
Expand Down
Loading