public void Regular_Empty()
 {
     ObservableSource.Empty <int>().Hide()
     .ConcatMap(v => ObservableSource.Just(9 + v))
     .Test()
     .AssertResult();
 }
Esempio n. 2
0
 public void Counted_Zero()
 {
     ObservableSource.Just(1)
     .Repeat(0)
     .Test()
     .AssertResult();
 }
        public void Scalar()
        {
            var scalar = ObservableSource.Just(1) as IStaticValue <int>;

            Assert.AreEqual(1, scalar.GetValue(out var success));
            Assert.True(success);
        }
Esempio n. 4
0
 public void Until_Just()
 {
     ObservableSource.Range(1, 5)
     .TakeUntil(ObservableSource.Just(1))
     .Test()
     .AssertResult();
 }
 public void Fused_Empty()
 {
     ObservableSource.Empty <int>()
     .ConcatMap(v => ObservableSource.Just(9 + v))
     .Test()
     .AssertResult();
 }
 public void Max_Error_Outer_Scalar()
 {
     ObservableSource.Range(1, 5).ConcatError(new InvalidOperationException())
     .FlatMap(v => ObservableSource.Just(v))
     .Test()
     .AssertFailure(typeof(InvalidOperationException), 1, 2, 3, 4, 5);
 }
Esempio n. 7
0
 public void Basic()
 {
     ObservableSource.Just(1)
     .Compose(v => v)
     .Test()
     .AssertResult(1);
 }
 public void Fused_Basic()
 {
     ObservableSource.Range(1, 5)
     .ConcatMap(v => ObservableSource.Just(9 + v))
     .Test()
     .AssertResult(10, 11, 12, 13, 14);
 }
        public void All_Success()
        {
            var success        = 0;
            var afterSuccess   = 0;
            var completed      = 0;
            var error          = 0;
            var terminate      = 0;
            var afterterminate = 0;
            var subscribe      = 0;
            var dispose        = 0;
            var final          = 0;

            ObservableSource.Just(1)
            .DoOnNext(v => success++)
            .DoAfterNext(v => afterSuccess++)
            .DoOnCompleted(() => completed++)
            .DoOnError(e => error++)
            .DoOnTerminate(() => terminate++)
            .DoAfterTerminate(() => afterterminate++)
            .DoOnSubscribe(d => subscribe++)
            .DoOnDispose(() => dispose++)
            .DoFinally(() => final++)
            .Test()
            .AssertResult(1);

            Assert.AreEqual(1, success);
            Assert.AreEqual(1, afterSuccess);
            Assert.AreEqual(1, completed);
            Assert.AreEqual(0, error);
            Assert.AreEqual(1, terminate);
            Assert.AreEqual(1, afterterminate);
            Assert.AreEqual(1, subscribe);
            Assert.AreEqual(0, dispose);
            Assert.AreEqual(1, final);
        }
 public void Supplier_Crash()
 {
     ObservableSource.Just(1)
     .Collect <int, List <int> >(() => throw new InvalidOperationException(), (a, b) => a.Add(b))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
 public void Initial_Reducer_Crash()
 {
     ObservableSource.Just(1)
     .Reduce <int, int>(() => 0, (a, b) => throw new InvalidOperationException())
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
        public void Single_Basic()
        {
            var v = ObservableSource.Just(1)
                    .BlockingFirst();

            Assert.AreEqual(1, v);
        }
Esempio n. 13
0
 public void Predicate_Counted_Basic()
 {
     ObservableSource.Just(1)
     .Repeat(count => count < 5)
     .Test()
     .AssertResult(1, 1, 1, 1, 1);
 }
 public void Regular_Error()
 {
     ObservableSource.Error <int>(new InvalidOperationException()).Hide()
     .ConcatMap(v => ObservableSource.Just(9 + v))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
 public void Max_Basic_Scalar()
 {
     ObservableSource.Range(1, 5)
     .FlatMap(v => ObservableSource.Just(v))
     .Test()
     .AssertResult(1, 2, 3, 4, 5);
 }
        public void Max_Mixed_Long()
        {
            ObservableSource.Range(0, 1200)
            .FlatMap(v => {
                var type = v % 6;
                switch (type)
                {
                case 0: return(ObservableSource.Just(v).Hide());

                case 1: return(ObservableSource.Just(v));

                case 2: return(ObservableSource.Range(v, 2).Hide());

                case 3: return(ObservableSource.Range(v, 2));

                case 4: return(ObservableSource.Empty <int>().Hide());

                case 5: return(ObservableSource.Empty <int>());
                }
                throw new InvalidOperationException();
            })
            .Test()
            .AwaitDone(TimeSpan.FromSeconds(5))
            .AssertSubscribed()
            .AssertValueCount(1200)
            .AssertNoError()
            .AssertCompleted();
        }
        public void Limited_Mixed_Long()
        {
            for (int i = 1; i < 7; i++)
            {
                ObservableSource.Range(0, 1200)
                .FlatMap(v => {
                    var type = v % 6;
                    switch (type)
                    {
                    case 0: return(ObservableSource.Just(v).Hide());

                    case 1: return(ObservableSource.Just(v));

                    case 2: return(ObservableSource.Range(v, 2).Hide());

                    case 3: return(ObservableSource.Range(v, 2));

                    case 4: return(ObservableSource.Empty <int>().Hide());

                    case 5: return(ObservableSource.Empty <int>());
                    }
                    throw new InvalidOperationException();
                }, maxConcurrency: i)
                .Test()
                .WithTag($"maxConcurrency: {i}")
                .AwaitDone(TimeSpan.FromSeconds(5))
                .AssertSubscribed()
                .AssertValueCount(1200)
                .AssertNoError()
                .AssertCompleted();
            }
        }
 public void Default_Basic()
 {
     ObservableSource.Just(1)
     .Single(100)
     .Test()
     .AssertResult(1);
 }
        public void Single_Delayed()
        {
            var v = ObservableSource.Just(1).Delay(TimeSpan.FromMilliseconds(20), ThreadPoolScheduler.Instance)
                    .BlockingSingle();

            Assert.AreEqual(1, v);
        }
 public void Plain_Basic()
 {
     ObservableSource.Just(1)
     .Single()
     .Test()
     .AssertResult(1);
 }
Esempio n. 21
0
 public void MoveNext_Crash()
 {
     ObservableSource.Just(1).Hide()
     .ConcatMap(v => new FailingEnumerable <int>(false, true, false))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Esempio n. 22
0
 public void Counted_Basic()
 {
     ObservableSource.Just(1)
     .Repeat(5)
     .Test()
     .AssertResult(1, 1, 1, 1, 1);
 }
Esempio n. 23
0
 public void Until_Just()
 {
     ObservableSource.Range(1, 5)
     .SkipUntil(ObservableSource.Just(1))
     .Test()
     .AssertResult(1, 2, 3, 4, 5);
 }
 public void Limited_Error_Inner_Delayed()
 {
     var to = ObservableSource.Just <IObservableSource <int> >(
         ObservableSource.Error <int>(new InvalidOperationException())).Hide()
              .Merge(true, 1)
              .Test()
              .AssertFailure(typeof(InvalidOperationException));
 }
 public void Regular_Take()
 {
     ObservableSource.Range(1, 5).Hide()
     .ConcatMap(v => ObservableSource.Just(9 + v))
     .Take(3)
     .Test()
     .AssertResult(10, 11, 12);
 }
 public void Fusion_Sync()
 {
     ObservableSource.Just(1)
     .Test(fusionMode: FusionSupport.Sync)
     .AssertFuseable()
     .AssertFusionMode(FusionSupport.Sync)
     .AssertResult(1);
 }
        public void TrySingle_NonEmpty()
        {
            var v = ObservableSource.Just(1)
                    .BlockingTrySingle(out var success);

            Assert.True(success);
            Assert.AreEqual(1, v);
        }
Esempio n. 28
0
 public void Predicate_Counted_Basic_Long()
 {
     ObservableSource.Just(1)
     .Repeat(count => count < 1000)
     .Test()
     .AssertValueCount(1000)
     .AssertNoError()
     .AssertCompleted();
 }
        public void SingleTask_Basic()
        {
            var task = ObservableSource.Just(1)
                       .SingleTask();

            Assert.True(task.Wait(5000));

            Assert.AreEqual(1, task.Result);
        }
 public void Default_Fused()
 {
     ObservableSource.Just(1)
     .Single(100)
     .Test(fusionMode: FusionSupport.Any)
     .AssertFuseable()
     .AssertFusionMode(FusionSupport.Async)
     .AssertResult(1);
 }