当前位置: 首页>>代码示例>>C#>>正文


C# List.IsCollection方法代码示例

本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.IsCollection方法的典型用法代码示例。如果您正苦于以下问题:C# List.IsCollection方法的具体用法?C# List.IsCollection怎么用?C# List.IsCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.VisualStudio.TestTools.UnitTesting.List的用法示例。


在下文中一共展示了List.IsCollection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FromEventPattern

        public void FromEventPattern()
        {
            var tester = new EventTester();

            {
                var list = new List<int>();
                var d = Observable.FromEventPattern<EventHandler<MyEventArgs>, MyEventArgs>((h) => h.Invoke, h => tester.genericEventHandler += h, h => tester.genericEventHandler -= h)
                    .Subscribe(xx =>
                    {
                        list.Add(xx.EventArgs.MyProperty);
                        Observable.Return(xx.EventArgs.MyProperty)
                            .Do(x => { if (x == 1) throw new Exception(); })
                            .Subscribe(x => list.Add(x));
                    });

                try { tester.Fire(5); } catch { }
                try { tester.Fire(1); } catch { }
                try { tester.Fire(10); } catch { }

                list.IsCollection(5, 5, 1, 10, 10);
                d.Dispose();
                tester.Fire(1000);
                list.Count.Is(5);
            }
        }
开发者ID:createdbyx,项目名称:UniRx,代码行数:25,代码来源:DurabilityTest.cs

示例2: OfType

        public void OfType()
        {
            var subject = new Subject<object>();

            var list = new List<int>();
            subject.OfType(default(int)).Subscribe(x => list.Add(x));

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext("hogehoge");
            subject.OnNext(3);

            list.IsCollection(1, 2, 3);
        }
开发者ID:createdbyx,项目名称:UniRx,代码行数:14,代码来源:ConversionTest.cs

示例3: CurrentThread2

        public void CurrentThread2()
        {
            var scheduler = Scheduler.CurrentThread;

            var list = new List<string>();
            scheduler.Schedule(() =>
            {
                list.Add("one");

                scheduler.Schedule(TimeSpan.FromSeconds(3), () =>
                {
                    list.Add("after 3");
                });

                scheduler.Schedule(TimeSpan.FromSeconds(1), () =>
                {
                    list.Add("after 1");
                });
            });

            list.IsCollection("one", "after 1", "after 3");
        }
开发者ID:createdbyx,项目名称:UniRx,代码行数:22,代码来源:SchedulerTest.cs

示例4: ToObservable

        public void ToObservable()
        {
            {
                var msgs = new List<string>();
                new[] { 1, 10, 100, 1000, 10000, 20000 }.ToObservable(Scheduler.CurrentThread)
                    .Do(i => msgs.Add("DO:" + i))
                    .Scan((x, y) =>
                    {
                        if (y == 100) throw new Exception("exception");
                        msgs.Add("x:" + x + " y:" + y);
                        return x + y;
                    })
                    .Subscribe(x => msgs.Add(x.ToString()), e => msgs.Add(e.Message), () => msgs.Add("comp"));

                msgs.IsCollection("DO:1", "1", "DO:10", "x:1 y:10", "11", "DO:100", "exception");
            }

            {
                var msgs = new List<string>();
                new[] { 1, 10, 100, 1000, 10000, 20000 }.ToObservable(Scheduler.Immediate)
                    .Do(i => msgs.Add("DO:" + i))
                    .Scan((x, y) =>
                    {
                        if (y == 100) throw new Exception("exception");
                        msgs.Add("x:" + x + " y:" + y);
                        return x + y;
                    })
                    .Subscribe(x => msgs.Add(x.ToString()), e => msgs.Add(e.Message), () => msgs.Add("comp"));

                msgs.IsCollection("DO:1", "1", "DO:10", "x:1 y:10", "11", "DO:100", "exception",
                    "DO:1000", "x:11 y:1000",
                    "DO:10000", "x:1011 y:10000",
                    "DO:20000", "x:11011 y:20000"
                    );
            }
        }
开发者ID:createdbyx,项目名称:UniRx,代码行数:36,代码来源:Observable.GeneratorTest.cs

示例5: ForEachAsync

        public void ForEachAsync()
        {
            {
                var list = new List<int>();
                var xs = Observable.Range(1, 10).ForEachAsync(x => list.Add(x)).ToArray().Wait();
                list.IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
                xs.Length.Is(1);
                xs[0].Is(Unit.Default);
            }

            {
                var list = new List<int>();
                var listI = new List<int>();
                var xs = Observable.Range(1, 10).ForEachAsync((x, i) =>
                {
                    list.Add(x);
                    listI.Add(i);
                }).ToArray().Wait();
                list.IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
                listI.IsCollection(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
                xs.Length.Is(1);
                xs[0].Is(Unit.Default);
            }
        }
开发者ID:ragcat,项目名称:UniRx,代码行数:24,代码来源:UnitTests.cs

示例6: ResultSelectorEnumerableWithIndex

 public void ResultSelectorEnumerableWithIndex()
 {
     SetScehdulerForImport();
     {
         // OnCompleted Case
         var a = new Subject<int>();
         var list = new List<string>();
         a.SelectMany((x, i) => (x == 10) ? Enumerable.Range(i, 3) : Enumerable.Repeat(i, 3), (x, i1, y, i2) => Tuple.Create(x, i1, y, i2))
          .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
         a.OnNext(10);
         a.OnNext(100);
         // do
         a.OnCompleted();
         // check
         list.IsCollection("OnNext((10, 0, 0, 0))", "OnNext((10, 0, 1, 1))", "OnNext((10, 0, 2, 2))", "OnNext((100, 1, 1, 0))", "OnNext((100, 1, 1, 1))", "OnNext((100, 1, 1, 2))", "OnCompleted()");
     }
     {
         // OnError Case
         var a = new Subject<int>();
         var list = new List<string>();
         a.SelectMany((x, i) => (x == 10) ? Enumerable.Range(i, 3) : Enumerable.Repeat(i, 3), (x, i1, y, i2) => Tuple.Create(x, i1, y, i2))
             .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
         a.OnNext(10);
         a.OnNext(100);
         // do
         a.OnError(new Exception());
         // check
         list.IsCollection("OnNext((10, 0, 0, 0))", "OnNext((10, 0, 1, 1))", "OnNext((10, 0, 2, 2))", "OnNext((100, 1, 1, 0))", "OnNext((100, 1, 1, 1))", "OnNext((100, 1, 1, 2))", "OnError(System.Exception)");
     }
     UniRx.Scheduler.SetDefaultForUnity();
 }
开发者ID:neuecc,项目名称:UniRx,代码行数:31,代码来源:TestImporter.cs

示例7: DoOnTerminate

        public void DoOnTerminate()
        {
            var list = new List<int>();
            Observable.Empty<int>().DoOnTerminate(() => list.Add(1000)).DefaultIfEmpty().Wait();
            list.IsCollection(1000);

            list.Clear();
            Observable.Range(1, 5).DoOnTerminate(() => list.Add(1000)).Wait();
            list.IsCollection(1000);

            list.Clear();
            Observable.Range(1, 5).Concat(Observable.Throw<int>(new Exception())).DoOnTerminate(() => list.Add(1000)).Subscribe(_ => { }, _ => { }, () => { });
            list.IsCollection(1000);
        }
开发者ID:ragcat,项目名称:UniRx,代码行数:14,代码来源:UnitTests.cs

示例8: Subject

        public void Subject()
        {
            // OnCompletedPattern
            {
                var subject = new Subject<int>();

                var onNext = new List<int>();
                var exception = new List<Exception>();
                int onCompletedCallCount = 0;
                subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);

                subject.OnNext(1);
                subject.OnNext(10);
                subject.OnNext(100);
                subject.OnNext(1000);
                onNext.IsCollection(1, 10, 100, 1000);

                subject.OnCompleted();
                onCompletedCallCount.Is(1);

                subject.OnNext(1);
                subject.OnNext(10);
                subject.OnNext(100);
                onNext.Count.Is(4);

                subject.OnCompleted();
                subject.OnError(new Exception());
                exception.Count.Is(0);
                onCompletedCallCount.Is(1);

                // ++subscription
                onNext.Clear();
                onCompletedCallCount = 0;
                subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
                onNext.Count.Is(0);
                exception.Count.Is(0);
                onCompletedCallCount.Is(1);
            }

            // OnErrorPattern
            {
                var subject = new Subject<int>();

                var onNext = new List<int>();
                var exception = new List<Exception>();
                int onCompletedCallCount = 0;
                subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);

                subject.OnNext(1);
                subject.OnNext(10);
                subject.OnNext(100);
                subject.OnNext(1000);
                onNext.IsCollection(1, 10, 100, 1000);

                subject.OnError(new Exception());
                exception.Count.Is(1);

                subject.OnNext(1);
                subject.OnNext(10);
                subject.OnNext(100);
                onNext.Count.Is(4);

                subject.OnCompleted();
                subject.OnError(new Exception());
                exception.Count.Is(1);
                onCompletedCallCount.Is(0);

                // ++subscription
                onNext.Clear();
                exception.Clear();
                onCompletedCallCount = 0;
                subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
                onNext.Count.Is(0);
                exception.Count.Is(1);
                onCompletedCallCount.Is(0);
            }
        }
开发者ID:ragcat,项目名称:UniRx,代码行数:77,代码来源:UnitTests.cs

示例9: SelectorWithIndex

        public void SelectorWithIndex()
        {
            {
                // OnCompleted Case
                var a = new Subject<int>();
                var b = new Subject<int>();
                var c = new Subject<int>();
                var list = new List<string>();
                a.SelectMany((x, i) => (x == 10) ? b.Select(y => Tuple.Create(y, i)) : c.Select(y => Tuple.Create(y, i)))
                    .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
                a.OnNext(10);
                a.OnNext(100);

                // do

                b.OnNext(200);
                c.OnNext(300);
                a.OnCompleted();
                b.OnCompleted();
                c.OnNext(400);
                c.OnCompleted();

                // check
                list.IsCollection("OnNext((200, 0))", "OnNext((300, 1))", "OnNext((400, 1))", "OnCompleted()");
            }
            {
                // OnError A
                var a = new Subject<int>();
                var b = new Subject<int>();
                var c = new Subject<int>();
                var list = new List<string>();
                a.SelectMany((x, i) => (x == 10) ? b.Select(y => Tuple.Create(y, i)) : c.Select(y => Tuple.Create(y, i)))
                    .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
                a.OnNext(10);
                a.OnNext(100);

                // do

                b.OnNext(200);
                c.OnNext(300);
                a.OnError(new Exception());
                b.OnCompleted();
                c.OnNext(400);
                c.OnCompleted();

                // check
                list.IsCollection("OnNext((200, 0))", "OnNext((300, 1))", "OnError(System.Exception)");
            }
            {
                // OnError B
                var a = new Subject<int>();
                var b = new Subject<int>();
                var c = new Subject<int>();
                var list = new List<string>();
                a.SelectMany((x, i) => (x == 10) ? b.Select(y => Tuple.Create(y, i)) : c.Select(y => Tuple.Create(y, i)))
                    .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
                a.OnNext(10);
                a.OnNext(100);

                // do

                b.OnNext(200);
                c.OnNext(300);
                a.OnCompleted();
                b.OnError(new Exception());
                c.OnNext(400);
                c.OnCompleted();

                // check
                list.IsCollection("OnNext((200, 0))", "OnNext((300, 1))", "OnError(System.Exception)");
            }
        }
开发者ID:ragcat,项目名称:UniRx,代码行数:72,代码来源:UnitTests.cs

示例10: Selector

        public void Selector()
        {
            {
                // OnCompleted Case
                var a = new Subject<int>();
                var b = new Subject<int>();
                var c = new Subject<int>();
                var list = new List<string>();
                a.SelectMany(x => (x == 10) ? b : c)
                    .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
                a.OnNext(10);
                a.OnNext(100);

                // do

                b.OnNext(200);
                c.OnNext(300);
                a.OnCompleted();
                b.OnCompleted();
                c.OnNext(400);
                c.OnCompleted();

                // check
                list.IsCollection("OnNext(200)", "OnNext(300)", "OnNext(400)", "OnCompleted()");
            }
            {
                // OnError A
                var a = new Subject<int>();
                var b = new Subject<int>();
                var c = new Subject<int>();
                var list = new List<string>();
                a.SelectMany(x => (x == 10) ? b : c)
                    .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
                a.OnNext(10);
                a.OnNext(100);

                // do

                b.OnNext(200);
                c.OnNext(300);
                a.OnError(new Exception());
                b.OnCompleted();
                c.OnNext(400);
                c.OnCompleted();

                // check
                list.IsCollection("OnNext(200)", "OnNext(300)", "OnError(System.Exception)");
            }
            {
                // OnError B
                var a = new Subject<int>();
                var b = new Subject<int>();
                var c = new Subject<int>();
                var list = new List<string>();
                a.SelectMany(x => (x == 10) ? b : c)
                    .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
                a.OnNext(10);
                a.OnNext(100);

                // do

                b.OnNext(200);
                c.OnNext(300);
                a.OnCompleted();
                b.OnError(new Exception());
                c.OnNext(400);
                c.OnCompleted();

                // check
                list.IsCollection("OnNext(200)", "OnNext(300)", "OnError(System.Exception)");
            }
            {
                // OnCompleted Case2
                var a = new Subject<int>();
                var b = new Subject<int>();
                var c = new Subject<int>();
                var list = new List<string>();
                a.SelectMany(x => (x == 10) ? b : c)
                    .Materialize().Select(x => x.ToString()).Subscribe(x => list.Add(x));
                a.OnNext(10);
                a.OnNext(100);

                // do

                b.OnNext(200);
                c.OnNext(300);
                b.OnCompleted();
                c.OnCompleted();

                // check
                list.IsCollection("OnNext(200)", "OnNext(300)");

                a.OnCompleted();

                list.IsCollection("OnNext(200)", "OnNext(300)", "OnCompleted()");
            }
        }
开发者ID:ragcat,项目名称:UniRx,代码行数:97,代码来源:UnitTests.cs

示例11: Enq

        public void Enq()
        {
            var q = new UniRx.InternalUtil.ThreadSafeQueueWorker();

            var l = new List<int>();
            q.Enqueue(x => l.Add((int)x), 1);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -1);
            q.Enqueue(x => l.Add((int)x), 2);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -2);
            q.Enqueue(x => l.Add((int)x), 3);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -3);
            q.Enqueue(x => l.Add((int)x), 4);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -4);
            q.Enqueue(x => l.Add((int)x), 5);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -5);
            q.Enqueue(x => l.Add((int)x), 6);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -6);
            q.Enqueue(x => l.Add((int)x), 7);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -7);
            q.Enqueue(x => l.Add((int)x), 8);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -8);
            q.Enqueue(x => l.Add((int)x), 9);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -9);
            q.Enqueue(x => l.Add((int)x), 10);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -10);
            q.Enqueue(x => l.Add((int)x), 11);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -11);
            q.Enqueue(x => l.Add((int)x), 12);

            q.ExecuteAll(ex => { });

            l.IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
            l.Clear();

            q.ExecuteAll(ex => { });
            l.IsCollection(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11);
            l.Clear();

            q.ExecuteAll(ex => { });
            l.Count.Is(0);

            q.Enqueue(x => l.Add((int)x), 1);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -1);
            q.Enqueue(x => l.Add((int)x), 2);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -2);
            q.Enqueue(x => l.Add((int)x), 3);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -3);
            q.Enqueue(x => l.Add((int)x), 4);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -4);
            q.Enqueue(x => l.Add((int)x), 5);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -5);
            q.Enqueue(x => l.Add((int)x), 6);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -6);
            q.Enqueue(x => l.Add((int)x), 7);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -7);
            q.Enqueue(x => l.Add((int)x), 8);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -8);
            q.Enqueue(x => l.Add((int)x), 9);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -9);
            q.Enqueue(x => l.Add((int)x), 10);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -10);
            q.Enqueue(x => l.Add((int)x), 11);
            q.Enqueue(x => q.Enqueue(_ => l.Add((int)x), null), -11);
            q.Enqueue(x => l.Add((int)x), 12);

            q.ExecuteAll(ex => { });
            l.IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
            l.Clear();

            q.ExecuteAll(ex => { });
            l.IsCollection(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11);
            l.Clear();

            q.ExecuteAll(ex => { });
            l.Count.Is(0);
        }
开发者ID:ragcat,项目名称:UniRx,代码行数:76,代码来源:UnitTests.cs

示例12: FromEventUnity

 public void FromEventUnity()
 {
     SetScehdulerForImport();
     var tester = new EventTester();
     {
         var list = new List<int>();
         var d = Observable.FromEvent<int>(h => tester.intAction += h, h => tester.intAction -= h)
             .Subscribe(xx =>
             {
                 list.Add(xx);
                 Observable.Return(xx)
                     .Do(x => { if (x == 1) throw new Exception(); })
                     .Subscribe(x => list.Add(x));
             });
         try { tester.Fire(5); } catch { }
         try { tester.Fire(1); } catch { }
         try { tester.Fire(10); } catch { }
         list.IsCollection(5, 5, 1, 10, 10);
         d.Dispose();
         tester.Fire(1000);
         list.Count.Is(5);
     }
     {
         var i = 0;
         var list = new List<int>();
         var d = Observable.FromEvent(h => tester.unitAction += h, h => tester.unitAction -= h)
             .Subscribe(xx =>
             {
                 list.Add(i);
                 Observable.Return(i)
                     .Do(x => { if (x == 1) throw new Exception(); })
                     .Subscribe(x => list.Add(i));
             });
         try { i = 5; tester.Fire(5); } catch { }
         try { i = 1; tester.Fire(1); } catch { }
         try { i = 10; tester.Fire(10); } catch { }
         list.IsCollection(5, 5, 1, 10, 10);
         d.Dispose();
         tester.Fire(1000);
         list.Count.Is(5);
     }
     UniRx.Scheduler.SetDefaultForUnity();
 }
开发者ID:neuecc,项目名称:UniRx,代码行数:43,代码来源:TestImporter.cs

示例13: DoOnTerminate

 public void DoOnTerminate()
 {
     SetScehdulerForImport();
     var list = new List<int>();
     Observable.Empty<int>().DoOnTerminate(() => list.Add(1000)).DefaultIfEmpty().Wait();
     list.IsCollection(1000);
     list.Clear();
     Observable.Range(1, 5).DoOnTerminate(() => list.Add(1000)).Wait();
     list.IsCollection(1000);
     list.Clear();
     Observable.Range(1, 5).Concat(Observable.Throw<int>(new Exception())).DoOnTerminate(() => list.Add(1000)).Subscribe(_ => { }, _ => { }, () => { });
     list.IsCollection(1000);
     UniRx.Scheduler.SetDefaultForUnity();
 }
开发者ID:neuecc,项目名称:UniRx,代码行数:14,代码来源:TestImporter.cs

示例14: ReplaySubject

 public void ReplaySubject()
 {
     SetScehdulerForImport();
     // OnCompletedPattern
     {
         var subject = new ReplaySubject<int>();
         var onNext = new List<int>();
         var exception = new List<Exception>();
         int onCompletedCallCount = 0;
         var _ = subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         subject.OnNext(1);
         subject.OnNext(10);
         subject.OnNext(100);
         subject.OnNext(1000);
         onNext.IsCollection(1, 10, 100, 1000);
         // replay subscription
         onNext.Clear();
         _.Dispose();
         subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         onNext.IsCollection(1, 10, 100, 1000);
         subject.OnCompleted();
         onCompletedCallCount.Is(1);
         subject.OnNext(1);
         subject.OnNext(10);
         subject.OnNext(100);
         onNext.Count.Is(4);
         subject.OnCompleted();
         subject.OnError(new Exception());
         exception.Count.Is(0);
         onCompletedCallCount.Is(1);
         // ++subscription
         onNext.Clear();
         onCompletedCallCount = 0;
         subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         onNext.IsCollection(1, 10, 100, 1000);
         exception.Count.Is(0);
         onCompletedCallCount.Is(1);
     }
     // OnErrorPattern
     {
         var subject = new ReplaySubject<int>();
         var onNext = new List<int>();
         var exception = new List<Exception>();
         int onCompletedCallCount = 0;
         subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         subject.OnNext(1);
         subject.OnNext(10);
         subject.OnNext(100);
         subject.OnNext(1000);
         onNext.IsCollection(1, 10, 100, 1000);
         subject.OnError(new Exception());
         exception.Count.Is(1);
         subject.OnNext(1);
         subject.OnNext(10);
         subject.OnNext(100);
         onNext.Count.Is(4);
         subject.OnCompleted();
         subject.OnError(new Exception());
         exception.Count.Is(1);
         onCompletedCallCount.Is(0);
         // ++subscription
         onNext.Clear();
         exception.Clear();
         onCompletedCallCount = 0;
         subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         onNext.IsCollection(1, 10, 100, 1000);
         exception.Count.Is(1);
         onCompletedCallCount.Is(0);
     }
     UniRx.Scheduler.SetDefaultForUnity();
 }
开发者ID:neuecc,项目名称:UniRx,代码行数:71,代码来源:TestImporter.cs

示例15: AsyncSubjectTest

 public void AsyncSubjectTest()
 {
     SetScehdulerForImport();
     // OnCompletedPattern
     {
         var subject = new AsyncSubject<int>();
         var onNext = new List<int>();
         var exception = new List<Exception>();
         int onCompletedCallCount = 0;
         subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         subject.OnNext(1);
         subject.OnNext(10);
         subject.OnNext(100);
         subject.OnNext(1000);
         onNext.Count.Is(0);
         subject.OnCompleted();
         onNext.IsCollection(1000);
         onCompletedCallCount.Is(1);
         subject.OnNext(1);
         subject.OnNext(10);
         subject.OnNext(100);
         onNext.Count.Is(1);
         subject.OnCompleted();
         subject.OnError(new Exception());
         exception.Count.Is(0);
         onCompletedCallCount.Is(1);
         // ++subscription
         subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         onNext.IsCollection(1000, 1000);
         exception.Count.Is(0);
         onCompletedCallCount.Is(2);
     }
     // OnErrorPattern
     {
         var subject = new AsyncSubject<int>();
         var onNext = new List<int>();
         var exception = new List<Exception>();
         int onCompletedCallCount = 0;
         subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         subject.OnNext(1);
         subject.OnNext(10);
         subject.OnNext(100);
         subject.OnNext(1000);
         onNext.Count.Is(0);
         subject.OnError(new Exception());
         exception.Count.Is(1);
         subject.OnNext(1);
         subject.OnNext(10);
         subject.OnNext(100);
         onNext.Count.Is(0);
         subject.OnCompleted();
         subject.OnError(new Exception());
         exception.Count.Is(1);
         onCompletedCallCount.Is(0);
         // ++subscription
         subject.Subscribe(x => onNext.Add(x), x => exception.Add(x), () => onCompletedCallCount++);
         onNext.Count.Is(0);
         exception.Count.Is(2);
         onCompletedCallCount.Is(0);
     }
     UniRx.Scheduler.SetDefaultForUnity();
 }
开发者ID:neuecc,项目名称:UniRx,代码行数:62,代码来源:TestImporter.cs


注:本文中的Microsoft.VisualStudio.TestTools.UnitTesting.List.IsCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。