示例#1
0
        private int IteratorCompareTo(IComparer <AnyValue> comparator, ListValue otherList)
        {
            IEnumerator <AnyValue> thisIterator = Iterator();
            IEnumerator <AnyValue> thatIterator = otherList.GetEnumerator();

            while (thisIterator.MoveNext())
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                if (!thatIterator.hasNext())
                {
                    return(1);
                }
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                int compare = comparator.Compare(thisIterator.Current, thatIterator.next());
                if (compare != 0)
                {
                    return(compare);
                }
            }
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            if (thatIterator.hasNext())
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
示例#2
0
 private void AssertListValuesEquals(ListValue appended, ListValue expected)
 {
     assertEquals(expected, appended);
     assertEquals(expected.GetHashCode(), appended.GetHashCode());
     assertArrayEquals(expected.AsArray(), appended.AsArray());
     assertTrue(iteratorsEqual(expected.GetEnumerator(), appended.GetEnumerator()));
 }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnEmptyListIfEmptyRange()
        internal virtual void ShouldReturnEmptyListIfEmptyRange()
        {
            // Given
            ListValue inner = list(longValue(5L), longValue(6L), longValue(7L), longValue(8L), longValue(9L), longValue(10L), longValue(11L));

            // When
            ListValue slice = inner.Slice(4, 2);

            // Then
            assertEquals(slice, EMPTY_LIST);
            assertTrue(iteratorsEqual(slice.GetEnumerator(), EMPTY_LIST.GetEnumerator()));
        }
示例#4
0
            public override IEnumerator <AnyValue> Iterator()
            {
                switch (Base.iterationPreference())
                {
                case RANDOM_ACCESS:
                    return(base.GetEnumerator());

                case ITERATION:
                    return(Iterators.prependTo(Base.GetEnumerator(), Prepended));

                default:
                    throw new System.InvalidOperationException("unknown iteration preference");
                }
            }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleNegativeStart()
        internal virtual void ShouldHandleNegativeStart()
        {
            // Given
            ListValue inner = list(longValue(5L), longValue(6L), longValue(7L), longValue(8L), longValue(9L), longValue(10L), longValue(11L));

            // When
            ListValue slice = inner.Slice(-2, 400000);

            // Then
            assertEquals(inner, slice);
            assertEquals(inner.GetHashCode(), slice.GetHashCode());
            assertArrayEquals(inner.AsArray(), slice.AsArray());
            assertTrue(iteratorsEqual(inner.GetEnumerator(), slice.GetEnumerator()));
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleExceedingRange()
        internal virtual void ShouldHandleExceedingRange()
        {
            // Given
            ListValue inner = list(longValue(5L), longValue(6L), longValue(7L), longValue(8L), longValue(9L), longValue(10L), longValue(11L));

            // When
            ListValue slice = inner.Slice(2, 400000);

            // Then
            ListValue expected = list(longValue(7L), longValue(8L), longValue(9L), longValue(10L), longValue(11L));

            assertEquals(expected, slice);
            assertEquals(expected.GetHashCode(), slice.GetHashCode());
            assertArrayEquals(expected.AsArray(), slice.AsArray());
            assertTrue(iteratorsEqual(expected.GetEnumerator(), slice.GetEnumerator()));
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldBeAbleToTakeFromList()
        internal virtual void ShouldBeAbleToTakeFromList()
        {
            // Given
            ListValue inner = list(longValue(5L), longValue(6L), longValue(7L), longValue(8L), longValue(9L), longValue(10L), longValue(11L));

            // When
            ListValue take = inner.Take(3);

            // Then
            ListValue expected = list(longValue(5L), longValue(6L), longValue(7L));

            assertEquals(expected, take);
            assertEquals(expected.GetHashCode(), take.GetHashCode());
            assertArrayEquals(expected.AsArray(), take.AsArray());
            assertTrue(iteratorsEqual(expected.GetEnumerator(), take.GetEnumerator()));
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldBeAbleToDropFromList()
        internal virtual void ShouldBeAbleToDropFromList()
        {
            // Given
            ListValue inner = list(longValue(5L), longValue(6L), longValue(7L), longValue(8L), longValue(9L), longValue(10L), longValue(11L));

            // When
            ListValue drop = inner.Drop(4);

            // Then
            ListValue expected = list(longValue(9L), longValue(10L), longValue(11L));

            assertEquals(expected, drop);
            assertEquals(expected.GetHashCode(), drop.GetHashCode());
            assertArrayEquals(expected.AsArray(), drop.AsArray());
            assertTrue(iteratorsEqual(expected.GetEnumerator(), drop.GetEnumerator()));
        }