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
14 changes: 14 additions & 0 deletions HostsFileEditor.Core.Tests/HostsEntryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ public void Invalid_Hostname_AfterEdit()
entry.Valid.ShouldBeFalse();
}

// Regression for #131: Resources.InvalidHostnames had no matching key in Core's Resources.resx,
// so it resolved to null and SetError(null) cleared the error — an invalid hostname surfaced a
// BLANK IDataErrorInfo message (rather than "Invalid host names") in both editions.
[TestMethod]
public void Invalid_Hostname_HasNonBlankErrorMessage()
{
var entry = new HostsEntry("127.0.0.1 goodhost");
entry.HostNames = "bad@host"; // invalid character

entry.Valid.ShouldBeFalse();
entry["HostNames"].ShouldNotBeNullOrEmpty();
entry["HostNames"].ShouldBe(HostsFileEditor.Properties.Resources.InvalidHostnames);
}

[TestMethod]
public void ToString_ReturnsExpected()
{
Expand Down
3 changes: 3 additions & 0 deletions HostsFileEditor.Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
<data name="InvalidHostEntries" xml:space="preserve">
<value>Invalid Host Entries</value>
</data>
<data name="InvalidHostnames" xml:space="preserve">
<value>Invalid host names</value>
</data>
<data name="LoseChangesDialogCaption" xml:space="preserve">
<value>Hosts File Editor Question</value>
</data>
Expand Down