@@ -105,12 +105,7 @@ public async Task TestMultithreadFloodPublishing()
105
105
var tcs = new TaskCompletionSource < bool > ( ) ;
106
106
consumer . Received += ( o , a ) =>
107
107
{
108
- Console . WriteLine ( "Receiving" ) ;
109
108
var receivedMessage = Encoding . UTF8 . GetString ( a . Body . ToArray ( ) ) ;
110
- if ( ! receivedMessage . Equals ( message ) )
111
- {
112
- Debugger . Break ( ) ;
113
- }
114
109
Assert . AreEqual ( message , receivedMessage ) ;
115
110
116
111
var result = Interlocked . Increment ( ref receivedCount ) ;
@@ -125,29 +120,17 @@ public async Task TestMultithreadFloodPublishing()
125
120
126
121
using ( var timeoutRegistration = cts . Token . Register ( ( ) => tcs . SetCanceled ( ) ) )
127
122
{
128
- StartFlood ( m , q . QueueName , bp , sendBody , publishCount ) ;
123
+ for ( int i = 0 ; i < publishCount ; i ++ )
124
+ {
125
+ m . BasicPublish ( string . Empty , q . QueueName , bp , sendBody ) ;
126
+ }
129
127
130
- //var tasks = new List<Task>();
131
- //for (int i = 0; i < threadCount; i++)
132
- //{
133
- // tasks.Add(Task.Run(() => StartFlood(m, q.QueueName, bp, sendBody, publishCount)));
134
- //}
135
- //await Task.WhenAll(tasks);
136
128
await tcs . Task ;
137
129
}
138
130
m . BasicCancel ( tag ) ;
139
131
await tcs . Task ;
140
132
Assert . AreEqual ( threadCount * publishCount , receivedCount ) ;
141
133
}
142
-
143
-
144
- void StartFlood ( IModel model , string queue , IBasicProperties properties , byte [ ] body , int count )
145
- {
146
- for ( int i = 0 ; i < count ; i ++ )
147
- {
148
- model . BasicPublish ( string . Empty , queue , properties , body ) ;
149
- }
150
- }
151
134
}
152
135
}
153
136
}
0 commit comments