@@ -44,7 +44,6 @@ namespace Test.Integration
44
44
{
45
45
public class TestPublisherConfirms : IntegrationFixture
46
46
{
47
- private const string QueueName = "Test.Integration.TestPublisherConfirms" ;
48
47
private readonly byte [ ] _body = new byte [ 4096 ] ;
49
48
50
49
public TestPublisherConfirms ( ITestOutputHelper output ) : base ( output )
@@ -79,10 +78,10 @@ public Task TestWaitForConfirmsWithTimeout()
79
78
}
80
79
81
80
[ Fact ]
82
- public Task TestWaitForConfirmsWithTimeoutAsync_MightThrowTaskCanceledException ( )
81
+ public async Task TestWaitForConfirmsWithTimeoutAsync_MightThrowTaskCanceledException ( )
83
82
{
84
83
bool waitResult = false ;
85
- bool sawTaskCanceled = false ;
84
+ bool sawException = false ;
86
85
87
86
Task t = TestWaitForConfirmsAsync ( 10000 , async ( ch ) =>
88
87
{
@@ -92,19 +91,19 @@ public Task TestWaitForConfirmsWithTimeoutAsync_MightThrowTaskCanceledException(
92
91
{
93
92
waitResult = await ch . WaitForConfirmsAsync ( cts . Token ) ;
94
93
}
95
- catch ( TaskCanceledException )
94
+ catch
96
95
{
97
- sawTaskCanceled = true ;
96
+ sawException = true ;
98
97
}
99
98
}
100
99
} ) ;
101
100
102
- if ( waitResult == false && sawTaskCanceled == false )
101
+ await t ;
102
+
103
+ if ( waitResult == false && sawException == false )
103
104
{
104
- Assert . Fail ( "test failed, both waitResult and sawTaskCanceled are still false" ) ;
105
+ Assert . Fail ( "test failed, both waitResult and sawException are still false" ) ;
105
106
}
106
-
107
- return t ;
108
107
}
109
108
110
109
[ Fact ]
@@ -128,10 +127,11 @@ public Task TestWaitForConfirmsWithTimeoutAsync_MessageNacked_WaitingHasTimedout
128
127
[ Fact ]
129
128
public async Task TestWaitForConfirmsWithEventsAsync ( )
130
129
{
130
+ string queueName = string . Format ( "{0}:{1}" , _testDisplayName , Guid . NewGuid ( ) ) ;
131
131
using ( IChannel ch = _conn . CreateChannel ( ) )
132
132
{
133
133
await ch . ConfirmSelectAsync ( ) ;
134
- await ch . QueueDeclareAsync ( queue : QueueName , passive : false , durable : false , exclusive : false , autoDelete : false , arguments : null ) ;
134
+ await ch . QueueDeclareAsync ( queue : queueName , passive : false , durable : false , exclusive : false , autoDelete : false , arguments : null ) ;
135
135
136
136
int n = 200 ;
137
137
// number of event handler invocations
@@ -146,7 +146,7 @@ public async Task TestWaitForConfirmsWithEventsAsync()
146
146
{
147
147
for ( int i = 0 ; i < n ; i ++ )
148
148
{
149
- await ch . BasicPublishAsync ( "" , QueueName , _encoding . GetBytes ( "msg" ) ) ;
149
+ await ch . BasicPublishAsync ( "" , queueName , _encoding . GetBytes ( "msg" ) ) ;
150
150
}
151
151
152
152
await ch . WaitForConfirmsAsync ( ) ;
@@ -159,23 +159,24 @@ public async Task TestWaitForConfirmsWithEventsAsync()
159
159
}
160
160
finally
161
161
{
162
- await ch . QueueDeleteAsync ( queue : QueueName , ifUnused : false , ifEmpty : false ) ;
162
+ await ch . QueueDeleteAsync ( queue : queueName , ifUnused : false , ifEmpty : false ) ;
163
163
}
164
164
}
165
165
}
166
166
167
167
private async Task TestWaitForConfirmsAsync ( int numberOfMessagesToPublish , Func < IChannel , Task > fn )
168
168
{
169
+ string queueName = string . Format ( "{0}:{1}" , _testDisplayName , Guid . NewGuid ( ) ) ;
169
170
using ( IChannel ch = _conn . CreateChannel ( ) )
170
171
{
171
172
var props = new BasicProperties { Persistent = true } ;
172
173
173
174
await ch . ConfirmSelectAsync ( ) ;
174
- await ch . QueueDeclareAsync ( queue : QueueName , passive : false , durable : false , exclusive : false , autoDelete : false , arguments : null ) ;
175
+ await ch . QueueDeclareAsync ( queue : queueName , passive : false , durable : false , exclusive : false , autoDelete : false , arguments : null ) ;
175
176
176
177
for ( int i = 0 ; i < numberOfMessagesToPublish ; i ++ )
177
178
{
178
- await ch . BasicPublishAsync ( exchange : "" , routingKey : QueueName , body : _body , mandatory : true , basicProperties : props ) ;
179
+ await ch . BasicPublishAsync ( exchange : string . Empty , routingKey : queueName , body : _body , mandatory : true , basicProperties : props ) ;
179
180
}
180
181
181
182
try
@@ -184,7 +185,7 @@ private async Task TestWaitForConfirmsAsync(int numberOfMessagesToPublish, Func<
184
185
}
185
186
finally
186
187
{
187
- await ch . QueueDeleteAsync ( queue : QueueName , ifUnused : false , ifEmpty : false ) ;
188
+ await ch . QueueDeleteAsync ( queue : queueName , ifUnused : false , ifEmpty : false ) ;
188
189
}
189
190
}
190
191
}
0 commit comments