Example #1
0
        public void ReturnFalseIfNoChildFilters()
        {
            var e = new SystemEvent();
            var extendedProperties = new FakeExtendedProperties { { "property", "Level" }, { "value", "Warning" } };
            var filter = new NotFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>());

            Assert.False(Filter.Compile(filter).Invoke(e));
        }
Example #2
0
        public void ReturnFalsefSingleChildFilterTrue()
        {
            var e = new SystemEvent { Level = SystemEventLevel.Warning };
            var extendedProperties = new FakeExtendedProperties { { "property", "Level" }, { "value", "Warning" } };
            var filter = new NotFilter(new FakeExtendedProperties(), new[] { new EqualFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()) });

            Assert.False(Filter.Compile(filter).Invoke(e));
        }
Example #3
0
        public void ReturnTrueIfAnyChildFilterFalse()
        {
            var e = new SystemEvent { Level = SystemEventLevel.Error, ProcessId = 123, Thread = "Unknown" };
            var filter = new NotFilter(
                             new FakeExtendedProperties(),
                             new[]
                                 {
                                     new EqualFilter(new FakeExtendedProperties { { "property", "ProcessId" }, { "value", "1234" } }, Enumerable.Empty<ICreateFilterExpressions>()),
                                     new EqualFilter(new FakeExtendedProperties { { "property", "Thread" }, { "value", "Unknown" } }, Enumerable.Empty<ICreateFilterExpressions>()),
                                     new EqualFilter(new FakeExtendedProperties { { "property", "Level" }, { "value", "Error" } }, Enumerable.Empty<ICreateFilterExpressions>())
                                 });

            Assert.True(Filter.Compile(filter).Invoke(e));
        }
Example #4
0
        private static ICreateFilterExpressions CreateTextFilter(FilterDefinition definition)
        {
            FilterActivator activator;

            if (!FilterActivators.TryGetValue(definition.FriendlyName, out activator))
            {
                throw new ArgumentException(String.Format(Localization.FilterTypeNotKnown, definition.FriendlyName), "definition");
            }

            var expressionBuilder = activator.Invoke(definition);

            if (definition.Negate)
            {
                expressionBuilder = new NotFilter(FilterDefinition.Empty, new[] { expressionBuilder });
            }

            return(expressionBuilder);
        }
        private static ICreateFilterExpressions CreateTextFilter(FilterDefinition definition)
        {
            FilterActivator activator;
            if (!FilterActivators.TryGetValue(definition.FriendlyName, out activator))
                throw new ArgumentException(String.Format(Localization.FilterTypeNotKnown, definition.FriendlyName), "definition");

            var expressionBuilder = activator.Invoke(definition);
            if (definition.Negate)
                expressionBuilder = new NotFilter(FilterDefinition.Empty, new[] { expressionBuilder });

            return expressionBuilder;
        }
Example #6
0
        public void AlwaysCompositeExpression()
        {
            var filter = new NotFilter(new FakeExtendedProperties(), Enumerable.Empty<ICreateFilterExpressions>());

            Assert.True(filter.CompositeExpression);
        }