Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseUnexhaustedCursorsOnReaderClose() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCloseUnexhaustedCursorsOnReaderClose()
        {
            // GIVEN
            GBPTree <LabelScanKey, LabelScanValue> index = mock(typeof(GBPTree));
            RawCursor <Hit <LabelScanKey, LabelScanValue>, IOException> cursor1 = mock(typeof(RawCursor));

            when(cursor1.Next()).thenReturn(false);
            RawCursor <Hit <LabelScanKey, LabelScanValue>, IOException> cursor2 = mock(typeof(RawCursor));

            when(cursor2.Next()).thenReturn(false);
            when(index.Seek(any(typeof(LabelScanKey)), any(typeof(LabelScanKey)))).thenReturn(cursor1, cursor2);

            // WHEN
            using (NativeLabelScanReader reader = new NativeLabelScanReader(index))
            {
                // first check test invariants
                reader.NodesWithLabel(LABEL_ID);
                reader.NodesWithLabel(LABEL_ID);
                verify(cursor1, never()).close();
                verify(cursor2, never()).close();
            }

            // THEN
            verify(cursor1, times(1)).close();
            verify(cursor2, times(1)).close();
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSupportMultipleOpenCursorsConcurrently() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSupportMultipleOpenCursorsConcurrently()
        {
            // GIVEN
            GBPTree <LabelScanKey, LabelScanValue> index = mock(typeof(GBPTree));
            RawCursor <Hit <LabelScanKey, LabelScanValue>, IOException> cursor1 = mock(typeof(RawCursor));

            when(cursor1.Next()).thenReturn(false);
            RawCursor <Hit <LabelScanKey, LabelScanValue>, IOException> cursor2 = mock(typeof(RawCursor));

            when(cursor2.Next()).thenReturn(false);
            when(index.Seek(any(typeof(LabelScanKey)), any(typeof(LabelScanKey)))).thenReturn(cursor1, cursor2);

            // WHEN
            using (NativeLabelScanReader reader = new NativeLabelScanReader(index))
            {
                // first check test invariants
                verify(cursor1, never()).close();
                verify(cursor2, never()).close();
                LongIterator first  = reader.NodesWithLabel(LABEL_ID);
                LongIterator second = reader.NodesWithLabel(LABEL_ID);

                // getting the second iterator should not have closed the first one
                verify(cursor1, never()).close();
                verify(cursor2, never()).close();

                // exhausting the first one should have closed only the first one
                Exhaust(first);
                verify(cursor1, times(1)).close();
                verify(cursor2, never()).close();

                // exhausting the second one should close it
                Exhaust(second);
                verify(cursor1, times(1)).close();
                verify(cursor2, times(1)).close();
            }
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void shouldFindMultipleNodesInEachRange() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFindMultipleNodesInEachRange()
        {
            // GIVEN
            GBPTree <LabelScanKey, LabelScanValue> index = mock(typeof(GBPTree));
            RawCursor <Hit <LabelScanKey, LabelScanValue>, IOException> cursor = mock(typeof(RawCursor));

            when(cursor.Next()).thenReturn(true, true, true, false);
            when(cursor.get()).thenReturn(Hit(0, 0b1000_1000__1100_0010L), Hit(1, 0b0000_0010__0000_1000L), Hit(3, 0b0010_0000__1010_0001L), null);
            when(index.Seek(any(typeof(LabelScanKey)), any(typeof(LabelScanKey)))).thenReturn(cursor);
            using (NativeLabelScanReader reader = new NativeLabelScanReader(index))
            {
                // WHEN
                LongIterator iterator = reader.NodesWithLabel(LABEL_ID);

                // THEN
                assertArrayEquals(new long[] { 1, 6, 7, 11, 15, 64 + 3, 64 + 9, 192 + 0, 192 + 5, 192 + 7, 192 + 13 }, asArray(iterator));
            }
        }