コード例 #1
0
        private void Enqueue(IRequestMessage requestMessage, IMessageResponseCollector resultBuilder = null,
                             IRequestMessage requestStreamingMessage = null)
        {
            _messages.Enqueue(requestMessage);
            _responseHandler.EnqueueMessage(requestMessage, resultBuilder);

            if (requestStreamingMessage != null)
            {
                _messages.Enqueue(requestStreamingMessage);
                _responseHandler.EnqueueMessage(requestStreamingMessage, resultBuilder);
            }
        }
コード例 #2
0
        private void Enqueue(IRequestMessage requestMessage, IMessageResponseCollector resultBuilder = null, IRequestMessage requestStreamingMessage = null)
        {
            lock (_syncLock)
            {
                EnsureNotInterrupted();
                _messages.Enqueue(requestMessage);
                _responseHandler.EnqueueMessage(requestMessage, resultBuilder);

                if (requestStreamingMessage != null)
                {
                    _messages.Enqueue(requestStreamingMessage);
                    _responseHandler.EnqueueMessage(requestStreamingMessage, resultBuilder);
                }
            }
        }
コード例 #3
0
            public MockedConnection(List <Tuple <IRequestMessage, IResponseMessage> > messages, ServerInfo serverInfo = null)
            {
                foreach (var pair in messages)
                {
                    if (pair.Item1 != null)
                    {
                        _requestMessages.Add(pair.Item1);
                    }

                    if (pair.Item2 != null)
                    {
                        _responseMessages.Add(pair.Item2);
                    }
                }

                _mockConn.Setup(x => x.Enqueue(It.IsAny <IRequestMessage>(), It.IsAny <IMessageResponseCollector>(),
                                               It.IsAny <IRequestMessage>()))
                .Callback <IRequestMessage, IMessageResponseCollector, IRequestMessage>((msg1, collector, msg2) =>
                {
                    msg1.ToString().Should().Be(_requestMessages[_requestCount].ToString());
                    _requestCount++;
                    _handler.EnqueueMessage(msg1, collector);

                    if (msg2 != null)
                    {
                        msg2.ToString().Should().Be(_requestMessages[_requestCount].ToString());
                        _requestCount++;
                        _handler.EnqueueMessage(msg1, collector);
                    }
                });
                _mockConn.Setup(x => x.ReceiveOne())
                .Callback(() =>
                {
                    if (_responseCount < _responseMessages.Count)
                    {
                        _responseMessages[_responseCount].Dispatch(_handler);
                        _responseCount++;
                        if (_handler.HasError)
                        {
                            var error      = _handler.Error;
                            _handler.Error = null;
                            throw error;
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException("Not enough response message to provide");
                    }
                });

                _mockConn.Setup(x => x.BoltProtocol).Returns(BoltProtocolV1.BoltV1);
                _mockConn.Setup(x => x.IsOpen).Returns(() => _responseCount < _responseMessages.Count);
                if (serverInfo != null)
                {
                    _mockConn.Setup(x => x.Server).Returns(serverInfo);
                }
                else
                {
                    _mockConn.Setup(x => x.Server)
                    .Returns(new ServerInfo(new Uri("bolt://123:456"))
                    {
                        Version = "Neo4j/3.1.0"
                    });
                }
            }
コード例 #4
0
 private void Enqueue(IRequestMessage requestMessage, IResultBuilder resultBuilder = null)
 {
     _messages.Enqueue(requestMessage);
     _responseHandler.EnqueueMessage(requestMessage, resultBuilder);
 }