Beispiel #1
0
        public void Validate_MessageMatchTheFiltersForLessOrEqualPatternWithWrongData_ReturnException()
        {
            var notificationFiltersValidator = new NotificationFiltersValidator();
            var message = new FieldsContainer();

            message.Add("Message", "text110");

            var filters = new Filters
            {
                FilterParams = new[]
                {
                    new FilterInfo
                    {
                        ColumnName           = "Message",
                        Patterns             = new[] { "110" },
                        MatchPatternOperator = "<="
                    }
                }
            };

            notificationFiltersValidator.SetFilters(filters);

            Action result = () => notificationFiltersValidator.Validate(message);

            result.Should().Throw <FormatException>().WithMessage("Nieprawidłowy format ciągu wejściowego.");
        }
Beispiel #2
0
        public void Validate_MessageIsNull_ReturnFalse()
        {
            var notificationFiltersValidator = new NotificationFiltersValidator();
            var message = new FieldsContainer();

            notificationFiltersValidator.SetFilters(_filters);

            notificationFiltersValidator.Validate(message).Should().BeFalse();
        }
Beispiel #3
0
        public void ToString_WithFilters_ReturnString()
        {
            var notificationFiltersValidator = new NotificationFiltersValidator();

            const string expected = "Id: 0, \r\nFilters: 1: {\r\n	ColumnName: Message, Patterns: [Exception,Critical], MatchPatternOperator: \r\n}\r\n";

            notificationFiltersValidator.SetFilters(_filters);

            notificationFiltersValidator.ToString().Should().Match(expected);
        }
Beispiel #4
0
        public void Validate_MessageMatchTheFiltersForDefaultPattern_ReturnTrue()
        {
            var notificationFiltersValidator = new NotificationFiltersValidator();
            var message = new FieldsContainer();

            message.Add("Message", "Critical");

            notificationFiltersValidator.SetFilters(_filters);

            notificationFiltersValidator.Validate(message).Should().BeTrue();
        }
Beispiel #5
0
        public void Validate_MessageMatchTheFiltersForLessOrEqualPattern_ReturnTrue()
        {
            var notificationFiltersValidator = new NotificationFiltersValidator();
            var message = new FieldsContainer();

            message.Add("Message", "110");

            var filters = new Filters
            {
                FilterParams = new[]
                {
                    new FilterInfo
                    {
                        ColumnName           = "Message",
                        Patterns             = new[] { "110" },
                        MatchPatternOperator = "<="
                    }
                }
            };

            notificationFiltersValidator.SetFilters(filters);

            notificationFiltersValidator.Validate(message).Should().BeTrue();
        }