public void TestEndpointManagerWithDuplicateEndpoints() { var sem = new TestServiceEndpointManager( new ServiceEndpoint(ConnectionString1, EndpointType.Primary, "1"), new ServiceEndpoint(ConnectionString1, EndpointType.Secondary, "2"), new ServiceEndpoint(ConnectionString2, EndpointType.Secondary, "11"), new ServiceEndpoint(ConnectionString2, EndpointType.Secondary, "12") ); var endpoints = sem.GetAvailableEndpoints().ToArray(); Assert.Equal(2, endpoints.Length); Assert.Equal("1", endpoints[0].Name); Assert.Equal("11", endpoints[1].Name); var primaryEndpoints = sem.GetPrimaryEndpoints().ToArray(); Assert.Single(primaryEndpoints); Assert.Equal("1", primaryEndpoints[0].Name); var router = new TestEndpointRouter(false); var container = new MultiEndpointServiceConnectionContainer( e => new TestServiceConnectionContainer(new List <IServiceConnection> { new TestServiceConnection(), new TestServiceConnection(), }, e), sem, router, null); Assert.Equal(2, container.Connections.Count); }
public async Task TestContainerWithTwoEndpointWithPrimaryOfflineAndConnectionStartedSucceeds() { var sem = new TestServiceEndpointManager( new ServiceEndpoint(ConnectionString1), new ServiceEndpoint(ConnectionString2, EndpointType.Secondary, "online")); var router = new TestEndpointRouter(false); var container = new MultiEndpointServiceConnectionContainer(e => { if (string.IsNullOrEmpty(e.Name)) { return(new TestServiceConnectionContainer(new List <IServiceConnection> { new TestServiceConnection(ServiceConnectionStatus.Disconnected), new TestServiceConnection(ServiceConnectionStatus.Disconnected), new TestServiceConnection(ServiceConnectionStatus.Disconnected), new TestServiceConnection(ServiceConnectionStatus.Disconnected), new TestServiceConnection(ServiceConnectionStatus.Disconnected), new TestServiceConnection(ServiceConnectionStatus.Disconnected), new TestServiceConnection(ServiceConnectionStatus.Disconnected), }, e)); } return(new TestServiceConnectionContainer(new List <IServiceConnection> { new TestServiceConnection(), new TestServiceConnection(), new TestServiceConnection(), new TestServiceConnection(), new TestServiceConnection(), new TestServiceConnection(), new TestServiceConnection(), }, e)); }, sem, router, null); _ = container.StartAsync(); await container.WriteAsync(DefaultGroupMessage); await container.WriteAsync("1", DefaultGroupMessage); var endpoints = sem.GetAvailableEndpoints(); Assert.Single(endpoints); endpoints = sem.GetPrimaryEndpoints(); Assert.Single(endpoints); Assert.Equal("online", endpoints.First().Name); }