public EventsLogAnalyser(ITaskScheduler scheduler, ILogFile source, TimeSpan maximumWaitTime, EventsLogAnalyserConfiguration configuration) { if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } _scheduler = scheduler; _source = source; _buffer = new LogLine[MaximumLineCount]; _events = new InMemoryLogTable(); _indices = new List <LogLineIndex>(); _eventDefinitions = new List <LogEventDefinition>(configuration.Events.Count); _eventDefinitions.AddRange(configuration.Events.Select(TryCreateDefinition).Where(x => x != null)); _modifications = new ConcurrentQueue <LogFileSection>(); _source.AddListener(this, maximumWaitTime, MaximumLineCount); _task = _scheduler.StartPeriodic(DoWork, TimeSpan.FromMilliseconds(100)); }
public void TestAddEntry1() { var table = new InMemoryLogTable(); table.AddEntry(new LogEntry()); table.Count.Should().Be(1); }
public void TestConstruction() { var table = new InMemoryLogTable(); table.Exists.Should().BeTrue(); table.LastModified.Should().Be(DateTime.MinValue); table.Count.Should().Be(0); table.Schema.Should().NotBeNull(); table.Schema.ColumnHeaders.Should().NotBeNull(); table.Schema.ColumnHeaders.Should().BeEmpty(); }
public void TestAddEntry3() { var table = new InMemoryLogTable(); table.AddListener(_listener.Object, TimeSpan.Zero, 1); table.AddEntry(new LogEntry()); _modifications.Should() .Equal(new object[] { LogTableModification.Reset, new LogTableModification(0, 1) }); }
public void TestAddEntry2() { var table = new InMemoryLogTable(new ColumnHeader("Name")); table.AddEntry(new LogEntry("Foo")); var task = table[0]; task.Should().NotBeNull(); task.Wait(TimeSpan.FromSeconds(1)); var entry = task.Result; entry.Fields.Should().Equal(new object[] { "Foo" }); }