Exemple #1
0
            public void Run1()
            {
                TestEvent one   = default;
                TestEvent two   = default;
                TestEvent three = default;
                TestEvent four  = default;

                one = new TestEvent(1, () =>
                {
                    if (two == null)
                    {
                        ev.Add(two = new TestEvent(2));
                    }
                    else if (three == null)
                    {
                        ev.Add(three = new TestEvent(3));
                    }
                    else if (four == null)
                    {
                        ev.Add(four = new TestEvent(4));
                    }
                });

                ev.Add(one);

                ev.SetResult(10);
                ev.SetResult(20);
                ev.SetResult(30);
                ev.SetResult(40);

                one.NextCalled.Should().BeEquivalentTo(10, 20, 30, 40);
                two.NextCalled.Should().BeEquivalentTo(20, 30, 40);
                three.NextCalled.Should().BeEquivalentTo(30, 40);
                four.NextCalled.Should().BeEquivalentTo(40);
            }
Exemple #2
0
        public void SimpleAdd()
        {
            var ev = new TriggerEvent <int>();

            // do nothing
            ev.SetResult(0);
            ev.SetError(null);
            ev.SetCompleted();
            ev.SetCanceled(default);
Exemple #3
0
            public void Run1()
            {
                TestEvent one   = default;
                TestEvent two   = default;
                TestEvent three = default;
                TestEvent four  = default;

                one   = new TestEvent(1, () => { ev.Remove(two); ev.Remove(three); });
                two   = new TestEvent(2);
                three = new TestEvent(3);
                four  = new TestEvent(4);

                ev.Add(one);
                ev.Add(two);
                ev.Add(three);
                ev.Add(four);

                ev.SetResult(10);
                ev.SetResult(20);
                ev.SetResult(30);

                one.NextCalled.Should().BeEquivalentTo(10, 20, 30);
                two.NextCalled.Count.Should().Be(0);
                three.NextCalled.Count.Should().Be(0);
                four.NextCalled.Should().BeEquivalentTo(10, 20, 30);
            }
Exemple #4
0
            public void Run1()
            {
                TestEvent one = default;

                one = new TestEvent(1, () => ev.Remove(one));

                var two   = new TestEvent(2);
                var three = new TestEvent(3);

                ev.Add(one);
                ev.Add(two);
                ev.Add(three);

                ev.SetResult(10);
                ev.SetResult(20);
                ev.SetResult(30);

                one.NextCalled.Should().BeEquivalentTo(10);
                two.NextCalled.Should().BeEquivalentTo(10, 20, 30);
                three.NextCalled.Should().BeEquivalentTo(10, 20, 30);
            }
            public void Run1()
            {
                TestEvent one   = default;
                TestEvent two   = default;
                TestEvent three = default;

                one   = new TestEvent(1, () => ev.Remove(two));
                two   = new TestEvent(2);
                three = new TestEvent(3);

                ev.Add(one);
                ev.Add(two);
                ev.Add(three);

                ev.SetResult(10);
                ev.SetResult(20);
                ev.SetResult(30);

                one.NextCalled.Should().Equal(10, 20, 30);
                two.NextCalled.Count.Should().Be(0);
                three.NextCalled.Should().Equal(10, 20, 30);
            }
Exemple #6
0
        async UniTaskVoid ConsumeEnumerator(IUniTaskAsyncEnumerable <T> source, CancellationToken cancellationToken)
        {
            enumerator = source.GetAsyncEnumerator(cancellationToken);
            try {
                while (await enumerator.MoveNextAsync())
                {
                    var value = enumerator.Current;
                    this.latestValue = value;
                    triggerEvent.SetResult(value);
                }
            }
            finally {
                await enumerator.DisposeAsync();

                enumerator = null;
            }
        }