protected AbstractDataSource(ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime)
        {
            if (taskScheduler == null)
            {
                throw new ArgumentNullException(nameof(taskScheduler));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (settings.Id == DataSourceId.Empty)
            {
                throw new ArgumentException("settings.Id shall be set to an actually generated id");
            }

            _taskScheduler   = taskScheduler;
            _settings        = settings;
            _maximumWaitTime = maximumWaitTime;
            _counter         = new LogFileCounter();

            _logFile = new LogFileProxy(taskScheduler, maximumWaitTime);
            _search  = new LogFileSearchProxy(taskScheduler, _logFile, maximumWaitTime);

            _findAllLogFile = new LogFileProxy(taskScheduler, maximumWaitTime);
            _findAllSearch  = new LogFileSearchProxy(taskScheduler, _findAllLogFile, maximumWaitTime);

            UpdateSearch();
            UpdateFindAllSearch();
        }
Example #2
0
 public void TestCtor1()
 {
     using (var proxy = new LogFileSearchProxy(_scheduler, _logFile.Object, TimeSpan.Zero))
     {
         proxy.SearchTerm.Should().BeNull();
         proxy.Count.Should().Be(0);
     }
 }
Example #3
0
        public void TestSearch1()
        {
            AddEntry("Hello World!");
            AddEntry("Foobar");

            using (var proxy = new LogFileSearchProxy(_scheduler, _logFile.Object, TimeSpan.Zero))
            {
                proxy.SearchTerm = "foobar";
                proxy.Property(x => x.Count).ShouldAfter(TimeSpan.FromSeconds(20)).Be(1, "because we should be able to search through the file in a few seconds");

                proxy.Matches.Should().Equal(new[]
                {
                    new LogMatch(1, new LogLineMatch(0, 6))
                });
                proxy.Count.Should().Be(1);
            }
        }