public void PingClass() { var pings = 2; var exe = new Executable(); exe.LoadFromObject <Pinger>(); var processor = new RegexCaptureOutputProcessor() .AddRegex <PingResult>(new Regex(@"Reply from (?<ip>[^:]+): (?:bytes=(?<bytes>\d+) time[^\d]*(?<time>[^ ]+) TTL=(?<ttl>\d+)|(?<fail>.+))")) .AddPropertyMapping((string s) => !string.IsNullOrEmpty(s) ? TimeSpan.FromMilliseconds(int.Parse(s.TrimEnd('m', 's'))) : (TimeSpan?)null); foreach (var command in exe.Commands) { command.Processor = processor; } var matches = 0; matches += exe.ExecuteCommandAndParseList <PingResult>("ping1", new PingArguments() { Count = pings, Host = "127.0.0.1", Timeout = 50 }).Count; matches += exe.ExecuteCommandAndParseList <PingResult>("ping2", new { Count = pings, Host = "127.0.0.1", Timeout = 50 }).Count; matches += exe.ExecuteCommandAndParseList <PingResult>("ping3", new { n = pings, Host = "127.0.0.1", w = 50 }).Count; matches += exe.ExecuteCommandAndParseList <PingResult>("ping4", new { n = pings, Host = "127.0.0.1", w = 50 }).Count; Assert.Equal(pings * 4, matches); }
public void OnConfiguring(Executable executable) { var processor = new RegexCaptureOutputProcessor() .AddRegex <PingResult>(new Regex(@"Reply from (?<ip>[^:]+): (?:bytes=(?<bytes>\d+) time[^\d]*(?<time>[^ ]+) TTL=(?<ttl>\d+)|(?<fail>.+))")) .AddPropertyMapping((string s) => !string.IsNullOrEmpty(s) ? TimeSpan.FromMilliseconds(int.Parse(s.TrimEnd('m', 's'))) : (TimeSpan?)null); foreach (var command in executable.Commands) { command.Processor = processor; } }