public void HasNextWithMoreThanHalfBlacklistedTest() { RoundRobinServerManager target = new RoundRobinServerManager(new ConnectionBuilder("Server=unit-test-1")); Server srv1 = null; Server srv2 = new Server("unit-test-2"); Server srv3 = new Server("unit-test-3"); Server srv4 = new Server("unit-test-4"); target.Add(srv2); target.Add(srv3); target.Add(srv4); List<Server> servers = new List<Server> { new Server("unit-test-1"), srv2, srv3, srv4 }; for (int i = 0; i < 4; i++) { Server srv = target.Next(); Assert.True(servers[i].ToString().Equals(srv.ToString(), StringComparison.OrdinalIgnoreCase)); if(i == 0) { srv1 = srv; } } target.ErrorOccurred(srv2); target.ErrorOccurred(srv3); Assert.True(target.HasNext); target.ErrorOccurred(srv1); Assert.True(target.HasNext); target.ErrorOccurred(srv4); Assert.False(target.HasNext); }
public void CanBlackListAndCleanQueueTest() { RoundRobinServerManager target = new RoundRobinServerManager(new ConnectionBuilder("Server=unit-test-1,unit-test-2,unit-test-3")); Server srv = new Server("unit-test-4"); target.Add(srv); bool gotServer4 = false; for (int i = 0; i < 4; i++) { Server server = target.Next(); if (server.ToString().Equals(srv.ToString(), StringComparison.OrdinalIgnoreCase)) { gotServer4 = true; break; } } Assert.True(gotServer4); target.ErrorOccurred(srv); gotServer4 = false; for (int i = 0; i < 4; i++) { Server server = target.Next(); if (server.Equals(srv)) { gotServer4 = true; break; } } Assert.False(gotServer4); }
public void HasNextWithMoreThanHalfBlacklistedTest() { RoundRobinServerManager target = new RoundRobinServerManager(new ConnectionBuilder("Server=unit-test-1")); Server srv1 = null; Server srv2 = new Server("unit-test-2"); Server srv3 = new Server("unit-test-3"); Server srv4 = new Server("unit-test-4"); target.Add(srv2); target.Add(srv3); target.Add(srv4); List <Server> servers = new List <Server> { new Server("unit-test-1"), srv2, srv3, srv4 }; for (int i = 0; i < 4; i++) { Server srv = target.Next(); Assert.True(servers[i].ToString().Equals(srv.ToString(), StringComparison.OrdinalIgnoreCase)); if (i == 0) { srv1 = srv; } } target.ErrorOccurred(srv2); target.ErrorOccurred(srv3); Assert.True(target.HasNext); target.ErrorOccurred(srv1); Assert.True(target.HasNext); target.ErrorOccurred(srv4); Assert.False(target.HasNext); }
/// <summary> /// /// </summary> /// <param name="builder"></param> protected ConnectionProvider(IConnectionBuilder builder) { ConnectionBuilder = builder; Servers = new RoundRobinServerManager(builder); }
/// <summary> /// /// </summary> /// <param name="builder"></param> protected ConnectionProvider(ConnectionBuilder builder) { Builder = builder; Servers = new RoundRobinServerManager(builder); }