예제 #1
0
        public void Iterators_Concatenation_ForwardsProperly()
        {
            var inputs = new[]
            {
                new MockedIterator(new object[] { 1, 2 }),
                new MockedIterator(new object[] { 3, 4 }),
                new MockedIterator(new object[] { 5, 6 })
            };

            var entries = new[]
            {
                ImmutableArray.Create(new RowBufferEntry(inputs[0].RowBuffer, 0)),
                ImmutableArray.Create(new RowBufferEntry(inputs[1].RowBuffer, 0)),
                ImmutableArray.Create(new RowBufferEntry(inputs[2].RowBuffer, 0))
            };

            var expected = new object[] { 1, 2, 3, 4, 5, 6 };

            using (var iterator = new ConcatenationIterator(inputs, entries))
            {
                for (var i = 0; i < 2; i++)
                {
                    AssertProduces(iterator, expected);
                }
            }

            foreach (var input in inputs)
            {
                Assert.Equal(2, input.TotalOpenCount);
                Assert.Equal(4, input.TotalReadCount);
                Assert.Equal(1, input.DisposalCount);
            }
        }
        public virtual void TestIterator()
        {
            ICollection <string> c1 = Collections.Singleton("a");
            ICollection <string> c2 = Java.Util.Collections.Singleton("b");
            IEnumerator <string> i  = new ConcatenationIterator <string>(c1.GetEnumerator(), c2.GetEnumerator());

            NUnit.Framework.Assert.AreEqual("a", i.Current);
            NUnit.Framework.Assert.AreEqual("b", i.Current);
            NUnit.Framework.Assert.IsFalse(i.MoveNext());
        }
예제 #3
0
        public void Iterators_Concatenation_ReturnsEmpty_IfAllEmpty()
        {
            var inputs = new[]
            {
                new MockedIterator(new object[0]),
                new MockedIterator(new object[0])
            };

            var entries = inputs.Select(i => ImmutableArray <RowBufferEntry> .Empty);

            using (var iterator = new ConcatenationIterator(inputs, entries))
            {
                AssertEmpty(iterator);
            }
        }
예제 #4
0
        public void Iterators_Concatenation_SkipsEmpty()
        {
            var inputs = new[]
            {
                new MockedIterator(new object[0]),
                new MockedIterator(new object[] { 5, 6 })
            };

            var expected = new object[] { 5, 6 };

            var entries = inputs.Select(i => ImmutableArray.Create(new RowBufferEntry(i.RowBuffer, 0)));

            using (var iterator = new ConcatenationIterator(inputs, entries))
            {
                AssertProduces(iterator, expected);
            }
        }