@@ -4,15 +4,8 @@ namespace Sentry.Tests;
44
55public class TraceIgnoreStatusCodeTransactionProcessorTests
66{
7- private static SentryOptions OptionsWithIgnoredCodes ( params HttpStatusCodeRange [ ] ranges )
8- {
9- var options = new SentryOptions ( ) ;
10- foreach ( var range in ranges )
11- {
12- options . TraceIgnoreStatusCodes . Add ( range ) ;
13- }
14- return options ;
15- }
7+ private static SentryOptions OptionsWithIgnoredCodes ( params HttpStatusCodeRange [ ] ranges ) =>
8+ new ( ) { TraceIgnoreStatusCodes = [ .. ranges ] } ;
169
1710 private static SentryTransaction TransactionWithStatusCode ( int statusCode )
1811 {
@@ -21,11 +14,55 @@ private static SentryTransaction TransactionWithStatusCode(int statusCode)
2114 return transaction ;
2215 }
2316
17+ [ Theory ]
18+ [ InlineData ( 301 ) ]
19+ [ InlineData ( 305 ) ]
20+ [ InlineData ( 307 ) ]
21+ [ InlineData ( 308 ) ]
22+ [ InlineData ( 399 ) ]
23+ [ InlineData ( 401 ) ]
24+ [ InlineData ( 403 ) ]
25+ [ InlineData ( 404 ) ]
26+ public void Process_DefaultOptions_DropsIgnoredStatusCode ( int statusCode )
27+ {
28+ // Arrange
29+ var processor = new TraceIgnoreStatusCodeTransactionProcessor ( new SentryOptions ( ) ) ;
30+ var transaction = TransactionWithStatusCode ( statusCode ) ;
31+
32+ // Act
33+ var result = processor . Process ( transaction ) ;
34+
35+ // Assert
36+ result . Should ( ) . BeNull ( ) ;
37+ }
38+
39+ [ Theory ]
40+ [ InlineData ( 200 ) ]
41+ [ InlineData ( 300 ) ]
42+ [ InlineData ( 302 ) ]
43+ [ InlineData ( 303 ) ]
44+ [ InlineData ( 304 ) ]
45+ [ InlineData ( 400 ) ]
46+ [ InlineData ( 405 ) ]
47+ [ InlineData ( 500 ) ]
48+ public void Process_DefaultOptions_ReturnsTransaction ( int statusCode )
49+ {
50+ // Arrange
51+ var processor = new TraceIgnoreStatusCodeTransactionProcessor ( new SentryOptions ( ) ) ;
52+ var transaction = TransactionWithStatusCode ( statusCode ) ;
53+
54+ // Act
55+ var result = processor . Process ( transaction ) ;
56+
57+ // Assert
58+ result . Should ( ) . BeSameAs ( transaction ) ;
59+ }
60+
2461 [ Fact ]
2562 public void Process_EmptyIgnoreList_ReturnsTransaction ( )
2663 {
2764 // Arrange
28- var options = new SentryOptions ( ) ;
65+ var options = OptionsWithIgnoredCodes ( ) ;
2966 var processor = new TraceIgnoreStatusCodeTransactionProcessor ( options ) ;
3067 var transaction = TransactionWithStatusCode ( 404 ) ;
3168
0 commit comments