Exemplo n.º 1
0
        public async void Push()
        {
            for (var i = 0; i < 10; i++)
            {
                var push = new MulticastAsyncEnumerable <int>();

                var en = AsyncEnum.MergeConcurrently(
                    push.Where(v => v % 2 == 0),
                    push.Where(v => v % 2 != 0)
                    )
                         .ToListAsync();

                var t = Task.Run(async() =>
                {
                    for (var j = 0; j < 100_000; j++)
                    {
                        await push.Next(j);
                    }
                    await push.Complete();
                });

                var list = await en;

                await t;

                var set = new HashSet <int>(list);

                Assert.Equal(100_000, set.Count);
            }
        }
Exemplo n.º 2
0
 public async void Solo()
 {
     await AsyncEnum.MergeConcurrently(
         AsyncEnumerable.Range(1, 5)
         )
     .AssertResult(1, 2, 3, 4, 5);
 }
Exemplo n.º 3
0
 public async void Error()
 {
     await AsyncEnum.MergeConcurrently(
         AsyncEnumerable.Range(1, 5),
         AsyncEnum.Error <int>(new InvalidOperationException())
         )
     .AssertFailure(typeof(InvalidOperationException), 1, 2, 3, 4, 5);
 }
Exemplo n.º 4
0
 public async void Normal_Uneven_2()
 {
     await AsyncEnum.MergeConcurrently(
         AsyncEnumerable.Range(1, 4),
         AsyncEnumerable.Range(6, 5)
         )
     .AssertResultSet(1, 2, 3, 4, 6, 7, 8, 9, 10);
 }
Exemplo n.º 5
0
 public async void Take()
 {
     await AsyncEnum.MergeConcurrently(
         AsyncEnum.Timer(TimeSpan.FromMilliseconds(100)),
         AsyncEnum.Timer(TimeSpan.FromMilliseconds(200))
         )
     .Take(1)
     .AssertResult(0L);
 }
Exemplo n.º 6
0
 public async void Empty()
 {
     await AsyncEnum.MergeConcurrently <int>(
         )
     .AssertResult();
 }