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


C# List.Is方法代码示例

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


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

示例1: UseObserverTest1

 public void UseObserverTest1()
 {
     var subject = new Subject<string>();
     var result = new List<Tuple<int, string>>();
     subject
         .Select(x => new Tuple<int, string>(0, x))
         .UseObserver((observer, value, i) =>
         {
             observer.OnNext(new Tuple<int, string>(i, value.Item2));
         },
         null,
         observer =>
         {
             observer.OnNext(new Tuple<int, string>(-1, "end"));
         })
         .Subscribe(result.Add);
     subject.OnNext("a");
     subject.OnNext("b");
     subject.OnNext("c");
     subject.OnCompleted();
     result.Is(
         new Tuple<int, string>(0, "a"),
         new Tuple<int, string>(1, "b"),
         new Tuple<int, string>(2, "c"),
         new Tuple<int, string>(-1, "end"));
 }
开发者ID:syo00,项目名称:LightWands,代码行数:26,代码来源:ObservableExtensionsTest.cs

示例2: NoDistinctUntilChanged

 public void NoDistinctUntilChanged()
 {
     var rp = new ReactiveProperty<string>(mode: ReactivePropertyMode.RaiseLatestValueOnSubscribe);
     var list = new List<string>();
     rp.Subscribe(list.Add);
     rp.Value = "Hello world";
     rp.Value = "Hello world";
     rp.Value = "Hello japan";
     list.Is(null, "Hello world", "Hello world", "Hello japan");
 }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:10,代码来源:ReactivePropertyTest.cs

示例3: ForEachAsyncTest2

 public async Task ForEachAsyncTest2()
 {
     var result = new List<int>();
     await new[] { 3, 1, 2, 0 }.ForEachAsync(async (i, index) =>
         {
             result.Add(index);
             result.Add(await PseudoSlowWork(i));
         });
     result.Is(0, 3, 1, 1, 2, 2, 3, 0);
 }
开发者ID:syo00,项目名称:LightWands,代码行数:10,代码来源:EnumerableExtensionsTest.cs

示例4: Async

        public async Task Async()
        {
            var mb = new AsyncMessageBroker();
            var l = new List<string>();

            var d1 = mb.Subscribe<int>(async x => l.Add("a:" + x));
            var d2 = mb.Subscribe<int>(async x => l.Add("b:" + x));

            await mb.PublishAsync(100);
            l.Is("a:100", "b:100"); l.Clear();

            d2.Dispose();
            await mb.PublishAsync(200);
            l.Is("a:200"); l.Clear();

            d1.Dispose();
            await mb.PublishAsync(300);
            l.Count.Is(0);
        }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:19,代码来源:MessageBrokerTest.cs

示例5: 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.Is(1, 2, 3);
        }
开发者ID:MighteeCactus,项目名称:UniRx,代码行数:14,代码来源:ConversionTest.cs

示例6: MultiSubscribeTest

        public void MultiSubscribeTest()
        {
            var s = new Subject<string>();

            var rp = s.ToReadOnlyReactiveProperty();
            var buffer1 = new List<string>();
            rp.Subscribe(buffer1.Add);


            buffer1.Count.Is(1);
            s.OnNext("Hello world");
            buffer1.Count.Is(2);
            buffer1.Is(default(string), "Hello world");

            var buffer2 = new List<string>();
            rp.Subscribe(buffer2.Add);
            buffer1.Is(default(string), "Hello world");
            buffer2.Is("Hello world");

            s.OnNext("ReactiveProperty");
            buffer1.Is(default(string), "Hello world", "ReactiveProperty");
            buffer2.Is("Hello world", "ReactiveProperty");
        }
开发者ID:wada811,项目名称:ReactiveProperty,代码行数:23,代码来源:ReadOnlyReactivePropertyTest.cs

示例7: Sync

        public void Sync()
        {
            var mb = new MessageBroker();
            var l = new List<string>();

            var d1 = mb.Subscribe<int>(x => l.Add("a:" + x));
            var d2 = mb.Subscribe<int>(x => l.Add("b:" + x));
            var d3 = mb.ToObservable<int>().Subscribe(x => l.Add("c:" + x));

            mb.Publish(100);
            l.Is("a:100", "b:100", "c:100"); l.Clear();

            d2.Dispose();
            mb.Publish(200);
            l.Is("a:200", "c:200"); l.Clear();

            d3.Dispose();
            mb.Publish(300);
            l.Is("a:300"); l.Clear();

            d1.Dispose();
            mb.Publish(400);
            l.Count.Is(0);
        }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:24,代码来源:MessageBrokerTest.cs

示例8: NormalPattern

        public void NormalPattern()
        {
            var s = new Subject<string>();

            var rp = s.ToReadOnlyReactiveProperty(eventScheduler: Scheduler.CurrentThread);
            var buffer = new List<string>();
            rp.Subscribe(buffer.Add);

            rp.Value.IsNull();
            buffer.Count.Is(1);
            buffer[0].IsNull();

            s.OnNext("Hello");
            rp.Value.Is("Hello");
            buffer.Count.Is(2);
            buffer.Is(default(string), "Hello");

            s.OnNext("Hello");
            rp.Value.Is("Hello");
            buffer.Count.Is(2); // distinct until changed.
        }
开发者ID:wada811,项目名称:ReactiveProperty,代码行数:21,代码来源:ReadOnlyReactivePropertyTest.cs

示例9: 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.Is("one", "after 1", "after 3");
        }
开发者ID:gameserver,项目名称:UniRx,代码行数:22,代码来源:SchedulerTest.cs

示例10: NormalPatternNoDistinctUntilChanged

        public void NormalPatternNoDistinctUntilChanged()
        {
            var s = new Subject<string>();

            var rp = s.ToReadOnlyReactiveProperty(
                mode: ReactivePropertyMode.RaiseLatestValueOnSubscribe,
                eventScheduler: Scheduler.CurrentThread);
            var buffer = new List<string>();
            rp.Subscribe(buffer.Add);

            rp.Value.IsNull();
            buffer.Count.Is(1);
            buffer[0].IsNull();

            s.OnNext("Hello");
            rp.Value.Is("Hello");
            buffer.Count.Is(2);
            buffer.Is(default(string), "Hello");

            s.OnNext("Hello");
            rp.Value.Is("Hello");
            buffer.Count.Is(3); // not distinct until changed.
        }
开发者ID:wada811,项目名称:ReactiveProperty,代码行数:23,代码来源:ReadOnlyReactivePropertyTest.cs

示例11: UseObserverTest2

 public void UseObserverTest2()
 {
     var subject = new Subject<string>();
     var result = new List<string>();
     subject
         .UseObserver((observer, value, i) =>
         {
             observer.OnNext(value);
         },
         (error, observer) =>
         {
             observer.OnNext(error.Message);
         },
         observer =>
         {
             observer.OnNext("end");
         })
         .Subscribe(result.Add);
     subject.OnNext("a");
     subject.OnError(new Exception("error!"));
     subject.OnCompleted();
     result.Is("a", "error!");
 }
开发者ID:syo00,项目名称:LightWands,代码行数:23,代码来源:ObservableExtensionsTest.cs

示例12: 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.Is("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.Is("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:gameserver,项目名称:UniRx,代码行数:36,代码来源:Observable.GeneratorTest.cs

示例13: Select

        public void Select()
        {
            {
                var a = new Subject<int>();

                var list = new List<int>();
                a.Select(x => x * x).Subscribe(x => list.Add(x));

                a.OnNext(100);
                a.OnNext(200);
                a.OnNext(300);
                a.OnCompleted();

                list.Count.Is(3);
                list.Is(10000, 40000, 90000);
            }
            {
                var a = new Subject<int>();

                var list = new List<int>();
                a.Select((x, i) => x * i).Subscribe(x => list.Add(x));

                a.OnNext(100);
                a.OnNext(200);
                a.OnNext(300);
                a.OnCompleted();

                list.Count.Is(3);
                list.Is(0, 200, 600);
            }
            {
                var a = new Subject<int>();

                var list = new List<int>();
                a.Select(x => x * x).Select(x => x * x).Subscribe(x => list.Add(x));

                a.OnNext(2);
                a.OnNext(4);
                a.OnNext(8);
                a.OnCompleted();

                list.Count.Is(3);
                list.Is(16, 256, 4096);
            }
            {
                var a = new Subject<int>();

                var list = new List<int>();
                a.Select((x, i) => x * i).Select(x => x * 10).Subscribe(x => list.Add(x));

                a.OnNext(100);
                a.OnNext(200);
                a.OnNext(300);
                a.OnCompleted();

                list.Count.Is(3);
                list.Is(0, 2000, 6000);
            }
        }
开发者ID:nicecapj,项目名称:UniRx,代码行数:59,代码来源:ObservableTest.cs

示例14: ForceNotify

        public void ForceNotify()
        {
            var rp = new ReactiveProperty<int>(0);
            var collecter = new List<int>();
            rp.Subscribe(collecter.Add);

            collecter.Is(0);
            rp.ForceNotify();
            collecter.Is(0, 0);
        }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:10,代码来源:ReactivePropertyTest.cs

示例15: 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.Is("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.Is("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.Is("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.Is("OnNext(200)", "OnNext(300)");

                a.OnCompleted();

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


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