[Hosts] Improved duplicate hosts finding (#24294)

* improved duplicate hosts finding

* improved filters with AdvancedCollectionView

* cancel FindDuplicates when file is reloaded
This commit is contained in:
Davide Giacometti
2023-02-27 19:11:57 +01:00
committed by GitHub
parent 0d9b797ef0
commit 3e651b8de6
14 changed files with 294 additions and 87 deletions

View File

@@ -28,7 +28,7 @@ namespace Hosts.Tests
[DataRow("# # \t10.1.1.1 host#comment", "10.1.1.1", "host", "comment", false)]
public void Valid_Entry_SingleHost(string line, string address, string host, string comment, bool active)
{
var entry = new Entry(line);
var entry = new Entry(0, line);
Assert.AreEqual(entry.Address, address);
Assert.AreEqual(entry.Hosts, host);
@@ -52,7 +52,7 @@ namespace Hosts.Tests
[DataRow("#10.1.1.1 host host.local#comment", "10.1.1.1", "host host.local", "comment", false)]
public void Valid_Entry_MultipleHosts(string line, string address, string host, string comment, bool active)
{
var entry = new Entry(line);
var entry = new Entry(0, line);
Assert.AreEqual(entry.Address, address);
Assert.AreEqual(entry.Hosts, host);
@@ -76,7 +76,7 @@ namespace Hosts.Tests
[DataRow("host 10.1.1.1")]
public void Not_Valid_Entry(string line)
{
var entry = new Entry(line);
var entry = new Entry(0, line);
Assert.IsFalse(entry.Valid);
}
}

View File

@@ -70,7 +70,7 @@ namespace Hosts.Tests
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var (_, entries) = await service.ReadAsync();
entries.Add(new Entry("10.1.1.30", "host30 host30.local", "new entry", false));
entries.Add(new Entry(0, "10.1.1.30", "host30 host30.local", "new entry", false));
await service.WriteAsync(string.Empty, entries);
var result = fileSystem.GetFile(service.HostsFilePath);