public void TestAddEntry1()
        {
            var settings = new EventsLogAnalyserConfiguration
            {
                Events =
                {
                    new EventConfiguration {
                        FilterExpression = @"Found (\d+) things"
                    }
                }
            };

            using (var analyser = new EventsLogAnalyser(_scheduler,
                                                        _source,
                                                        TimeSpan.Zero,
                                                        settings
                                                        ))
            {
                _scheduler.RunOnce();
                analyser.Events.Count.Should().Be(0);

                _source.AddEntry("Found 42 things", LevelFlags.None);
                _scheduler.RunOnce();
                analyser.Events.Count.Should().Be(1);
                var actualEntry = analyser.Events[0].Result;
                actualEntry.Should().Be(new LogEntry(null, "42"));
            }
        }
        public void TestRoundtrip()
        {
            using (var data = new MemoryStream())
            {
                var settings = new EventsLogAnalyserConfiguration
                {
                    MaxEvents = 9999,
                    Events    =
                    {
                        new EventConfiguration
                        {
                            Name             = "My custom event",
                            FilterExpression = "%d",
                        }
                    }
                };

                using (var writer = XmlWriter.Create(data, new XmlWriterSettings
                {
                    NewLineHandling = NewLineHandling.Entitize,
                    Indent = true,
                    NewLineChars = "\r\n"
                }))
                {
                    writer.WriteStartElement("Test");
                    //settings.Save(writer);
                    writer.WriteEndElement();
                }
                data.Position = 0;
                using (var reader = new StreamReader(data))
                {
                    Console.Write(reader.ReadToEnd());
                    data.Position = 0;
                    using (var xmlReader = XmlReader.Create(data))
                    {
                        xmlReader.MoveToContent();
                        xmlReader.MoveToElement();

                        //var actualSettings = (EventsLogAnalyserConfiguration)LogAnalyserConfiguration.Restore(xmlReader);
                        //actualSettings.MaxEvents.Should().Be(9999);
                        //actualSettings.Events.Count.Should().Be(1);
                        //actualSettings.Events[0].Name.Should().Be("My custom event");
                        //actualSettings.Events[0].FilterExpression.Should().Be("%d");
                    }
                }
            }
        }
        public void TestConstruction2()
        {
            var settings = new EventsLogAnalyserConfiguration
            {
                Events =
                {
                    new EventConfiguration
                    {
                        FilterExpression = "[."
                    }
                }
            };

            new Action(() => new EventsLogAnalyser(_scheduler,
                                                   _source,
                                                   TimeSpan.Zero,
                                                   settings)).ShouldNotThrow("becuase the analyser should just ignore invalid event definitions");
        }
Exemplo n.º 4
0
 public void TestRoundtrip()
 {
     var config = new EventsLogAnalyserConfiguration
     {
         MaxEvents = 9999,
         Events    =
         {
             new EventConfiguration
             {
                 Name             = "My custom event",
                 FilterExpression = "%d",
             }
         }
     };
     var actualConfig = Roundtrip(config);
     //actualConfig.MaxEvents.Should().Be(9999);
     //actualConfig.Events.Count.Should().Be(1);
     //actualConfig.Events[0].Name.Should().Be("My custom event");
     //actualConfig.Events[0].FilterExpression.Should().Be("%d");
 }
        public void TestOneEntry2()
        {
            var settings = new EventsLogAnalyserConfiguration
            {
                Events =
                {
                    new EventConfiguration {
                        FilterExpression = @"Found (\d+) thing(s)"
                    }
                }
            };

            _source.AddEntry("Found tmp things", LevelFlags.None);

            using (var analyser = new EventsLogAnalyser(_scheduler,
                                                        _source,
                                                        TimeSpan.Zero,
                                                        settings
                                                        ))
            {
                _scheduler.RunOnce();
                analyser.Events.Count.Should().Be(0);
            }
        }
Exemplo n.º 6
0
 private EventsLogAnalyserConfiguration Roundtrip(EventsLogAnalyserConfiguration config)
 {
     return(config.Roundtrip(typeof(EventConfiguration)));
 }