Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportCorrectCount() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReportCorrectCount()
        {
            using (IndexKeyStorage <GenericKey> keyStorage = keyStorage())
            {
                assertEquals(0, keyStorage.count());
                keyStorage.add(RandomKey(1));
                assertEquals(1, keyStorage.count());
                keyStorage.add(RandomKey(2));
                assertEquals(2, keyStorage.count());
                keyStorage.doneAdding();
                assertEquals(2, keyStorage.count());
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAddAndReadMultipleKeys() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldAddAndReadMultipleKeys()
        {
            IList <GenericKey> keys = new List <GenericKey>();
            int numberOfKeys        = 1000;

            for (int i = 0; i < numberOfKeys; i++)
            {
                keys.Add(RandomKey(i));
            }
            using (IndexKeyStorage <GenericKey> keyStorage = keyStorage())
            {
                foreach (GenericKey key in keys)
                {
                    keyStorage.add(key);
                }
                keyStorage.doneAdding();
                using (IndexKeyStorage.KeyEntryCursor <GenericKey> reader = keyStorage.reader())
                {
                    foreach (GenericKey expected in keys)
                    {
                        assertTrue(reader.Next());
                        GenericKey actual = reader.Key();
                        assertEquals(0, _layout.compare(expected, actual), "Expected stored key to be equal to original.");
                    }
                    assertFalse(reader.Next(), "Expected reader to have no more entries, but had at least one additional " + reader.Key());
                }
            }
        }
Ejemplo n.º 3
0
 internal override void DoReportConflict(long existingNodeId, long addedNodeId, KEY conflictingKey)
 {
     try
     {
         AllConflictingKeys.add(conflictingKey);
     }
     catch (IOException e)
     {
         throw new UncheckedIOException(e);
     }
 }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldDeleteFileOnCloseWithDataBeforeDoneAdding() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldDeleteFileOnCloseWithDataBeforeDoneAdding()
        {
            FileSystemAbstraction fs = Directory.FileSystem;
            File makeSureImDeleted   = Directory.file("makeSureImDeleted");

            using (IndexKeyStorage <GenericKey> keyStorage = keyStorage(makeSureImDeleted))
            {
                keyStorage.add(RandomKey(1));
                assertTrue(fs.FileExists(makeSureImDeleted), "Expected this file to exist now so that we can assert deletion later.");
            }
            assertFalse(fs.FileExists(makeSureImDeleted), "Expected this file to be deleted on close.");
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAddAndReadOneKey() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldAddAndReadOneKey()
        {
            using (IndexKeyStorage <GenericKey> keyStorage = keyStorage())
            {
                GenericKey expected = RandomKey(1);
                keyStorage.add(expected);
                keyStorage.doneAdding();
                using (IndexKeyStorage.KeyEntryCursor <GenericKey> reader = keyStorage.reader())
                {
                    assertTrue(reader.Next(), "Expected reader to have one entry");
                    GenericKey actual = reader.Key();
                    assertEquals(0, _layout.compare(expected, actual), "Expected stored key to be equal to original.");
                    assertFalse(reader.Next(), "Expected reader to have only one entry, second entry was " + reader.Key());
                }
            }
        }