diff --git a/HostsFileEditor.Core.Tests/HostsEntryTests.cs b/HostsFileEditor.Core.Tests/HostsEntryTests.cs index 9aaf604..d52cc67 100644 --- a/HostsFileEditor.Core.Tests/HostsEntryTests.cs +++ b/HostsFileEditor.Core.Tests/HostsEntryTests.cs @@ -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() { diff --git a/HostsFileEditor.Core/Properties/Resources.resx b/HostsFileEditor.Core/Properties/Resources.resx index 039c016..d5114da 100644 --- a/HostsFileEditor.Core/Properties/Resources.resx +++ b/HostsFileEditor.Core/Properties/Resources.resx @@ -68,6 +68,9 @@ Invalid Host Entries + + Invalid host names + Hosts File Editor Question