@@ -29,10 +29,9 @@ public MaybeSourceSpec(ITestOutputHelper output) : base(output)
29
29
}
30
30
31
31
[ Fact ( DisplayName = "The Maybe Source must complete materialized promise with None when stream cancels" ) ]
32
- public void CompleteMaterializedPromiseWithNoneWhenCancelled ( )
32
+ public async Task CompleteMaterializedPromiseWithNoneWhenCancelled ( )
33
33
{
34
- this . AssertAllStagesStopped ( ( ) =>
35
- {
34
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
36
35
var neverSource = Source . Maybe < int > ( ) ;
37
36
var pubSink = Sink . AsPublisher < int > ( false ) ;
38
37
@@ -42,11 +41,11 @@ public void CompleteMaterializedPromiseWithNoneWhenCancelled()
42
41
43
42
var c = this . CreateManualSubscriberProbe < int > ( ) ;
44
43
neverPub . Subscribe ( c ) ;
45
- var subs = c . ExpectSubscription ( ) ;
44
+ var subs = await c . ExpectSubscriptionAsync ( ) ;
46
45
47
46
subs . Request ( 1000 ) ;
48
- c . ExpectNoMsg ( 100 . Milliseconds ( ) ) ;
49
-
47
+ await c . ExpectNoMsgAsync ( 100 . Milliseconds ( ) ) ;
48
+
50
49
subs . Cancel ( ) ;
51
50
52
51
tcs . Task . Wait ( 3 . Seconds ( ) ) . Should ( ) . BeTrue ( ) ;
@@ -55,39 +54,39 @@ public void CompleteMaterializedPromiseWithNoneWhenCancelled()
55
54
}
56
55
57
56
[ Fact ( DisplayName = "The Maybe Source must complete materialized promise with 0 when stream cancels with a failure cause" ) ]
58
- public void CompleteMaterializedTaskWithNoneWhenStreamCancelsWithFailure ( )
57
+ public async Task CompleteMaterializedTaskWithNoneWhenStreamCancelsWithFailure ( )
59
58
{
60
- this . AssertAllStagesStopped ( ( ) =>
61
- {
62
- var ( tcs , killSwitch ) = Source . Maybe < int > ( )
63
- . ViaMaterialized ( KillSwitches . Single < int > ( ) , Keep . Both )
64
- . To ( Sink . Ignore < int > ( ) )
65
- . Run ( _materializer ) ;
59
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
60
+ var ( tcs , killSwitch ) = Source . Maybe < int > ( )
61
+ . ViaMaterialized ( KillSwitches . Single < int > ( ) , Keep . Both )
62
+ . To ( Sink . Ignore < int > ( ) )
63
+ . Run ( _materializer ) ;
66
64
67
65
var boom = new TestException ( "Boom" ) ;
68
66
killSwitch . Abort ( boom ) ;
69
67
// Could make sense to fail it with the propagated exception instead but that breaks
70
68
// the assumptions in the CoupledTerminationFlowSpec
71
69
tcs . Task . Wait ( 3 . Seconds ( ) ) . Should ( ) . BeTrue ( ) ;
72
70
tcs . Task . Result . Should ( ) . Be ( 0 ) ;
71
+ return Task . CompletedTask ;
73
72
} , _materializer ) ;
74
73
}
75
74
76
75
[ Fact ( DisplayName = "The Maybe Source must allow external triggering of empty completion" ) ]
77
- public void AllowExternalTriggeringOfEmptyCompletion ( )
76
+ public async Task AllowExternalTriggeringOfEmptyCompletion ( )
78
77
{
79
- this . AssertAllStagesStopped ( ( ) =>
80
- {
78
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
81
79
var neverSource = Source . Maybe < int > ( ) . Where ( _ => false ) ;
82
80
var counterSink = Sink . Aggregate < int , int > ( 0 , ( acc , _ ) => acc + 1 ) ;
83
81
var ( neverPromise , counterFuture ) = neverSource
84
82
. ToMaterialized ( counterSink , Keep . Both )
85
83
. Run ( _materializer ) ;
86
-
84
+
87
85
// external cancellation
88
86
neverPromise . TrySetResult ( 0 ) . Should ( ) . BeTrue ( ) ;
89
87
counterFuture . Wait ( 3 . Seconds ( ) ) . Should ( ) . BeTrue ( ) ;
90
88
counterFuture . Result . Should ( ) . Be ( 0 ) ;
89
+ return Task . CompletedTask ;
91
90
} , _materializer ) ;
92
91
}
93
92
@@ -96,54 +95,52 @@ public void AllowExternalTriggeringOfEmptyCompletion()
96
95
[ Fact (
97
96
DisplayName = "The Maybe Source must allow external triggering of empty completion when there was no demand" ,
98
97
Skip = "Not working, check Maybe<T> source." ) ]
99
- public void AllowExternalTriggerOfEmptyCompletionWhenNoDemand ( )
98
+ public async Task AllowExternalTriggerOfEmptyCompletionWhenNoDemand ( )
100
99
{
101
- this . AssertAllStagesStopped ( ( ) =>
102
- {
100
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
103
101
var probe = this . CreateSubscriberProbe < int > ( ) ;
104
102
var promise = Source
105
103
. Maybe < int > ( )
106
104
. To ( Sink . FromSubscriber ( probe ) )
107
105
. Run ( _materializer ) ;
108
-
106
+
109
107
// external cancellation
110
- probe . EnsureSubscription ( ) ;
108
+ await probe . EnsureSubscriptionAsync ( ) ;
111
109
promise . TrySetResult ( 0 ) . Should ( ) . BeTrue ( ) ;
112
- probe . ExpectComplete ( ) ;
110
+ await probe . ExpectCompleteAsync ( ) ;
113
111
} , _materializer ) ;
114
112
}
115
113
116
114
[ Fact ( DisplayName = "The Maybe Source must allow external triggering of non-empty completion" ) ]
117
- public void AllowExternalTriggerNonEmptyCompletion ( )
115
+ public async Task AllowExternalTriggerNonEmptyCompletion ( )
118
116
{
119
- this . AssertAllStagesStopped ( ( ) =>
120
- {
117
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
121
118
var neverSource = Source . Maybe < int > ( ) ;
122
119
var counterSink = Sink . First < int > ( ) ;
123
120
124
121
var ( neverPromise , counterFuture ) = neverSource
125
122
. ToMaterialized ( counterSink , Keep . Both )
126
123
. Run ( _materializer ) ;
127
-
124
+
128
125
// external cancellation
129
126
neverPromise . TrySetResult ( 6 ) . Should ( ) . BeTrue ( ) ;
130
127
counterFuture . Wait ( 3 . Seconds ( ) ) . Should ( ) . BeTrue ( ) ;
131
128
counterFuture . Result . Should ( ) . Be ( 6 ) ;
129
+ return Task . CompletedTask ;
132
130
} , _materializer ) ;
133
131
}
134
132
135
133
[ Fact ( DisplayName = "The Maybe Source must allow external triggering of onError" ) ]
136
- public void AllowExternalTriggerOnError ( )
134
+ public async Task AllowExternalTriggerOnError ( )
137
135
{
138
- this . AssertAllStagesStopped ( ( ) =>
139
- {
136
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
140
137
var neverSource = Source . Maybe < int > ( ) ;
141
138
var counterSink = Sink . Aggregate < int , int > ( 0 , ( acc , _ ) => acc + 1 ) ;
142
139
143
140
var ( neverPromise , counterFuture ) = neverSource
144
141
. ToMaterialized ( counterSink , Keep . Both )
145
142
. Run ( _materializer ) ;
146
-
143
+
147
144
// external cancellation
148
145
neverPromise . TrySetException ( new TestException ( "Boom" ) ) . Should ( ) . BeTrue ( ) ;
149
146
@@ -152,6 +149,7 @@ public void AllowExternalTriggerOnError()
152
149
. WithInnerException < AggregateException > ( )
153
150
. WithInnerException < TestException > ( )
154
151
. WithMessage ( "Boom" ) ;
152
+ return Task . CompletedTask ;
155
153
} , _materializer ) ;
156
154
}
157
155
0 commit comments