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."); }
public void Validate_MessageIsNull_ReturnFalse() { var notificationFiltersValidator = new NotificationFiltersValidator(); var message = new FieldsContainer(); notificationFiltersValidator.SetFilters(_filters); notificationFiltersValidator.Validate(message).Should().BeFalse(); }
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); }
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(); }
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(); }