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
18 changes: 18 additions & 0 deletions tests/TraceClient.Tests/InstallIdTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ public void InstallIdFromFile_ReadsTheFirstValidLineAndReplacesAFileWithoutOne()
Assert.Equal(fresh, TraceClient.InstallIdFromFile(junk));
}

[Theory]
[InlineData("")]
[InlineData(" \n\t\n")]
public void InstallIdFromFile_ReplacesAnEmptyOrBlankFileWithAFreshId(string contents)
{
// A file that exists but holds nothing -- touched by hand, or cut off
// while being written -- is treated like a missing one.
Directory.CreateDirectory(_directory);
string path = Path.Combine(_directory, "install-id");
File.WriteAllText(path, contents);

string id = TraceClient.InstallIdFromFile(path);

Assert.True(IsGuid(id), id);
Assert.Equal(id + "\n", File.ReadAllText(path));
Assert.Equal(id, TraceClient.InstallIdFromFile(path));
}

[Fact]
public void InstallIdFromFile_KeepsALineExactlyAtTheLimit()
{
Expand Down
12 changes: 12 additions & 0 deletions tests/TraceClient.Tests/TraceClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@ public void DisabledReason_NamesTheConfigFlagOrTheMissingKey()
Assert.Equal("config", TraceClient.Disabled().DisabledReason);
}

[Theory]
[InlineData("")]
[InlineData(" ")]
[InlineData("\t\n")]
public void DisabledReason_TreatsABlankKeyAsNoKey(string key)
{
var client = new TraceClient(_server.BaseUrl, "MyGame", "1.2.3", key: key);

Assert.False(client.IsEnabled);
Assert.Equal(TraceClient.ReasonNoKey, client.DisabledReason);
}

[Theory]
[InlineData("off")]
[InlineData("OFF")]
Expand Down
Loading