public void Skip()
 {
     Flowable.Range(1, 10)
     .Window(1, 2)
     .Merge()
     .Test()
     .AssertResult(1, 3, 5, 7, 9);
 }
Beispiel #2
0
        IEnumerable <IFlowable <int> > Sequence(long elements)
        {
            yield return(Flowable.Empty <int>());

            yield return(Flowable.Empty <int>());

            yield return(Flowable.Range(1, (int)elements));
        }
Beispiel #3
0
 public void OneGroupLong()
 {
     Flowable.Range(1, 1000).GroupBy(v => 1).FlatMap(v => v)
     .Test()
     .AssertValueCount(1000)
     .AssertNoError()
     .AssertComplete();
 }
Beispiel #4
0
 public void Simple()
 {
     Flowable.Range(1, 5)
     .SubscribeOn(Executors.Task)
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertResult(1, 2, 3, 4, 5);
 }
Beispiel #5
0
 public void SimpleHidden()
 {
     Flowable.Range(1, 5).Hide()
     .ObserveOn(Executors.Task)
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertResult(1, 2, 3, 4, 5);
 }
Beispiel #6
0
 public void Normal()
 {
     Flowable.Range(1, 100)
     .Delay(TimeSpan.FromMilliseconds(1), Executors.Single)
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertResult(Enumerable.Range(1, 100).ToArray());
 }
Beispiel #7
0
 public void AllGroupLongHidden()
 {
     Flowable.Range(1, 1000).GroupBy(v => v).FlatMap(v => v.Hide(), int.MaxValue)
     .Test()
     .AssertValueCount(1000)
     .AssertNoError()
     .AssertComplete();
 }
Beispiel #8
0
 public override IPublisher <int> CreatePublisher(long elements)
 {
     if (elements == 0)
     {
         return(Flowable.Empty <int>());
     }
     return(Flowable.Range(1, (int)elements - 1).Scan(() => 1, (a, b) => a + b));
 }
 public void Overlap()
 {
     Flowable.Range(1, 5)
     .Window(2, 1)
     .Merge()
     .Test()
     .AssertResult(1, 2, 2, 3, 3, 4, 4, 5, 5);
 }
 public void Skip3()
 {
     Flowable.Range(1, 10)
     .Window(1, 3)
     .Merge()
     .Test()
     .AssertResult(1, 4, 7, 10);
 }
 public override IPublisher <int> CreatePublisher(long elements)
 {
     return(Flowable.Range(1, (int)elements)
            .Hide()
            .Parallel()
            .RunOn(Executors.Computation)
            .Sequential());
 }
Beispiel #12
0
 public void Normal()
 {
     Flowable.Range(1, 10)
     .Map(v => 11 - v)
     .Parallel(2)
     .ToSortedList()
     .Test()
     .AssertResult(new List <int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }));
 }
Beispiel #13
0
 public void Range2()
 {
     Flowable.Range(1, 2).Buffer(2, 1)
     .Test()
     .AssertResult(
         listOf(1, 2),
         listOf(2)
         );
 }
Beispiel #14
0
 public void Fallback2()
 {
     Flowable.Just(0)
     .ConcatWith(Flowable.Never <int>())
     .Timeout(TimeSpan.FromMilliseconds(100), Flowable.Range(1, 5))
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertResult(0, 1, 2, 3, 4, 5);
 }
Beispiel #15
0
        public void FlatMapEnumerableTest1000000_Fused()
        {
            int i = 1000000;
            int j = 1000000 / i;

            Flowable.Range(1, i)
            .FlatMapEnumerable(v => Enumerable.Range(v, j))
            .Subscribe(new PerfFlowableSubscriber <int>());
        }
 public void InnerErrorEager()
 {
     Flowable.Range(0, 5)
     .FlatMap(x => x == 0 ? Flowable.Error <int>(new Exception()) : Flowable.Just(x).Delay(TimeSpan.FromMilliseconds(10)), Flowable.BufferSize(), Flowable.BufferSize(), false)
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertValueCount(0)
     .AssertError(typeof(Exception));
 }
Beispiel #17
0
 public void Long()
 {
     Flowable.Range(1, 1000).GroupBy(v => v)
     .DoOnNext(v => v.Subscribe())
     .Test()
     .AssertValueCount(1000)
     .AssertNoError()
     .AssertComplete();
 }
Beispiel #18
0
        public void Normal()
        {
            var ts = new TestSubscriber <int>();

            Flowable.Range(1, 10)
            .BlockingSubscribe(ts);

            ts.AssertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        }
Beispiel #19
0
 public void ParallelSequentialBackpressured()
 {
     Flowable.Range(1, 1024)
     .Parallel(1)
     .Sequential()
     .Test(1024)
     .AssertValueCount(1024)
     .AssertComplete()
     ;
 }
Beispiel #20
0
 public void Normal32()
 {
     Flowable.Range(1, 5).Buffer(3, 2)
     .Test()
     .AssertResult(
         listOf(1, 2, 3),
         listOf(3, 4, 5),
         listOf(5)
         );
 }
        public void Disconnect()
        {
            var pp = new PublishProcessor <int>();

            pp.Publish(f => Flowable.Range(1, 5))
            .Test()
            .AssertResult(1, 2, 3, 4, 5);

            Assert.IsFalse(pp.HasSubscribers);
        }
Beispiel #22
0
 public void LessConcurrency()
 {
     var result = Flowable.Range(0, 3)
                  .ConcatMapEager(x =>
     {
         return(Flowable.Just(x));
     }, 2)
                  .Test()
                  .AssertResult(0, 1, 2);
 }
 public void SourceErrorDelayed()
 {
     Flowable.Just(0)
     .ConcatWith(Flowable.Error <int>(new Exception()))
     .FlatMap(x => Flowable.Range(0, 5).Delay(TimeSpan.FromMilliseconds(10)))
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertValues(Enumerable.Range(0, 5))
     .AssertError(typeof(Exception));
 }
Beispiel #24
0
 public void GroupUnsubscriptionOnError()
 {
     Flowable.Range(0, 1000)
     .GroupBy(x => x % 2)
     .FlatMap(g => g.Map <int, int>(x => throw new Exception()))
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertValueCount(0)
     .AssertError(typeof(Exception));
 }
Beispiel #25
0
        public void NormalAsync()
        {
            var ts = new TestSubscriber <int>();

            Flowable.Range(1, 10)
            .Delay(TimeSpan.FromMilliseconds(10))
            .BlockingSubscribe(ts);

            ts.AssertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        }
Beispiel #26
0
        public void ZipTest_DifferentLength()
        {
            TestSubscriber <int> ts = new TestSubscriber <int>();

            Flowable.Zip(Flowable.Range(1, 3), Flowable.Range(10, 2), (a, b) => a + b).Subscribe(ts);

            ts.AssertValues(11, 13)
            .AssertComplete()
            .AssertNoError();
        }
Beispiel #27
0
        public void NormalLambda()
        {
            var ts = new TestSubscriber <int>();

            ts.OnSubscribe(new BooleanSubscription());

            Flowable.Range(1, 10)
            .BlockingSubscribe(ts.OnNext, ts.OnError, ts.OnComplete);

            ts.AssertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        }
Beispiel #28
0
        public void Backpressure_NotFused_2()
        {
            var n = Flowable.BufferSize() + 1;

            Flowable.Range(0, n)
            .Hide()
            .FlatMapEnumerable(x => new[] { x, x + 1, x + 2 }, 1)
            .TakeLast(1)
            .Test()
            .AssertResult(n + 1);
        }
Beispiel #29
0
 public void ParallelSequentialHidden()
 {
     Flowable.Range(1, 1024)
     .Hide()
     .Parallel(1)
     .Sequential()
     .Test()
     .AssertValueCount(1024)
     .AssertComplete()
     ;
 }
Beispiel #30
0
        public void FlattenArray()
        {
            var n = 1000;

            Flowable.Range(0, n)
            .FlatMapEnumerable(x => new[] { x })
            .Test()
            .AssertValueCount(n)
            .AssertNoError()
            .AssertComplete();
        }