예제 #1
0
            public async Task ShouldBeClosedWhenRollBacked()
            {
                var protocol = new Mock <IBoltProtocol>();
                var mockConn = NewMockedConnection(protocol.Object);
                var tx       = new AsyncTransaction(mockConn.Object, Mock.Of <ITransactionResourceHandler>());

                await tx.BeginTransactionAsync(TransactionConfig.Default);

                await tx.RollbackAsync();

                tx.IsOpen.Should().BeFalse();
            }
            public async void ShouldRollbackOnFailure()
            {
                var protocol    = new Mock <IBoltProtocol>();
                var mockConn    = NewMockedConnection(protocol.Object);
                var mockHandler = new Mock <ITransactionResourceHandler>();
                var tx          = new AsyncTransaction(mockConn.Object, mockHandler.Object);

                mockConn.Invocations.Clear();
                await tx.RollbackAsync();

                protocol.Verify(x => x.RollbackTransactionAsync(It.IsAny <IConnection>()));
                mockHandler.Verify(x => x.OnTransactionDisposeAsync(It.IsAny <Bookmark>()), Times.Once);
            }
            public async Task ShouldNotEnqueueMoreMessagesAfterMarkToClosedInRollbackAsync()
            {
                var protocol = new Mock <IBoltProtocol>();
                var mockConn = NewMockedConnection(protocol.Object);
                var tx       = new AsyncTransaction(mockConn.Object);

                mockConn.Invocations.Clear();

                tx.MarkToClose();
                await tx.RollbackAsync();

                protocol.Verify(x => x.RollbackTransactionAsync(It.IsAny <IConnection>()), Times.Never);
                mockConn.Verify(x => x.SyncAsync(), Times.Never);
            }