Example #1
0
            public void ShouldPropagateAuthenticationException()
            {
                // Given
                var uri          = new Uri("bolt+routing://123:456");
                var routingTable = new RoutingTable(new List <Uri> {
                    uri
                });
                var poolManagerMock = new Mock <IClusterConnectionPoolManager>();

                poolManagerMock.Setup(x => x.CreateClusterConnection(uri))
                .Callback(() => throw new AuthenticationException("Failed to auth the client to the server."));
                var manager = NewRoutingTableManager(routingTable, poolManagerMock.Object);

                // When
                var error = Record.Exception(() => manager.UpdateRoutingTable());

                // Then
                error.Should().BeOfType <AuthenticationException>();
                error.Message.Should().Contain("Failed to auth the client to the server.");

                // while the server is not removed
                routingTable.All().Should().ContainInOrder(uri);
            }
Example #2
0
            public void ShouldForgetAndTryNextRouterWhenConnectionIsNull()
            {
                // Given
                var uriA = new Uri("bolt+routing://123:456");
                var uriB = new Uri("bolt+routing://123:789");

                // This ensures that uri and uri2 will return in order
                var routingTable = new RoutingTable(new List <Uri> {
                    uriA, uriB
                });
                var poolManagerMock = new Mock <IClusterConnectionPoolManager>();

                poolManagerMock.Setup(x => x.CreateClusterConnection(It.IsAny <Uri>()))
                .Returns((ClusterConnection)null);
                var manager = NewRoutingTableManager(routingTable, poolManagerMock.Object);

                // When
                var newRoutingTable = manager.UpdateRoutingTable(null, connection =>
                                                                 throw new NotSupportedException($"Unknown uri: {connection.Server.Address}"));

                // Then
                newRoutingTable.Should().BeNull();
                routingTable.All().Should().BeEmpty();
            }