Exemplo n.º 1
0
        public void TestAddListener1()
        {
            Add("Hello World!");
            using (var search = new LogFileSearch(_scheduler, _logFile.Object, "l"))
            {
                search.AddListener(_listener.Object);

                _scheduler.RunOnce();

                _matches.Should().Equal(new[]
                    {
                        new LogMatch(0, new LogLineMatch(2, 1)),
                        new LogMatch(0, new LogLineMatch(3, 1)),
                        new LogMatch(0, new LogLineMatch(9, 1))
                    });
            }
        }
Exemplo n.º 2
0
 private void DisposeCurrentSearch()
 {
     if (_currentSearch != null)
     {
         _currentSearch.Dispose();
         _currentSearch = null;
     }
 }
Exemplo n.º 3
0
        private void CreateSearch()
        {
            DisposeCurrentSearch();

            var term = SearchTerm;
            _currentSearch = !string.IsNullOrEmpty(term) ? new LogFileSearch(_taskScheduler, _logFile, term, _maximumWaitTime) : null;
            _search.SearchTerm = SearchTerm;
        }
Exemplo n.º 4
0
        public void TestCtor2()
        {
            Add("Hello World!");
            using (var search = new LogFileSearch(_scheduler, _logFile.Object, "l"))
            {
                _scheduler.RunOnce();

                search.Count.Should().Be(3);
                var matches = search.Matches.ToList();
                matches.Should().Equal(new[]
                    {
                        new LogMatch(0, new LogLineMatch(2, 1)),
                        new LogMatch(0, new LogLineMatch(3, 1)),
                        new LogMatch(0, new LogLineMatch(9, 1))
                    });
            }
        }
Exemplo n.º 5
0
 public void TestCtor1()
 {
     using (var search = new LogFileSearch(_scheduler, _logFile.Object, "foobar"))
     {
         search.Matches.Should().BeEmpty("because the source is empty");
     }
 }
Exemplo n.º 6
0
        public void TestDispose()
        {
            LogFileSearch search;
            using (search = new LogFileSearch(_scheduler, _logFile.Object, "foobar"))
            {
                search.IsDisposed.Should().BeFalse();
                _scheduler.PeriodicTaskCount.Should().Be(1);
            }

            search.IsDisposed.Should().BeTrue();
            _scheduler.PeriodicTaskCount.Should().Be(0);
        }