Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenGettingTxAfterTermination()
        public virtual void ShouldThrowWhenGettingTxAfterTermination()
        {
            MutableObject <Status> terminationReason = new MutableObject <Status>();
            InternalTransaction    tx = mock(typeof(InternalTransaction));

            doAnswer(invocation =>
            {
                terminationReason.Value = Status.Transaction.Terminated;
                return(null);
            }).when(tx).terminate();
            when(tx.TerminationReason()).then(invocation => Optional.ofNullable(terminationReason.Value));

            Neo4jTransactionalContext context = NewContext(tx);

            context.Terminate();

            try
            {
                context.OrBeginNewIfClosed;
                fail("Exception expected");
            }
            catch (Exception e)
            {
                assertThat(e, instanceOf(typeof(TransactionTerminatedException)));
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBePossibleToTerminateWithoutActiveTransaction()
        public virtual void ShouldBePossibleToTerminateWithoutActiveTransaction()
        {
            InternalTransaction       tx      = mock(typeof(InternalTransaction));
            Neo4jTransactionalContext context = NewContext(tx);

            context.Close(true);
            verify(tx).success();
            verify(tx).close();

            context.Terminate();
            verify(tx, never()).terminate();
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCloseTransactionDuringTermination()
        public virtual void ShouldNotCloseTransactionDuringTermination()
        {
            InternalTransaction tx = mock(typeof(InternalTransaction));

            when(tx.TransactionType()).thenReturn(KernelTransaction.Type.@implicit);

            Neo4jTransactionalContext context = NewContext(tx);

            context.Terminate();

            verify(tx).terminate();
            verify(tx, never()).close();
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBePossibleToCloseAfterTermination()
        public virtual void ShouldBePossibleToCloseAfterTermination()
        {
            InternalTransaction tx = mock(typeof(InternalTransaction));

            when(tx.TransactionType()).thenReturn(KernelTransaction.Type.@implicit);

            Neo4jTransactionalContext context = NewContext(tx);

            context.Terminate();

            verify(tx).terminate();
            verify(tx, never()).close();

            context.Close(false);
            verify(tx).failure();
            verify(tx).close();
        }