public static void Main(string[] args) { try { var p = new Program(); var options = new Options(); var parser = new CommandLine.Parser(settings => settings.CaseSensitive = true); if (parser.ParseArguments(args, options)) { p.Run(options); } else { // print help Console.WriteLine(options.GetUsage()); } if (options.Debug) { Watch.PrintTasks(); } } catch (Exception e) { ConsoleEx.PrintException(e.Message, e); Environment.ExitCode = e.HResult == 0 ? -1 : e.HResult; } }
public void TestRead() { var hostsfile = new HostsFile(MyFile); List <HostsFileLine> hosts; using (new Watch("GetHosts")) { hosts = hostsfile.GetHosts().ToList(); } // print Watch.PrintTasks(); var table = new Table(); table.Create(1, 1, "Hosts", hosts); // validate Assert.IsNotEmpty(hosts); Assert.AreEqual(11 * REPEAT, hosts.Count, "Count all"); Assert.AreEqual(0 * REPEAT, hosts.Count(x => x.IsCommentarLine), "CommentarLine count"); Assert.AreEqual(5 * REPEAT, hosts.Count(x => x.IsDisabled), "Disabled count"); Assert.AreEqual(3 * REPEAT, hosts.Count(x => !string.IsNullOrEmpty(x.Ipv6)), "Ipv6 count"); Assert.AreEqual(2 * REPEAT, hosts.Count(x => !string.IsNullOrEmpty(x.Commentar)), "Commentar count"); }