Example #1
0
 internal TransactionLogFiles(File logsDirectory, string name, TransactionLogFilesContext context)
 {
     this._logFilesContext    = context;
     this._logsDirectory      = logsDirectory;
     this._fileHelper         = new TransactionLogFilesHelper(logsDirectory, name);
     this._fileSystem         = context.FileSystem;
     this._monitor            = context.LogFileCreationMonitor;
     this._logHeaderCache     = new LogHeaderCache(1000);
     this._logFileInformation = new TransactionLogFileInformation(this, _logHeaderCache, context);
     this._logFile            = new TransactionLogFile(this, context);
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadFirstCommittedTransactionIdForAGivenVersionWhenCached() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadFirstCommittedTransactionIdForAGivenVersionWhenCached()
        {
            TransactionLogFileInformation info = new TransactionLogFileInformation(_logFiles, _logHeaderCache, _context);
            long expected = 5;

            long version = 10L;

            when(_logHeaderCache.getLogHeader(version)).thenReturn(expected - 1);

            long firstCommittedTxId = info.GetFirstEntryId(version);

            assertEquals(expected, firstCommittedTxId);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnNothingWhenThereAreNoTransactions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnNothingWhenThereAreNoTransactions()
        {
            TransactionLogFileInformation info = new TransactionLogFileInformation(_logFiles, _logHeaderCache, _context);

            long version = 10L;

            when(_logFiles.HighestLogVersion).thenReturn(version);
            when(_logFiles.hasAnyEntries(version)).thenReturn(false);

            long firstCommittedTxId = info.FirstExistingEntryId;

            assertEquals(-1, firstCommittedTxId);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadFirstCommittedTransactionIdWhenCached() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadFirstCommittedTransactionIdWhenCached()
        {
            TransactionLogFileInformation info = new TransactionLogFileInformation(_logFiles, _logHeaderCache, _context);
            long expected = 5;

            long version = 10L;

            when(_logFiles.HighestLogVersion).thenReturn(version);
            when(_logFiles.versionExists(version)).thenReturn(true);
            when(_logHeaderCache.getLogHeader(version)).thenReturn(expected - 1);
            when(_logFiles.hasAnyEntries(version)).thenReturn(true);

            long firstCommittedTxId = info.FirstExistingEntryId;

            assertEquals(expected, firstCommittedTxId);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadAndCacheFirstCommittedTransactionIdForAGivenVersionWhenNotCached() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadAndCacheFirstCommittedTransactionIdForAGivenVersionWhenNotCached()
        {
            TransactionLogFileInformation info = new TransactionLogFileInformation(_logFiles, _logHeaderCache, _context);
            long expected = 5;

            long version = 10L;

            when(_logHeaderCache.getLogHeader(version)).thenReturn(null);
            when(_logFiles.versionExists(version)).thenReturn(true);
            when(_logFiles.extractHeader(version)).thenReturn(new LogHeader((sbyte)-1, -1L, expected - 1L)
                                                              );

            long firstCommittedTxId = info.GetFirstEntryId(version);

            assertEquals(expected, firstCommittedTxId);
            verify(_logHeaderCache, times(1)).putHeader(version, expected - 1);
        }