Example #1
0
        public void Matches_WithMultipleCriteria_ShouldMatchAll()
        {
            // Arrange
            var filter = new SimpleLogFilter(level: Option.Some(LogLevel.Warn), logger: Option.Some("foo.bar"));

            // Act + Assert
            filter.Level.Should().Be(Option.Some(LogLevel.Warn));
            filter.Logger.Should().Be(Option.Some("foo.bar"));
            filter.Matches(new LogEntry {
                Level = LogLevel.Warn, Logger = "foo.bar"
            }).Should().BeTrue();
            filter.Matches(new LogEntry {
                Level = LogLevel.Info, Logger = "foo.bar"
            }).Should().BeFalse();
            filter.Matches(new LogEntry {
                Level = LogLevel.Warn, Logger = "foo.bar.baz"
            }).Should().BeFalse();
        }
Example #2
0
        public void Matches_WithLogger_ShouldMatchSuffixString()
        {
            // Arrange
            var filter = new SimpleLogFilter(logger: Option.Some("*.foo.bar"));

            // Act + Assert
            filter.Level.Should().Be(Option.None <LogLevel>());
            filter.Logger.Should().Be(Option.Some("*.foo.bar"));
            filter.Matches(new LogEntry {
                Logger = "foo.bar"
            }).Should().BeFalse();
            filter.Matches(new LogEntry {
                Logger = "foo.bar.baz"
            }).Should().BeFalse();
            filter.Matches(new LogEntry {
                Logger = "baz.foo.bar"
            }).Should().BeTrue();
        }
Example #3
0
        public void Matches_WithLevel_ShouldMatchLevel()
        {
            // Arrange
            var filter = new SimpleLogFilter(level: Option.Some(LogLevel.Warn));

            // Act + Assert
            filter.Level.Should().Be(Option.Some(LogLevel.Warn));
            filter.Logger.Should().Be(Option.None <string>());
            filter.Matches(new LogEntry {
                Level = LogLevel.Warn
            }).Should().BeTrue();
            filter.Matches(new LogEntry {
                Level = LogLevel.Error
            }).Should().BeTrue();
            filter.Matches(new LogEntry {
                Level = LogLevel.Info
            }).Should().BeFalse();
        }