Exemplo n.º 1
0
 public void TestAdd2()
 {
     var results = new SearchResults();
     results.Add(0, new LogLineMatch(1, 2));
     results.Add(1, new LogLineMatch(5, 42));
     results.Count.Should().Be(2);
     results.MatchesByLine[0].Should().Equal(new[] { new LogLineMatch(1, 2) });
     results.MatchesByLine[1].Should().Equal(new[] { new LogLineMatch(5, 42) });
 }
Exemplo n.º 2
0
 public void OnSearchModified(ILogSourceSearch sender, IEnumerable <LogMatch> matches)
 {
     foreach (var match in matches)
     {
         _results.Add(match);
     }
 }
Exemplo n.º 3
0
        public void TestClear3()
        {
            var results = new SearchResults();
            results.Add(42, new LogLineMatch(1, 5));

            results.MatchesByLine[42].Should().NotBeEmpty();

            new Action(results.Clear).ShouldNotThrow();
            results.MatchesByLine[42].Should().BeEmpty();
        }
Exemplo n.º 4
0
        public void TestClear2()
        {
            var results = new SearchResults();
            results.Add(42, new LogLineMatch(1, 5));

            results.Count.Should().Be(1);
            results.Matches.Should().Equal(new[] {new LogMatch(42, new LogLineMatch(1, 5))});

            new Action(results.Clear).ShouldNotThrow();
            results.Count.Should().Be(0);
            results.Matches.Should().BeEmpty();
        }
Exemplo n.º 5
0
        public bool Update()
        {
            lock (_syncRoot)
            {
                if (!_modified)
                {
                    return(false);
                }

                _actualResults.Clear();
                _actualResults.Add(_matches);

                _modified = false;
                return(true);
            }
        }
Exemplo n.º 6
0
        public void TestIncorrectSearchResult()
        {
            var textLine = new TextLine(new LogLine(0, 0, "foobar", LevelFlags.Fatal), _hovered, _selected, true);
            var searchResults = new SearchResults();
            searchResults.Add(new LogLineIndex(0), new LogLineMatch(42, 101));

            new Action(() => textLine.SearchResults = searchResults).ShouldNotThrow();

            IEnumerable<TextSegment> segments = null;
            new Action(() => segments = textLine.Segments).ShouldNotThrow();

            segments.Should().NotBeEmpty();
            segments.Count().Should().Be(1);
            segments.ElementAt(0).Text.Should().Be("foobar", "because if, for some reason, highlighting doesn't work, then the original, non-highlithed, line should be displayed");
        }
Exemplo n.º 7
0
        public void TestHighlight5()
        {
            var results = new SearchResults();
            results.Add(new LogMatch(0, new LogLineMatch(28, 5)));

            var textLine = new TextLine(new LogLine(0, 0, ".NET Environment: 4.0.30319.42000", LevelFlags.None), _hovered,
                                        _selected, true)
            {
                SearchResults = results
            };

            textLine.Segments.Count().Should().Be(2);
            textLine.Segments.ElementAt(0).Text.Should().Be(".NET Environment: 4.0.30319.");
            textLine.Segments.ElementAt(1).Text.Should().Be("42000");
        }
Exemplo n.º 8
0
        public void TestHighlight3()
        {
            var textLine = new TextLine(new LogLine(0, 0, "foobar", LevelFlags.Fatal), _hovered, _selected, true);
            textLine.Segments.Count().Should().Be(1);
            textLine.Segments.First().FormattedText.Text.Should().Be("foobar");

            var results = new SearchResults();
            results.Add(new LogMatch(0, new LogLineMatch(1, 2)));
            textLine.SearchResults = results;
            var segments = textLine.Segments.ToList();
            segments.Count.Should().Be(3);
            segments[0].FormattedText.Text.Should().Be("f");
            segments[1].FormattedText.Text.Should().Be("oo");
            segments[2].FormattedText.Text.Should().Be("bar");
        }