@@ -2,6 +2,45 @@ namespace Sentry.Tests.Internals;
22
33public class UnsampledTransactionTests
44{
5+ [ Fact ]
6+ public void Dispose_Unfinished_Finishes ( )
7+ {
8+ // Arrange
9+ var hub = Substitute . For < IHub > ( ) ;
10+ ITransactionContext context = new TransactionContext ( "TestTransaction" , "TestOperation" ,
11+ new SentryTraceHeader ( SentryId . Create ( ) , SpanId . Create ( ) , false )
12+ ) ;
13+ var transaction = new UnsampledTransaction ( hub , context ) ;
14+
15+ // Act
16+ transaction . Dispose ( ) ;
17+
18+ // Assert
19+ transaction . IsFinished . Should ( ) . BeTrue ( ) ;
20+ hub . Received ( 1 ) . ConfigureScope ( Arg . Any < Action < Scope , UnsampledTransaction > > ( ) ,
21+ Arg . Is < UnsampledTransaction > ( t => ReferenceEquals ( t , transaction ) ) ) ;
22+ }
23+
24+ [ Fact ]
25+ public void Dispose_Finished_DoesNothing ( )
26+ {
27+ // Arrange
28+ var hub = Substitute . For < IHub > ( ) ;
29+ ITransactionContext context = new TransactionContext ( "TestTransaction" , "TestOperation" ,
30+ new SentryTraceHeader ( SentryId . Create ( ) , SpanId . Create ( ) , false )
31+ ) ;
32+ var transaction = new UnsampledTransaction ( hub , context ) ;
33+ transaction . Finish ( ) ;
34+
35+ // Act
36+ transaction . Dispose ( ) ;
37+
38+ // Assert
39+ transaction . IsFinished . Should ( ) . BeTrue ( ) ;
40+ hub . Received ( 1 ) . ConfigureScope ( Arg . Any < Action < Scope , UnsampledTransaction > > ( ) ,
41+ Arg . Is < UnsampledTransaction > ( t => ReferenceEquals ( t , transaction ) ) ) ;
42+ }
43+
544 [ Fact ]
645 public void StartChild_CreatesSpan_IsTrackedByParent ( )
746 {
0 commit comments