//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMandateTransactionsForUsingIterator()
        public virtual void ShouldMandateTransactionsForUsingIterator()
        {
            using (ResourceIterator <Node> iterator = _indexHits.GetEnumerator())
            {
                try
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    iterator.hasNext();

                    fail("Transactions are mandatory, also for reads");
                }
                catch (NotInTransactionException)
                {                         // Expected
                }

                try
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    iterator.next();

                    fail("Transactions are mandatory, also for reads");
                }
                catch (NotInTransactionException)
                {                         // Expected
                }
            }
        }
예제 #2
0
        public override bool MatchesSafely(IndexHits <T> indexHits)
        {
            ICollection <T> collection = Iterators.asCollection(indexHits.GetEnumerator());

            if (_expectedItems.Length != collection.Count)
            {
                _message  = "IndexHits with a size of " + _expectedItems.Length + ", got one with " + collection.Count;
                _message += collection.ToString();
                return(false);
            }

            foreach (T item in _expectedItems)
            {
                if (!collection.Contains(item))
                {
                    _message = "Item (" + item + ") not found.";
                    return(false);
                }
            }
            return(true);
        }