public async Task ShouldNotSyncIfBookmarkIsNull()
            {
                var mockConn = NewConnectionWithMode();
                var V3       = new BoltProtocolV3();

                await V3.BeginTransactionAsync(mockConn.Object, null, null, null);

                mockConn.Verify(
                    x => x.EnqueueAsync(It.IsAny <BeginMessage>(), It.IsAny <V3.BeginResponseHandler>(), null, null),
                    Times.Once);
                mockConn.Verify(x => x.SyncAsync(), Times.Never);
            }
            public async Task ShouldSyncIfValidBookmarkGiven()
            {
                var mockConn = NewConnectionWithMode();
                var bookmark = Bookmark.From(AsyncSessionTests.FakeABookmark(234));
                var V3       = new BoltProtocolV3();

                await V3.BeginTransactionAsync(mockConn.Object, null, bookmark, null);

                mockConn.Verify(
                    x => x.EnqueueAsync(It.IsAny <BeginMessage>(), It.IsAny <V3.BeginResponseHandler>(), null, null),
                    Times.Once);
                mockConn.Verify(x => x.SyncAsync(), Times.Once);
            }
Ejemplo n.º 3
0
            public async Task ShouldThrowOnImpersonatedUserAsync()
            {
                var protocol = new BoltProtocolV3();
                var mockConn = NewConnectionWithMode(AccessMode.Read);

                var ex = await Assert.ThrowsAsync <ArgumentException>(() => protocol.BeginTransactionAsync(mockConn.Object,
                                                                                                           string.Empty,
                                                                                                           Bookmark.From("123"),
                                                                                                           TransactionConfig.Default,
                                                                                                           "ImpersonatedUser"));

                ex.Message.Should().Contain("3.0");
            }
            public async Task ShouldPassBookmarkTxConfigAndModeToRunWithMetadataMessage(AccessMode mode)
            {
                var mockConn = NewConnectionWithMode(mode);
                var V3       = new BoltProtocolV3();

                mockConn.Setup(x => x.EnqueueAsync(It.IsAny <IRequestMessage>(), It.IsAny <IResponseHandler>(),
                                                   It.IsAny <IRequestMessage>(), It.IsAny <IResponseHandler>()))
                .Returns(Task.CompletedTask)
                .Callback <IRequestMessage, IResponseHandler, IRequestMessage, IResponseHandler>(
                    (m1, h1, m2, h2) =>
                {
                    var msg = m1.CastOrThrow <BeginMessage>();
                    VerifyMetadata(msg.Metadata, mode);
                });

                await V3.BeginTransactionAsync(mockConn.Object, null, Bookmark, TxConfig);

                mockConn.Verify(
                    x => x.EnqueueAsync(It.IsAny <BeginMessage>(), It.IsAny <V3.BeginResponseHandler>(), null, null),
                    Times.Once);
            }