public void ShouldNotEnqueueMoreMessagesAfterMarkToClosedInRollbackAsync() { var protocol = new Mock <IBoltProtocol>(); var mockConn = NewMockedConnection(protocol.Object); var tx = new AsyncTransaction(mockConn.Object, Mock.Of <ITransactionResourceHandler>()); mockConn.Invocations.Clear(); tx.MarkToClose(); tx.Awaiting(t => t.RollbackAsync()).Should().NotThrow(); protocol.Verify(x => x.RollbackTransactionAsync(It.IsAny <IConnection>()), Times.Never); mockConn.Verify(x => x.SyncAsync(), Times.Never); }
public void ShouldNotEnqueueMoreMessagesAfterMarkToClosedInCommitAsync() { var protocol = new Mock <IBoltProtocol>(); var mockConn = NewMockedConnection(protocol.Object); var tx = new AsyncTransaction(mockConn.Object, Mock.Of <ITransactionResourceHandler>()); mockConn.Invocations.Clear(); tx.MarkToClose(); tx.Awaiting(t => t.CommitAsync()).Should().Throw <ClientException>().Which.Message.Should() .Contain("Cannot commit this transaction"); protocol.Verify(x => x.CommitTransactionAsync(It.IsAny <IConnection>(), tx), Times.Never); mockConn.Verify(x => x.SyncAsync(), Times.Never); }
public void ShouldThrowExceptionToRunAfterMarkToClosed() { var protocol = new Mock <IBoltProtocol>(); var mockConn = NewMockedConnection(protocol.Object); var tx = new AsyncTransaction(mockConn.Object, Mock.Of <ITransactionResourceHandler>()); mockConn.Invocations.Clear(); tx.MarkToClose(); tx.Awaiting(t => t.RunAsync("should not run")).Should().Throw <ClientException>().Which.Message.Should() .StartWith("Cannot run statement in this transaction"); protocol.Verify(x => x.RollbackTransactionAsync(It.IsAny <IConnection>()), Times.Never); mockConn.Verify(x => x.SyncAsync(), Times.Never); }