public async Task ShouldPassBookmarkAndTxConfigToRunWithMetadataMessage(AccessMode mode)
            {
                var mockConn        = NewConnectionWithMode(mode);
                var statement       = new Statement("A cypher query");
                var bookmarkTracker = new Mock <IBookmarkTracker>();
                var resourceHandler = new Mock <IResultResourceHandler>();

                mockConn.Setup(x => x.EnqueueAsync(It.IsAny <RunMessage>(), It.IsAny <V3.RunResponseHandler>(),
                                                   It.IsAny <PullAllMessage>(), It.IsAny <V3.PullResponseHandler>()))
                .Returns(TaskHelper.GetCompletedTask())
                .Callback <IRequestMessage, IResponseHandler, IRequestMessage, IResponseHandler>(
                    (m1, h1, m2, h2) =>
                {
                    h1.OnSuccess(new Dictionary <string, object>());
                    VerifyMetadata(m1.CastOrThrow <RunWithMetadataMessage>().Metadata, mode);
                });

                await BoltV3.RunInAutoCommitTransactionAsync(mockConn.Object, statement, true, bookmarkTracker.Object,
                                                             resourceHandler.Object, Bookmark, TxConfig);

                mockConn.Verify(
                    x => x.EnqueueAsync(It.IsAny <RunWithMetadataMessage>(), It.IsAny <V3.RunResponseHandler>(),
                                        PullAllMessage.PullAll,
                                        It.IsAny <V3.PullResponseHandler>()),
                    Times.Once);
            }
예제 #2
0
            public async Task ResultBuilderShouldObtainServerInfoFromConnection()
            {
                var mockConn    = new Mock <IConnection>();
                var statement   = new Statement("A cypher query");
                var mockHandler = new Mock <IResultResourceHandler>();

                mockConn.Setup(x => x.Enqueue(It.IsAny <IRequestMessage>(), It.IsAny <ResultCursorBuilder>(), PullAll))
                .Callback <IRequestMessage, IMessageResponseCollector, IRequestMessage>(
                    (msg1, h, msg2) =>
                {
                    h?.DoneSuccess();
                });
                await BoltV3.RunInAutoCommitTransactionAsync(mockConn.Object, statement, mockHandler.Object, null, null);

                mockConn.Verify(x => x.Server, Times.Once);
            }
            public async Task ResultBuilderShouldObtainServerInfoFromConnection()
            {
                var mockConn        = NewConnectionWithMode();
                var statement       = new Statement("A cypher query");
                var bookmarkTracker = new Mock <IBookmarkTracker>();
                var resourceHandler = new Mock <IResultResourceHandler>();

                mockConn.Setup(x => x.EnqueueAsync(It.IsAny <RunMessage>(), It.IsAny <V3.RunResponseHandler>(),
                                                   It.IsAny <PullAllMessage>(), It.IsAny <V3.PullResponseHandler>()))
                .Returns(TaskHelper.GetCompletedTask())
                .Callback <IRequestMessage, IResponseHandler, IRequestMessage, IResponseHandler>(
                    (msg1, h1, msg2, h2) => { h1.OnSuccess(new Dictionary <string, object>()); });

                await BoltV3.RunInAutoCommitTransactionAsync(mockConn.Object, statement, true, bookmarkTracker.Object,
                                                             resourceHandler.Object, null, null);

                mockConn.Verify(x => x.Server, Times.Once);
            }
예제 #4
0
            public async Task ShouldPassBookmarkAndTxConfigToRunWithMetadataMessage()
            {
                var mockConn    = new Mock <IConnection>();
                var statement   = new Statement("A cypher query");
                var mockHandler = new Mock <IResultResourceHandler>();

                mockConn.Setup(x => x.Enqueue(It.IsAny <IRequestMessage>(), It.IsAny <ResultCursorBuilder>(), PullAll))
                .Callback <IRequestMessage, IMessageResponseCollector, IRequestMessage>(
                    (m0, h, m1) =>
                {
                    h?.DoneSuccess();
                    VerifyMetadata(m0.CastOrThrow <RunWithMetadataMessage>().Metadata);
                });
                await BoltV3.RunInAutoCommitTransactionAsync(mockConn.Object, statement, mockHandler.Object,
                                                             Bookmark, TxConfig);

                mockConn.Verify(x => x.Enqueue(It.IsAny <RunWithMetadataMessage>(), It.IsAny <ResultCursorBuilder>(), PullAll), Times.Once);
            }
            public async Task ShouldEnqueueRunAndPullAllAndSend()
            {
                var mockConn        = NewConnectionWithMode();
                var query           = new Query("A cypher query");
                var bookmarkTracker = new Mock <IBookmarkTracker>();
                var resourceHandler = new Mock <IResultResourceHandler>();

                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>(
                    (msg1, h1, msg2, h2) => { h1.OnSuccess(new Dictionary <string, object>()); });

                await BoltV3.RunInAutoCommitTransactionAsync(mockConn.Object, query, true, bookmarkTracker.Object,
                                                             resourceHandler.Object, null, null, null);

                mockConn.Verify(
                    x => x.EnqueueAsync(It.IsAny <RunWithMetadataMessage>(), It.IsAny <V3.RunResponseHandler>(),
                                        PullAllMessage.PullAll,
                                        It.IsAny <V3.PullResponseHandler>()), Times.Once);
                mockConn.Verify(x => x.SendAsync());
            }