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

                await tx.BeginTransactionAsync(TransactionConfig.Default);

                tx.IsOpen.Should().BeTrue();
            }
            public async Task ShouldDelegateToProtocolBeginTxMethod()
            {
                var protocol = new Mock <IBoltProtocol>();
                var mockConn = NewMockedConnection(protocol.Object);
                var tx       = new AsyncTransaction(mockConn.Object);

                await tx.BeginTransactionAsync(TransactionConfig.Empty);

                protocol.Verify(
                    x => x.BeginTransactionAsync(It.IsAny <IConnection>(), It.IsAny <Bookmark>(),
                                                 It.IsAny <TransactionConfig>()), Times.Once);
            }
Beispiel #3
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 Task ShouldDelegateToProtocolBeginTxMethod()
            {
                var protocol = new Mock <IBoltProtocol>();
                var mockConn = NewMockedConnection(protocol.Object);
                var tx       = new AsyncTransaction(mockConn.Object, Mock.Of <ITransactionResourceHandler>());

                await tx.BeginTransactionAsync(TransactionConfig.Default);

                protocol.Verify(
                    x => x.BeginTransactionAsync(It.IsAny <IConnection>(), It.IsAny <string>(), It.IsAny <Bookmark>(),
                                                 It.IsAny <TransactionConfig>(), null), Times.Once);
            }
            public async Task ShouldSaveBookmark()
            {
                var mockConn     = new Mock <IConnection>();
                var mockProtocol = new Mock <IBoltProtocol>();

                mockConn.Setup(x => x.BoltProtocol).Returns(mockProtocol.Object);

                var bookmark = Bookmark.From(FakeABookmark(123));
                var tx       = new AsyncTransaction(mockConn.Object, null, null, bookmark);

                await tx.BeginTransactionAsync(null);

                mockProtocol.Verify(
                    x => x.BeginTransactionAsync(It.IsAny <IConnection>(), bookmark, It.IsAny <TransactionConfig>()),
                    Times.Once);
            }