//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly() { // GIVEN TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore)); TransactionAppender appender = new TestableTransactionAppender(transactionIdStore); long txId = 11; when(transactionIdStore.NextCommittingTransactionId()).thenReturn(txId); IOException rootCause = new IOException("Mock exception"); StorageEngine storageEngine = mock(typeof(StorageEngine)); doThrow(new IOException(rootCause)).when(storageEngine).apply(any(typeof(TransactionToApply)), any(typeof(TransactionApplicationMode))); TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine); TransactionToApply transaction = MockedTransaction(); // WHEN try { commitProcess.Commit(transaction, _commitEvent, INTERNAL); } catch (TransactionFailureException e) { assertThat(e.Message, containsString("Could not apply the transaction to the store")); assertTrue(contains(e, rootCause.Message, rootCause.GetType())); } // THEN // we can't verify transactionCommitted since that's part of the TransactionAppender, which we have mocked verify(transactionIdStore, times(1)).transactionClosed(eq(txId), anyLong(), anyLong()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSuccessfullyCommitTransactionWithNoCommands() { // GIVEN long txId = 11; long commitTimestamp = DateTimeHelper.CurrentUnixTimeMillis(); TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore)); TransactionAppender appender = new TestableTransactionAppender(transactionIdStore); when(transactionIdStore.NextCommittingTransactionId()).thenReturn(txId); StorageEngine storageEngine = mock(typeof(StorageEngine)); TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine); PhysicalTransactionRepresentation noCommandTx = new PhysicalTransactionRepresentation(Collections.emptyList()); noCommandTx.SetHeader(new sbyte[0], -1, -1, -1, -1, -1, -1); // WHEN commitProcess.Commit(new TransactionToApply(noCommandTx), _commitEvent, INTERNAL); verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP); }