示例#1
0
        public void Load_ParsesSampleFile()
        {
            StringResource resource = new StringResource(Resources.SampleHostsFile);

            HostEntry[] expectedEntries = new HostEntry[]
            {
                new HostEntry(22, "127.0.0.1		host1.localhost # comment 1", "		", true, "host1.localhost", "127.0.0.1", "comment 1"),
                new HostEntry(23, "# 192.168.0.1		host2.localhost # comment 2", "		", false, "host2.localhost", "192.168.0.1", "comment 2"),
            };

            HostsFile file = new HostsFile(resource);

            Assert.IsTrue(expectedEntries.SequenceEqual(file.Entries));
        }
示例#2
0
        public void Load_LoadsValues()
        {
            string inputValue = "127.0.0.1    host1 # comment 1\n192.168.0.1    host2";

            HostEntry[] expectedEntries = new HostEntry[]
            {
                new HostEntry(0, "127.0.0.1    host1 # comment 1", "    ", true, "host1", "127.0.0.1", "comment 1"),
                new HostEntry(1, "192.168.0.1    host2", "    ", true, "host2", "192.168.0.1", null),
            };

            StringResource resource = new StringResource(inputValue);

            HostsFile file = new HostsFile(resource);

            Assert.IsTrue(expectedEntries.SequenceEqual(file.Entries));
        }