public void Error()
 {
     SingleSource.Error <int>(new InvalidOperationException())
     .OnTerminateDetach()
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
 /// <summary>
 /// 停止播放单通道音效
 /// </summary>
 public void StopSingleSound()
 {
     if (SingleSource.isPlaying)
     {
         SingleSource.Stop();
     }
 }
Beispiel #3
0
 public void Single_Error()
 {
     SingleSource.Error <int>(new InvalidOperationException())
     .IgnoreElement()
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
 public void Single_Main_Error()
 {
     CompletableSource.Error(new InvalidOperationException())
     .AndThen(SingleSource.Just(1))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Beispiel #5
0
 public void Max_Delayed_Basic()
 {
     Observable.Range(1, 5)
     .FlatMap(v => SingleSource.Just(v + 1), true)
     .Test()
     .AssertResult(2, 3, 4, 5, 6);
 }
Beispiel #6
0
 public void Basic()
 {
     SingleSource.Never <int>()
     .Test()
     .AssertSubscribed()
     .AssertEmpty();
 }
Beispiel #7
0
 public void Single_Basic()
 {
     SingleSource.Just(1)
     .FlatMap(v => SingleSource.Just("" + (v + 1)))
     .Test()
     .AssertResult("2");
 }
Beispiel #8
0
        public void All_Success()
        {
            var success        = 0;
            var afterSuccess   = 0;
            var error          = 0;
            var terminate      = 0;
            var afterterminate = 0;
            var subscribe      = 0;
            var dispose        = 0;
            var final          = 0;

            SingleSource.Just(1)
            .DoOnSuccess(v => success++)
            .DoAfterSuccess(v => afterSuccess++)
            .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(0, error);
            Assert.AreEqual(1, terminate);
            Assert.AreEqual(1, afterterminate);
            Assert.AreEqual(1, subscribe);
            Assert.AreEqual(0, dispose);
            Assert.AreEqual(1, final);
        }
Beispiel #9
0
        public void All_Error()
        {
            var success        = 0;
            var afterSuccess   = 0;
            var error          = 0;
            var terminate      = 0;
            var afterterminate = 0;
            var subscribe      = 0;
            var dispose        = 0;
            var final          = 0;

            SingleSource.Error <int>(new InvalidOperationException())
            .DoOnSuccess(v => success++)
            .DoOnSuccess(v => afterSuccess++)
            .DoOnError(e => error++)
            .DoOnTerminate(() => terminate++)
            .DoAfterTerminate(() => afterterminate++)
            .DoOnSubscribe(d => subscribe++)
            .DoOnDispose(() => dispose++)
            .DoFinally(() => final++)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.AreEqual(0, success);
            Assert.AreEqual(0, afterSuccess);
            Assert.AreEqual(1, error);
            Assert.AreEqual(1, terminate);
            Assert.AreEqual(1, afterterminate);
            Assert.AreEqual(1, subscribe);
            Assert.AreEqual(0, dispose);
            Assert.AreEqual(1, final);
        }
        public void Value_Success_Timeout()
        {
            var v = SingleSource.Just(1)
                    .Wait(5000);

            Assert.AreEqual(1, v);
        }
        public void Value_Success_Timeout_CancellationTokenSource()
        {
            var v = SingleSource.Just(1)
                    .Wait(5000, cts: new CancellationTokenSource());

            Assert.AreEqual(1, v);
        }
Beispiel #12
0
        public void Eager_Mapper_Crash()
        {
            var subj = new Subject <int>();

            var to = subj
                     .SwitchMap(v => {
                if (v == 3)
                {
                    throw new InvalidOperationException();
                }
                return(SingleSource.Just(v + 1));
            })
                     .Test();

            subj.OnNext(1);

            to.AssertValuesOnly(2);

            subj.OnNext(2);

            to.AssertValuesOnly(2, 3);

            subj.OnNext(3);

            Assert.False(subj.HasObservers);

            to
            .AssertFailure(typeof(InvalidOperationException), 2, 3);
        }
Beispiel #13
0
 public void Eager_Basic()
 {
     Observable.Range(1, 5)
     .SwitchMap(v => SingleSource.Just(v + 1))
     .Test()
     .AssertResult(2, 3, 4, 5, 6);
 }
Beispiel #14
0
 public void Delayed_Main_Error()
 {
     Observable.Range(1, 5).ConcatError(new InvalidOperationException())
     .SwitchMap(v => SingleSource.Just(v + 1), true)
     .Test()
     .AssertFailure(typeof(InvalidOperationException), 2, 3, 4, 5, 6);
 }
Beispiel #15
0
 public void Single_Empty()
 {
     MaybeSource.Empty <int>()
     .SwitchIfEmpty(SingleSource.Just(2))
     .Test()
     .AssertResult(2);
 }
Beispiel #16
0
 public void Success()
 {
     SingleSource.Just(1)
     .Hide()
     .Test()
     .AssertResult(1);
 }
Beispiel #17
0
 public void Single_Error_Fallback()
 {
     MaybeSource.Empty <int>()
     .SwitchIfEmpty(SingleSource.Error <int>(new InvalidOperationException()))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Beispiel #18
0
 public void Times_Success()
 {
     SingleSource.Just(1)
     .Retry()
     .Test()
     .AssertResult(1);
 }
Beispiel #19
0
 public void Maybe_Error_Inner()
 {
     SingleSource.Just(1)
     .FlatMap(v => MaybeSource.Error <int>(new InvalidOperationException()))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Beispiel #20
0
 public void Handler_Success()
 {
     SingleSource.Just(1)
     .Retry((e, i) => true)
     .Test()
     .AssertResult(1);
 }
 public void Single_Basic()
 {
     CompletableSource.Empty()
     .AndThen(SingleSource.Just(1))
     .Test()
     .AssertResult(1);
 }
Beispiel #22
0
        public void Success()
        {
            IMaybeSource <int> src = SingleSource.Just(1)
                                     .ToMaybe();

            src.Test().AssertResult(1);
        }
 public void Single_Next_Error()
 {
     CompletableSource.Empty()
     .AndThen(SingleSource.Error <int>(new InvalidOperationException()))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Beispiel #24
0
        public void Error()
        {
            IMaybeSource <int> src = SingleSource.Error <int>(new InvalidOperationException())
                                     .ToMaybe();

            src.Test().AssertFailure(typeof(InvalidOperationException));
        }
Beispiel #25
0
 public void Max_Eager_Error()
 {
     Observable.Range(1, 5).ConcatError(new InvalidOperationException())
     .FlatMap(v => SingleSource.Just(v + 1))
     .Test()
     .AssertFailure(typeof(InvalidOperationException), 2, 3, 4, 5, 6);
 }
Beispiel #26
0
 public void Dispose_Fallback()
 {
     TestHelper.VerifyDisposeSingle <int, int>(m =>
                                               SingleSource.Error <int>(new InvalidOperationException())
                                               .OnErrorResumeNext(m)
                                               );
 }
Beispiel #27
0
 public void Single_Success()
 {
     SingleSource.Just(1)
     .IgnoreElement()
     .Test()
     .AssertResult();
 }
Beispiel #28
0
 public void Single_Success()
 {
     MaybeSource.Just(1)
     .SwitchIfEmpty(SingleSource.Just(2))
     .Test()
     .AssertResult(1);
 }
Beispiel #29
0
 public void Times_Error()
 {
     SingleSource.Error <int>(new InvalidOperationException())
     .Repeat()
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
 public void Success()
 {
     SingleSource.Just(1)
     .OnTerminateDetach()
     .Test()
     .AssertResult(1);
 }