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
5 changes: 4 additions & 1 deletion CounterStrikeProgression.Core/Players/BotNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ internal static class BotNames
}

string trimmed = current.Trim();
if (names.Values.Any(given => string.Equals(given.Trim(), trimmed, StringComparison.OrdinalIgnoreCase)))

// A null value is read from config as readily as a blank one ("Rock": null), and means the same:
// leave that bot alone. It must not stop every other bot from being renamed.
if (names.Values.Any(given => string.Equals(given?.Trim(), trimmed, StringComparison.OrdinalIgnoreCase)))
{
return null;
}
Expand Down
8 changes: 8 additions & 0 deletions CounterStrikeProgression.Test/BotNameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ public void RenameFor_LeavesABlankNameAlone() =>
[TestMethod]
public void RenameFor_IgnoresABlankTarget() =>
Assert.IsNull(BotNames.RenameFor(new Dictionary<string, string> { ["Rock"] = " " }, "Rock"));

[TestMethod]
public void RenameFor_ANullTarget_StillRenamesTheOtherBots() =>
Assert.AreEqual("Muhlik", BotNames.RenameFor(new Dictionary<string, string> { ["Rock"] = null!, ["Bob"] = "Muhlik" }, "Bob"));

[TestMethod]
public void RenameFor_IgnoresANullTarget() =>
Assert.IsNull(BotNames.RenameFor(new Dictionary<string, string> { ["Rock"] = null!, ["Bob"] = "Muhlik" }, "Rock"));
}
Loading