@@ -318,7 +318,7 @@ public void Parse_Multiline_String_As_A_Single_Line_With_Regex_Options_Specified
318318 const string logs = @"2023-02-21 04:15:26.349 Parsing output [221206045974]: [XXXX=9999]Got error: Dimension error at argument [0]
319319 Node: X
320320 Token: Y
321- Context: Sample text
321+ Context: Sample text
322322 Second line
323323 (Third one)" ;
324324
@@ -331,7 +331,48 @@ Second line
331331 var relevantMultilineObject = multilineResult [ 1 ] . Value ;
332332 Assert . NotNull ( relevantMultilineObject ) ;
333333
334- Assert . Contains ( "(Third one)" , ( string ) relevantMultilineObject ) ;
334+ Assert . Contains ( "(Third one)" , ( string ) relevantMultilineObject ) ;
335+ }
336+
337+ [ Fact ]
338+ public void Load_Custom_Patterns_From_Stream_And_Parse_With_Regex_Options_Specified ( )
339+ {
340+ // Arrange
341+ const RegexOptions options = RegexOptions . Singleline ;
342+ const string zipcode = "122001" ;
343+ const string email = "[email protected] " ; 344+
345+ var sut = new Grok ( "%{ZIPCODE:zipcode}:%{EMAILADDRESS:email}" , ReadCustomFile ( ) , options ) ;
346+
347+ // Act
348+ GrokResult grokResult = sut . Parse ( $ "{ zipcode } :{ email } ") ;
349+
350+ // Assert
351+ Assert . Equal ( zipcode , grokResult [ 0 ] . Value ) ;
352+ Assert . Equal ( email , grokResult [ 1 ] . Value ) ;
353+ }
354+
355+ [ Fact ]
356+ public void Load_Custom_Patterns_And_Parse_With_Regex_Options_Specified ( )
357+ {
358+ // Arrange
359+ const RegexOptions options = RegexOptions . Singleline ;
360+ const string zipcode = "122001" ;
361+ var customPatterns = new Dictionary < string , string >
362+ {
363+ { "ZIPCODE" , "[1-9]{1}[0-9]{2}\\ s{0,1}[0-9]{3}" } ,
364+ { "FLOAT" , "[+-]?([0-9]*[.,]}?[0-9]+)" }
365+ } ;
366+ const string email = "[email protected] " ; 367+
368+ var sut = new Grok ( "%{ZIPCODE:zipcode}:%{EMAILADDRESS:email}" , customPatterns , options ) ;
369+
370+ // Act
371+ GrokResult grokResult = sut . Parse ( $ "{ zipcode } :{ email } ") ;
372+
373+ // Assert
374+ Assert . Equal ( zipcode , grokResult [ 0 ] . Value ) ;
375+ Assert . Equal ( email , grokResult [ 1 ] . Value ) ;
335376 }
336377
337378 [ Fact ]
0 commit comments