File tree Expand file tree Collapse file tree 4 files changed +47
-1
lines changed
Halibut.TestUtils.CompatBinary.Base
Halibut.TestUtils.Contracts
Halibut.Tests/ServiceModel Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ public int Increment()
16
16
return countingService . Increment ( ) ;
17
17
}
18
18
19
+ public int Increment ( int ? number )
20
+ {
21
+ return countingService . Increment ( number ) ;
22
+ }
23
+
19
24
public int GetCurrentValue ( )
20
25
{
21
26
return countingService . GetCurrentValue ( ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,20 @@ public class CountingService : ICountingService
8
8
int count ;
9
9
public int Increment ( )
10
10
{
11
- return Interlocked . Increment ( ref count ) ;
11
+ return Increment ( 1 ) ;
12
+ }
13
+
14
+ public int Increment ( int ? number )
15
+ {
16
+ var increment = number ?? 1 ;
17
+ var counter = 0 ;
18
+
19
+ for ( var i = 0 ; i < increment ; i ++ )
20
+ {
21
+ counter = Interlocked . Increment ( ref count ) ;
22
+ }
23
+
24
+ return counter ;
12
25
}
13
26
14
27
public int GetCurrentValue ( )
@@ -26,6 +39,12 @@ public async Task<int> IncrementAsync(CancellationToken cancellationToken)
26
39
return service . Increment ( ) ;
27
40
}
28
41
42
+ public async Task < int > IncrementAsync ( int ? number , CancellationToken cancellationToken )
43
+ {
44
+ await Task . CompletedTask ;
45
+ return service . Increment ( number ) ;
46
+ }
47
+
29
48
public async Task < int > GetCurrentValueAsync ( CancellationToken cancellationToken )
30
49
{
31
50
await Task . CompletedTask ;
Original file line number Diff line number Diff line change @@ -6,12 +6,14 @@ namespace Halibut.TestUtils.Contracts
6
6
public interface ICountingService
7
7
{
8
8
public int Increment ( ) ;
9
+ public int Increment ( int ? number ) ;
9
10
public int GetCurrentValue ( ) ;
10
11
}
11
12
12
13
public interface IAsyncCountingService
13
14
{
14
15
public Task < int > IncrementAsync ( CancellationToken cancellationToken ) ;
16
+ public Task < int > IncrementAsync ( int ? number , CancellationToken cancellationToken ) ;
15
17
public Task < int > GetCurrentValueAsync ( CancellationToken cancellationToken ) ;
16
18
}
17
19
}
Original file line number Diff line number Diff line change @@ -53,6 +53,26 @@ public async Task AsyncInvokeWithNoParamsOnAsyncService()
53
53
response . Result . Should ( ) . Be ( 1 ) ;
54
54
}
55
55
56
+ [ Test ]
57
+ public async Task AsyncInvokeWithNullableParamsOnAsyncService ( )
58
+ {
59
+ var serviceFactory = new ServiceFactoryBuilder ( )
60
+ . WithConventionVerificationDisabled ( )
61
+ . WithService < ICountingService , IAsyncCountingService > ( ( ) => new AsyncCountingService ( ) )
62
+ . Build ( ) ;
63
+
64
+ var sut = new ServiceInvoker ( serviceFactory ) ;
65
+ var request = new RequestMessage ( )
66
+ {
67
+ ServiceName = nameof ( ICountingService ) ,
68
+ MethodName = nameof ( ICountingService . Increment ) ,
69
+ Params = new object [ ] { null ! } ,
70
+ } ;
71
+
72
+ var response = await sut . InvokeAsync ( request ) ;
73
+ response . Result . Should ( ) . Be ( 1 ) ;
74
+ }
75
+
56
76
[ Test ]
57
77
public async Task AsyncInvokeWithNoParams_AsyncServiceMissingSuffix ( )
58
78
{
You can’t perform that action at this time.
0 commit comments