@@ -13,7 +13,35 @@ public class StreamRepositoryTests
13
13
[ Fact ]
14
14
public async Task GetNextAsync_MergesTwoStreams ( )
15
15
{
16
+ const int stream1StepSize = 3 ;
17
+ const int stream2StepSize = 7 ;
18
+ const string stream1Name = "stream1" ;
19
+ const string stream2Name = "stream2" ;
20
+ var stream1 = GetInfiniteSequence ( stream1StepSize ) ;
21
+ var stream2 = GetInfiniteSequence ( stream2StepSize ) ;
22
+ var streams = new Dictionary < string , IEnumerator < int > > ( StreamNameComparer . Comparer )
23
+ {
24
+ { stream1Name , stream1 . GetEnumerator ( ) } ,
25
+ { stream2Name , stream2 . GetEnumerator ( ) }
26
+ } ;
27
+
28
+ var systemUnderTest = new StreamRepository ( new FakeStreamClient ( streams ) , new StreamStore ( ) ) ;
16
29
30
+ const int numToCheck = 50 ;
31
+ int last = int . MinValue ;
32
+ for ( int index = 0 ; index < numToCheck ; index ++ )
33
+ {
34
+ var next = await systemUnderTest . GetNextAsync ( stream1Name , stream2Name ) ;
35
+ Assert . True ( next . CurrentValue >= last , "The next value from the stream should be greater than or equal to the previous one." ) ;
36
+ Assert . True (
37
+ next . CurrentValue % stream1StepSize == 0 || next . CurrentValue % stream2StepSize == 0 ,
38
+ "The values from the merged stream should come from either of the source streams." ) ;
39
+ if ( last != int . MinValue )
40
+ {
41
+ Assert . True ( last == next . LastValue , "The returned last value should match the previous invocation's current value." ) ;
42
+ }
43
+ last = next . CurrentValue ;
44
+ }
17
45
}
18
46
19
47
#region Fake Data Helpers
0 commit comments