예제 #1
0
        public void FloatPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("FloatProperty", "-7.4");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Different representation of the same number
            evaluator = new GreaterOrEqualsEvaluator("FloatProperty", "-74E-1");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("FloatProperty", "74E-1");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("FloatProperty", "-7.5");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Zero as special case
            evaluator = new GreaterOrEqualsEvaluator("FloatProperty", "0");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Out of range
            evaluator = new GreaterOrEqualsEvaluator("FloatProperty", "-2.347E43");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #2
0
        public void DoublePropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("DoubleProperty", "-2.347E43");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Different representation of the same number
            evaluator = new GreaterOrEqualsEvaluator("DoubleProperty", "-234.7E41");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("DoubleProperty", "2.347E43");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("DoubleProperty", "-2.3471E43");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Zero as special case
            evaluator = new GreaterOrEqualsEvaluator("DoubleProperty", "0");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("DoubleProperty", "not a double value");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #3
0
        public void DateTimeOffsetPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("DateTimeOffsetProperty", "2015-05-29T10:39:17.485Z");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Alternative representation of the same value
            evaluator = new GreaterOrEqualsEvaluator("DateTimeOffsetProperty", "2015-05-29T10:39:17.485+00:00");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value in different time zone
            evaluator = new GreaterOrEqualsEvaluator("DateTimeOffsetProperty", "2015-05-29T10:39:17.485+00:01");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("DateTimeOffsetProperty", "2015-05-29T10:39:17Z");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("DateTimeOffsetProperty", "2015-05-29T10:39:18Z");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("DateTimeOffsetProperty", "not a DateTimeOffset value");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #4
0
        public void MessagePropertyGreaterOrEquals()
        {
            var evaluator = new GreaterOrEqualsEvaluator("Message", "Test event with many properties of different types");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("Message", "aaa");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("Message", "zzz");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #5
0
        public void BoolPropertyGreaterOrEquals()
        {
            // Bool properties do not work with greater-or-equals operator, so no matter what RHS value we use the evaluation should always be false.
            var evaluator = new GreaterOrEqualsEvaluator("BoolProperty", "true");

            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("BoolProperty", "false");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("BoolProperty", "not a bool value");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #6
0
        public void GuidPropertyGreaterOrEquals()
        {
            // GUID properties do not work with greater-or-equals operator, so no matter what RHS value we use the evaluation should always be false.
            var evaluator = new GreaterOrEqualsEvaluator("GuidProperty", "8DCE9920-E985-4B63-8ECE-A22160421FA3");

            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("GuidProperty", "{8DCE9920-E985-4B63-8ECE-A22160421FA3}");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("GuidProperty", "67FED6E7-23C5-45DB-96DE-F763E169C922");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("GuidProperty", "not a GUID value");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #7
0
        public void IdPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("EventId", "1234");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("EventId", "-34");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("EventId", "1235");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("EventId", "notIntegerValue");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #8
0
        public void IntPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("IntProperty", "-65000");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("IntProperty", "65000");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("IntProperty", "-65001");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("IntProperty", "not an int value");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #9
0
        public void StringPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("StringProperty", "Ala ma kota");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Comparison should be case-insensitive
            evaluator = new GreaterOrEqualsEvaluator("StringProperty", "Ala MA kota");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Greater value
            evaluator = new GreaterOrEqualsEvaluator("StringProperty", "Kota ma Ala");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("StringProperty", "AAla");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
        public void EnumPropertyEquality()
        {
            var evaluator = new GreaterOrEqualsEvaluator("EnumProperty", "Warning");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("EnumProperty", "3");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("EnumProperty", "Informational");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("EnumProperty", "4");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("EnumProperty", "Error");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("EnumProperty", "2");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #11
0
        public void DateTimePropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("DateTimeProperty", "2015-03-30T09:15:00");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Alternative representation of the same value
            evaluator = new GreaterOrEqualsEvaluator("DateTimeProperty", "2015-03-30 09:15:00");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("DateTimeProperty", "2015-03-30T09:15:01");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("DateTimeProperty", "2015-03-30T09:14:59");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("DateTimeProperty", "not a DateTime value");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #12
0
        public void TimestampPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("Timestamp", "2015-05-29T10:45:00.537Z");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Alternative representation of the same timestamp
            evaluator = new GreaterOrEqualsEvaluator("Timestamp", "2015-05-29T10:45:00.537+00:00");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("Timestamp", "2015-05-29T10:50:00Z");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("Timestamp", "2015-05-29T10:45:00Z");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("Timestamp", "not a timestamp value");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #13
0
        public void LongPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("LongProperty", "-5000000000");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("LongProperty", "5000000000");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("LongProperty", "-5000000001");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Zero as special case
            evaluator = new GreaterOrEqualsEvaluator("LongProperty", "0");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            evaluator = new GreaterOrEqualsEvaluator("LongProperty", "not a long value");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #14
0
        public void PartialTimestampTest()
        {
            DateTime timestamp = DateTime.Now;

            if (timestamp.Hour == 0 && timestamp.Minute <= 5)
            {
                // The range of timestamps checked is about 4 minutes, so the test will fail if it is shortly past midnight.
                // In that case we simply do not perform the test, to avoid false negatives.

                // The test is using current machine time and cannot produce a result within 5 minutes past midnight local time;
                return;
            }

            string timestampString = timestamp.ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture);
            var    evaluator       = new GreaterOrEqualsEvaluator("TwoMinutesAgoProperty", timestampString);

            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            timestamp       = DateTime.Now - TimeSpan.FromMinutes(4);
            timestampString = timestamp.ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture);
            evaluator       = new GreaterOrEqualsEvaluator("TwoMinutesAgoProperty", timestampString);
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #15
0
        public void UintPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("UintProperty", "80000");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("UintProperty", "80001");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("UintProperty", "70500");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Zero as special case
            evaluator = new GreaterOrEqualsEvaluator("UintProperty", "0");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Out of range for uint
            evaluator = new GreaterOrEqualsEvaluator("UintProperty", "-80000");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #16
0
        public void UshortPropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("UshortProperty", "18200");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("UshortProperty", "18201");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("UshortProperty", "18199");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Zero as special case
            evaluator = new GreaterOrEqualsEvaluator("UshortProperty", "0");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Out of range
            evaluator = new GreaterOrEqualsEvaluator("UshortProperty", "-18200");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #17
0
        public void BytePropertyGreaterOrEquals()
        {
            // Same value
            var evaluator = new GreaterOrEqualsEvaluator("ByteProperty", "7");

            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Higher value
            evaluator = new GreaterOrEqualsEvaluator("ByteProperty", "8");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Lower value
            evaluator = new GreaterOrEqualsEvaluator("ByteProperty", "3");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Zero as special case
            evaluator = new GreaterOrEqualsEvaluator("ByteProperty", "0");
            Assert.True(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));

            // Out of range for byte
            evaluator = new GreaterOrEqualsEvaluator("ByteProperty", "-3");
            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }
예제 #18
0
        public void MissingPropertyGreaterOrEquals()
        {
            var evaluator = new GreaterOrEqualsEvaluator("InvalidPropertyName", "somevalue");

            Assert.False(evaluator.Evaluate(FilteringTestData.ManyPropertiesEvent));
        }