@@ -49,7 +49,7 @@ public void Should_Return_Same_Template_String_If_No_Args_Provided()
49
49
public void Should_Format_Entire_String_If_Only_Numeric_Formatting_Is_Used ( )
50
50
{
51
51
/* Setup */
52
- const string originalTemplate = "Look at this,a {0} formatted string!" ;
52
+ const string originalTemplate = "Look at this, a {0} formatted string!" ;
53
53
var args = new object [ ] { "nicely " } ;
54
54
var expected = string . Format ( originalTemplate , args ) ;
55
55
@@ -60,5 +60,34 @@ public void Should_Format_Entire_String_If_Only_Numeric_Formatting_Is_Used()
60
60
Assert . That ( result , Is . True ) ;
61
61
Assert . That ( _resultTemplate , Is . EqualTo ( expected ) ) ;
62
62
}
63
+
64
+ public class When_Calling_GetIndecesOfNumericalFormatting : SerilogPreformatterTests
65
+ {
66
+ [ Test ]
67
+ public void Should_Return_Empty_List_If_Template_String_Is_Not_Formatted ( )
68
+ {
69
+ /* Setup */
70
+ const string originalTemplate = "This is a template without any args" ;
71
+
72
+ /* Test */
73
+ var result = _preformatter . GetIndecesOfNumericalFormatting ( originalTemplate ) ;
74
+
75
+ /* Assert */
76
+ Assert . That ( result , Is . Empty ) ;
77
+ }
78
+
79
+ [ TestCase ( "A pure numeric string with {0} and {1}." , new [ ] { 0 , 1 } ) ]
80
+ [ TestCase ( "A pure {@Serilog} formatted string" , new int [ 0 ] ) ]
81
+ [ TestCase ( "A mixed string with both {@Seri} and numeric {1} formatting" , new [ ] { 1 } ) ]
82
+ public void Should_Return_Expected_Indeces ( string originalTemplate , int [ ] expectedResult )
83
+ {
84
+ /* Setup */
85
+ /* Test */
86
+ var result = _preformatter . GetIndecesOfNumericalFormatting ( originalTemplate ) ;
87
+
88
+ /* Assert */
89
+ Assert . That ( result , Is . EquivalentTo ( expectedResult ) ) ;
90
+ }
91
+ }
63
92
}
64
93
}
0 commit comments