File tree Expand file tree Collapse file tree
DebugProbe.AspNetCore.Tests/Configuration
DebugProbe.AspNetCore/Options Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,4 +87,21 @@ public void MaxEntries_negative_throws_InvalidOperationException()
8787
8888 Assert . Contains ( "MaxEntries" , exception . Message ) ;
8989 }
90+
91+ [ Fact ]
92+ public void MaxBodyCaptureSizeKb_negative_throws_ArgumentOutOfRangeException ( )
93+ {
94+ var options = new DebugProbeOptions ( ) ;
95+
96+ Assert . Throws < ArgumentOutOfRangeException > ( ( ) => options . MaxBodyCaptureSizeKb = - 1 ) ;
97+ }
98+
99+ [ Fact ]
100+ public void MaxBodyCaptureSizeKb_zero_is_valid ( )
101+ {
102+ var options = new DebugProbeOptions ( ) ;
103+ options . MaxBodyCaptureSizeKb = 0 ;
104+
105+ Assert . Equal ( 0 , options . MaxBodyCaptureSizeKb ) ;
106+ }
90107}
Original file line number Diff line number Diff line change 1- namespace DebugProbe . AspNetCore . Options ;
1+ namespace DebugProbe . AspNetCore . Options ;
22
33/// <summary>
44/// Configuration options for DebugProbe.
@@ -13,7 +13,18 @@ public class DebugProbeOptions
1313 /// <summary>
1414 /// Maximum captured request or response body size in kilobytes.
1515 /// </summary>
16- public int MaxBodyCaptureSizeKb { get ; set ; } = 32 ;
16+ private int _maxBodyCaptureSizeKb = 32 ;
17+ public int MaxBodyCaptureSizeKb
18+ {
19+ get => _maxBodyCaptureSizeKb ;
20+ set
21+ {
22+ if ( value < 0 )
23+ throw new ArgumentOutOfRangeException ( nameof ( MaxBodyCaptureSizeKb ) ,
24+ "MaxBodyCaptureSizeKb must be 0 or greater. Use 0 to disable body capture." ) ;
25+ _maxBodyCaptureSizeKb = value ;
26+ }
27+ }
1728
1829 internal int MaxBodyCaptureSizeBytes => MaxBodyCaptureSizeKb * 1024 ;
1930
You can’t perform that action at this time.
0 commit comments