@@ -13,6 +13,12 @@ namespace NHibernate.Test.NHSpecificTest.GH1391
13
13
public class Fixture
14
14
{
15
15
private readonly Random _random = new Random ( ) ;
16
+
17
+ [ OneTimeSetUp ]
18
+ public void Test ( )
19
+ {
20
+ SessionIdLoggingContext . SessionId = null ;
21
+ }
16
22
17
23
[ Test ]
18
24
public void Concurrent ( )
@@ -56,11 +62,11 @@ async Task RunAsync(bool enabled)
56
62
public void Enabled ( )
57
63
{
58
64
var guid = Guid . NewGuid ( ) ;
59
- using ( new SessionIdLoggingContext ( guid ) )
65
+ using ( SessionIdLoggingContext . CreateOrNull ( guid ) )
60
66
{
61
67
Assert . That ( SessionIdLoggingContext . SessionId , Is . EqualTo ( guid ) ) ;
62
68
var guid2 = Guid . NewGuid ( ) ;
63
- using ( new SessionIdLoggingContext ( guid2 ) )
69
+ using ( SessionIdLoggingContext . CreateOrNull ( guid2 ) )
64
70
{
65
71
Assert . That ( SessionIdLoggingContext . SessionId , Is . EqualTo ( guid2 ) ) ;
66
72
}
@@ -73,14 +79,14 @@ public void Enabled()
73
79
public async Task EnabledAsync ( )
74
80
{
75
81
var guid = Guid . NewGuid ( ) ;
76
- using ( new SessionIdLoggingContext ( guid ) )
82
+ using ( SessionIdLoggingContext . CreateOrNull ( guid ) )
77
83
{
78
84
Assert . That ( SessionIdLoggingContext . SessionId , Is . EqualTo ( guid ) ) ;
79
85
await Task . Delay ( 1 ) . ConfigureAwait ( false ) ;
80
86
Assert . That ( SessionIdLoggingContext . SessionId , Is . EqualTo ( guid ) ) ;
81
87
82
88
var guid2 = Guid . NewGuid ( ) ;
83
- using ( new SessionIdLoggingContext ( guid2 ) )
89
+ using ( SessionIdLoggingContext . CreateOrNull ( guid2 ) )
84
90
{
85
91
Assert . That ( SessionIdLoggingContext . SessionId , Is . EqualTo ( guid2 ) ) ;
86
92
await Task . Delay ( 1 ) . ConfigureAwait ( false ) ;
@@ -95,10 +101,10 @@ public async Task EnabledAsync()
95
101
public void Disabled ( )
96
102
{
97
103
var guid = Guid . Empty ;
98
- using ( new SessionIdLoggingContext ( guid ) )
104
+ using ( SessionIdLoggingContext . CreateOrNull ( guid ) )
99
105
{
100
106
Assert . That ( SessionIdLoggingContext . SessionId , Is . Null ) ;
101
- using ( new SessionIdLoggingContext ( guid ) )
107
+ using ( SessionIdLoggingContext . CreateOrNull ( guid ) )
102
108
{
103
109
Assert . That ( SessionIdLoggingContext . SessionId , Is . Null ) ;
104
110
}
@@ -111,13 +117,13 @@ public void Disabled()
111
117
public async Task DisabledAsync ( )
112
118
{
113
119
var guid = Guid . Empty ;
114
- using ( new SessionIdLoggingContext ( guid ) )
120
+ using ( SessionIdLoggingContext . CreateOrNull ( guid ) )
115
121
{
116
122
Assert . That ( SessionIdLoggingContext . SessionId , Is . Null ) ;
117
123
await Task . Delay ( 1 ) . ConfigureAwait ( false ) ;
118
124
Assert . That ( SessionIdLoggingContext . SessionId , Is . Null ) ;
119
125
120
- using ( new SessionIdLoggingContext ( guid ) )
126
+ using ( SessionIdLoggingContext . CreateOrNull ( guid ) )
121
127
{
122
128
Assert . That ( SessionIdLoggingContext . SessionId , Is . Null ) ;
123
129
await Task . Delay ( 1 ) . ConfigureAwait ( false ) ;
0 commit comments