@@ -51,12 +51,25 @@ namespace RabbitMQ.Client.Unit {
51
51
[ TestFixture ]
52
52
public class TestConcurrentAccessWithSharedConnection : IntegrationFixture {
53
53
54
+ protected const int threads = 32 ;
55
+ protected CountdownEvent latch ;
56
+
57
+ [ SetUp ]
58
+ public void Init ( )
59
+ {
60
+ latch = new CountdownEvent ( threads ) ;
61
+ }
62
+
63
+ [ TearDown ]
64
+ public void Dispose ( )
65
+ {
66
+ latch . Dispose ( ) ;
67
+ }
68
+
54
69
[ Test ]
55
70
public void TestConcurrentChannelOpenWithPublishing ( )
56
71
{
57
- var n = 32 ;
58
- var latch = new CountdownEvent ( n ) ;
59
- foreach ( var i in Enumerable . Range ( 0 , n ) )
72
+ foreach ( var i in Enumerable . Range ( 0 , threads ) )
60
73
{
61
74
var t = new Thread ( ( ) => {
62
75
// publishing on a shared channel is not supported
@@ -77,12 +90,12 @@ public void TestConcurrentChannelOpenWithPublishing()
77
90
Assert . IsTrue ( latch . Wait ( TimeSpan . FromSeconds ( 90 ) ) ) ;
78
91
}
79
92
93
+ // note: refactoring this further to use an Action causes .NET Core 1.x
94
+ // to segfault on OS X for no obvious reason
80
95
[ Test ]
81
96
public void TestConcurrentChannelOpenCloseLoop ( )
82
97
{
83
- var n = 32 ;
84
- var latch = new CountdownEvent ( n ) ;
85
- foreach ( var i in Enumerable . Range ( 0 , n ) )
98
+ foreach ( var i in Enumerable . Range ( 0 , threads ) )
86
99
{
87
100
var t = new Thread ( ( ) => {
88
101
foreach ( var j in Enumerable . Range ( 0 , 100 ) )
0 commit comments