public void ToString_IsNotDirty_HasOriginalString_ReturnsOriginalString() { HostEntry entry = new HostEntry(5, "original-line", " ", false, "hostname", "address", "comment"); string actualValue = entry.ToString(); Assert.AreEqual("original-line", actualValue); }
public void ToString_IsNotDirty_DoesNotHaveOriginalString_FormatsValues() { HostEntry entry = new HostEntry(5, null, " ", false, "hostname", "address", "comment"); string expectedValue = "# address hostname # comment"; string actualValue = entry.ToString(); Assert.AreEqual(expectedValue, actualValue); }
private HostEntry FindHostEntry(HostEntry entryToFind, IEnumerable <HostEntry> entries) { var entry = entries.FirstOrDefault(e => entryToFind.Line == e.Line); if (entry == null || entryToFind.ToString() != entry.ToString()) { throw new HostsFileEditCollisionException(); } foreach (HostEntry hostEntry in entries) { if (entryToFind.ToString() == hostEntry.ToString()) { return(hostEntry); } } throw new HostsFileServiceException("File has changed. Please reload"); }
public void ToString_IsDirty_FormatsValues() { HostEntry entry = new HostEntry(5, "original-line", " ", false, "hostname", "address", "comment"); entry.Hostname = "hostname2"; string expectedValue = "# address hostname2 # comment"; string actualValue = entry.ToString(); Assert.AreEqual(expectedValue, actualValue); }