internal static IConnection Setup32SocketConnection(IDictionary <string, string> routingContext, object[] recordFields, Mock <ISocketClient> clientMock) { var pairs = new List <Tuple <IRequestMessage, IResponseMessage> > { MessagePair(InitMessage(), SuccessMessage()), MessagePair(new RunMessage("CALL dbms.cluster.routing.getRoutingTable({context})", new Dictionary <string, object> { { "context", routingContext } }), SuccessMessage(new List <object> { "ttl", "servers" })), MessagePair(new RecordMessage(recordFields)), MessagePair(PullAllMessage(), SuccessMessage()) }; var mock = new MockedMessagingClient(pairs, clientMock); var serverInfo = new ServerInfo(new Uri("bolt://123:456")); var conn = SocketConnectionTests.NewSocketConnection(mock.Client, server: serverInfo); conn.Init(); serverInfo.Version = "Neo4j/3.2.2"; return(conn); }
public void ShouldServiceUnavailableWhenProcedureNotFound() { // Given var pairs = new List <Tuple <IRequestMessage, IResponseMessage> > { MessagePair(InitMessage(), SuccessMessage()), MessagePair(new RunMessage("CALL dbms.cluster.routing.getServers"), new FailureMessage("Neo.ClientError.Procedure.ProcedureNotFound", "not found")), MessagePair(PullAllMessage(), new IgnoredMessage()) }; var messagingClient = new MockedMessagingClient(pairs); var conn = SocketConnectionTests.NewSocketConnection(messagingClient.Client); conn.Init(); var manager = CreateDiscoveryManager(conn, null); // When var exception = Record.Exception(() => manager.Rediscovery()); // Then exception.Should().BeOfType <ServiceUnavailableException>(); exception.Message.Should().StartWith("Error when calling `getServers` procedure: "); messagingClient.ClientMock.Verify(x => x.Stop(), Times.Once); }
internal static IConnection SetupSocketConnection(List <object[]> recordFieldsList, Mock <ISocketClient> clientMock) { var pairs = new List <Tuple <IRequestMessage, IResponseMessage> > { MessagePair(InitMessage(), SuccessMessage()), MessagePair(new RunMessage("CALL dbms.cluster.routing.getServers", new Dictionary <string, object>()), SuccessMessage(new List <object> { "ttl", "servers" })) }; foreach (var recordFields in recordFieldsList) { pairs.Add(MessagePair(new RecordMessage(recordFields))); } pairs.Add(MessagePair(PullAllMessage(), SuccessMessage())); var mock = new MockedMessagingClient(pairs, clientMock); var conn = SocketConnectionTests.NewSocketConnection(mock.Client); conn.Init(); return(conn); }