public void Save_AppliesDeletionReorderingDisabling() { StringResource resource = new StringResource(Resources.ComplexHostsFile_Before); HostsFile file = new HostsFile(resource); var entry1 = file.Entries.Where(c => c.Hostname == "host1.localhost").First(); var entry2 = file.Entries.Where(c => c.Hostname == "host2.localhost").First(); var entry3 = file.Entries.Where(c => c.Hostname == "host3.localhost").First(); var entry4 = file.Entries.Where(c => c.Hostname == "host4.localhost").First(); var entry5 = file.Entries.Where(c => c.Hostname == "host5.localhost").First(); var entry6 = new HostEntry("host6.localhost", "127.0.0.1", "comment 6"); entry1.Enabled = false; entry2.Enabled = true; entry3.Enabled = false; entry3.SwapLine(entry5); // swap two with a deleted in between entry6.SwapLine(entry2); // new swapped with existing file.DeleteEntry(entry4); file.AddEntry(entry6); file.Save(); string actualOutput = resource.ToString(); Assert.AreEqual(Resources.ComplexHostsFile_Expected, actualOutput); }
public void IsDirty_LineSwapped_SwapsLineNumbers() { HostEntry entryA = new HostEntry(5, "original-line", " ", false, "hostname", "address", "comment"); HostEntry entryB = new HostEntry(10, "original-line", " ", false, "hostname", "address", "comment"); entryA.SwapLine(entryB); Assert.AreEqual(10, entryA.Line); Assert.AreEqual(5, entryB.Line); }
public void IsDirty_LineSwapped_ReturnsTrue() { HostEntry entryA = new HostEntry(5, "original-line", " ", false, "hostname", "address", "comment"); HostEntry entryB = new HostEntry(10, "original-line", " ", false, "hostname", "address", "comment"); entryA.SwapLine(entryB); Assert.IsTrue(entryA.IsDirty); Assert.IsTrue(entryB.IsDirty); }
public void IsDirty_LineSwapped_SwapsNewStatus() { HostEntry entryA = new HostEntry(-1, "original-line", " ", false, "hostname", "address", "comment"); HostEntry entryB = new HostEntry(10, "original-line", " ", false, "hostname", "address", "comment"); entryA.SwapLine(entryB); Assert.IsFalse(entryA.IsNew); Assert.IsTrue(entryB.IsNew); }