Exemplo n.º 1
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());
                }
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAddAndReadZeroKey() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldAddAndReadZeroKey()
        {
            using (IndexKeyStorage <GenericKey> keyStorage = keyStorage())
            {
                keyStorage.doneAdding();
                using (IndexKeyStorage.KeyEntryCursor <GenericKey> reader = keyStorage.reader())
                {
                    assertFalse(reader.Next(), "Didn't expect reader to have any entries.");
                }
            }
        }
Exemplo n.º 3
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.");
        }
Exemplo n.º 4
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());
            }
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotCreateFileIfNoData() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldNotCreateFileIfNoData()
        {
            FileSystemAbstraction fs = Directory.FileSystem;
            File makeSureImDeleted   = Directory.file("makeSureImDeleted");

            using (IndexKeyStorage <GenericKey> keyStorage = keyStorage(makeSureImDeleted))
            {
                assertFalse(fs.FileExists(makeSureImDeleted), "Expected this file to exist now so that we can assert deletion later.");
                keyStorage.doneAdding();
                assertFalse(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.");
        }
Exemplo n.º 6
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());
                }
            }
        }
Exemplo n.º 7
0
 internal RecordingConflictDetector(bool compareEntityIds, IndexKeyStorage <KEY> indexKeyStorage) : base(compareEntityIds)
 {
     AllConflictingKeys = indexKeyStorage;
 }