Пример #1
0
            public async Task ShouldThrowClientErrorIfFailedToConnectToServerWithinTimeout()
            {
                // Given
                var mockClient = new Mock <ISocketClient>();

                mockClient.Setup(x => x.ConnectAsync())
                .Throws(new IOException("I will stop socket conn from initialization"));
                // ReSharper disable once ObjectCreationAsStatement
                var conn = new SocketConnection(mockClient.Object, AuthToken, UserAgent, Logger, Server);
                // When
                var error = await Record.ExceptionAsync(() => conn.InitAsync());

                // Then
                error.Should().BeOfType <IOException>();
                error.Message.Should().Be("I will stop socket conn from initialization");
            }
Пример #2
0
        public async Task ShouldUseProtocolVersionWhenPassedMetadata()
        {
            var mockClient = new Mock <ISocketClient>();

            mockClient.Setup(x => x.ConnectAsync(null)).Returns(Task.FromResult(new Mock <IBoltProtocol>().Object));

            var conn = new SocketConnection(mockClient.Object, AuthTokens.None, ConnectionSettings.DefaultUserAgent, new Mock <ILogger>().Object, new ServerInfo(new Uri("http://neo4j.com")));
            await conn.InitAsync();

            var responseHandler = new HelloResponseHandler(conn, new Protocol.BoltProtocolVersion(MajorVersion, MinorVersion));

            responseHandler.OnSuccess(new[] { ServerVersionCollectorTests.TestMetadata, ConnectionIdCollectorTests.TestMetadata }.ToDictionary());

            //Ensure it is using the protocol version and not the version sent in the metadata
            conn.Server.Agent.Should().ContainAll("Neo4j/" + MajorVersion + "." + MinorVersion + ".0");
        }