示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testMultiIterator()
        internal virtual void TestMultiIterator()
        {
            FirstItemIterable <bool> firstItemIterable = new FirstItemIterable <bool>(asList(true, false));
            IEnumerator <bool>       empty             = firstItemIterable.GetEnumerator();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertTrue(empty.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(true, empty.next());
            assertEquals(true, firstItemIterable.First);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertTrue(empty.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(false, empty.next());
            assertEquals(true, firstItemIterable.First);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(empty.hasNext());
            try
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                empty.next();
                fail("Exception expected");
            }
            catch (Exception e)
            {
                assertThat(e, instanceOf(typeof(NoSuchElementException)));
            }
            assertEquals(true, firstItemIterable.First);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testEmptyIterator()
        internal virtual void TestEmptyIterator()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: FirstItemIterable<?> firstItemIterable = new FirstItemIterable<>(java.util.Collections.emptyList());
            FirstItemIterable <object> firstItemIterable = new FirstItemIterable <object>(Collections.emptyList());
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Iterator<?> empty = firstItemIterable.iterator();
            IEnumerator <object> empty = firstItemIterable.GetEnumerator();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(empty.hasNext());
            try
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                empty.next();
                fail("Exception expected");
            }
            catch (Exception e)
            {
                assertThat(e, instanceOf(typeof(NoSuchElementException)));
            }
            assertNull(firstItemIterable.First);
        }
示例#3
0
 public IteratorAnonymousInnerClass(FirstItemIterable <T> outerInstance)
 {
     this.outerInstance = outerInstance;
 }