예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPruneAndOpenExistingDatabase() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPruneAndOpenExistingDatabase()
        {
            // given
            foreach (StoreType typeToTest in RelevantRecordStores())
            {
                // given all the stores with some records in them
                using (PageCache pageCache = Storage.pageCache())
                {
                    Storage.directory().cleanup();
                    using (BatchingNeoStores stores = BatchingNeoStores.BatchingNeoStoresWithExternalPageCache(Storage.fileSystem(), pageCache, PageCacheTracer.NULL, Storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.Instance, EMPTY, Config.defaults()))
                    {
                        stores.CreateNew();
                        foreach (StoreType type in RelevantRecordStores())
                        {
                            CreateRecordIn(stores.NeoStores.getRecordStore(type));
                        }
                    }

                    // when opening and pruning all except the one we test
                    using (BatchingNeoStores stores = BatchingNeoStores.BatchingNeoStoresWithExternalPageCache(Storage.fileSystem(), pageCache, PageCacheTracer.NULL, Storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.Instance, EMPTY, Config.defaults()))
                    {
                        stores.PruneAndOpenExistingStore(type => type == typeToTest, Predicates.alwaysFalse());

                        // then only the one we kept should have data in it
                        foreach (StoreType type in RelevantRecordStores())
                        {
                            RecordStore <AbstractBaseRecord> store = stores.NeoStores.getRecordStore(type);
                            if (type == typeToTest)
                            {
                                assertThat(store.ToString(), (int)store.HighId, greaterThan(store.NumberOfReservedLowIds));
                            }
                            else
                            {
                                assertEquals(store.ToString(), store.NumberOfReservedLowIds, store.HighId);
                            }
                        }
                    }
                }
            }
        }