Esempio n. 1
0
 public async void Timer()
 {
     await AsyncEnumerable.Range(1, 10)
     .FlatMap(v => AsyncEnum.Timer(TimeSpan.FromMilliseconds(100)))
     .Take(5)
     .AssertResult(0L, 0L, 0L, 0L, 0L);
 }
 public async void Take()
 {
     await AsyncEnum.MergeConcurrently(
         AsyncEnum.Timer(TimeSpan.FromMilliseconds(100)),
         AsyncEnum.Timer(TimeSpan.FromMilliseconds(200))
         )
     .Take(1)
     .AssertResult(0L);
 }
Esempio n. 3
0
 public async void Delayed_Completion_After_Debounced_Item()
 {
     await AsyncEnum.Just(1)
     .ConcatWith(
         AsyncEnum.Timer(TimeSpan.FromMilliseconds(200))
         .Select(v => 0)
         .IgnoreElements()
         )
     .Throttle(TimeSpan.FromMilliseconds(100))
     .AssertResult(1);
 }
Esempio n. 4
0
        public async void Cancel()
        {
            var cts = new CancellationTokenSource();

            var push = new UnicastAsyncEnumerable <long>();

            var t = AsyncEnum.Timer(TimeSpan.FromMilliseconds(500))
                    .Consume(push, cts.Token);

            await Task.Delay(100, cts.Token);

            cts.Cancel();

            await t;
        }
Esempio n. 5
0
        public async void OutOfOrder()
        {
            var t = 100;

            if (Environment.GetEnvironmentVariable("CI") != null)
            {
                t = 1000;
            }

            var result = AsyncEnum.FromArray(
                t, 3 * t, 2 * t, 0, 5 * t, 4 * t
                )
                         .FlatMap(v => AsyncEnum.Timer(TimeSpan.FromMilliseconds(v)).Select(w => v))
            ;

            await result.AssertResult(0, t, 2 *t, 3 *t, 4 *t, 5 *t);
        }