Example #1
0
 public void ParserCanCollectFields()
 {
     var tail = new MockedTail(new[]
     {
         "foo_1",
         "xyz",
     });
     var testObject = new Parser(tail, new MockedConfig(new List<IRule>()
     {
         new Rule(@"foo_(?<foo>\d+)") {Name = "firstrule"},
         new Rule(@"bar_(?<bar>\d+)") {Name = "secondrule", ActionOnly = false}
     }));
     CheckRules(testObject.rules);
     IDictionary<string, string> testRecord = new ConcurrentDictionary<string, string>();
     testObject.Changed += (rec) => { testRecord = rec; };
     testObject.Run();
     tail.AddLines("bar_1");
     CheckFields(new Dictionary<string, string>() { { "foo", "1" }, { "bar", "1" } }, testRecord);
 }
Example #2
0
 public void ParserCanCleanFields()
 {
     var tail = new MockedTail(new[]
     {
         "foo_1",
         "bar_2",
         "xyz_3"
     });
     var testObject = new Parser(tail, new MockedConfig(new List<IRule>()
     {
         new Rule(@"foo_(?<foo>\d+)") {Name = "firstrule"},
         new Rule(@"bar_(?<bar>\d+)") {Name = "secondrule"},
         new Rule(@"xyz_(?<xyz>\d+)") {Name = "thirdrule"},
         new Rule(@"mr.proper") {Name = "cleanerrule", Clean = "foo,xyz", ActionOnly = true},
     }));
     CheckRules(testObject.rules);
     IDictionary<string, string> testRecord = new ConcurrentDictionary<string, string>();
     testObject.Changed += (rec) => { testRecord = rec; };
     testObject.Run();
     CheckFields(new Dictionary<string, string>() { { "foo", "1" }, { "bar", "2" }, { "xyz", "3" } }, testRecord);
     tail.AddLines("mr.proper");
     CheckFields(new Dictionary<string, string>() { { "foo", "" }, { "bar", "2" }, { "xyz", "" } }, testRecord);
 }