public void ChooseEmptyServer() { var configuration = ServiceProvider.Configuration <BalancerConfiguration>(); var maxSessions = configuration.GetMaxSessionsParameter(QueryType.Oltp); var statisticsStorage = ServiceProvider.Resolve <IStatisticsStorage>(); var someOccupiedHost = new Server { Host = "192.168.0.3" }; var someEmptyHost = new Server { Host = "192.168.0.4" }; var maxSessionsStats = new Statistics { IsOnline = true, CurrentSessionsCount = 5 }; SetLocalhostStatisticsAsOnline(statisticsStorage); statisticsStorage.Set(QueryType.Oltp, someOccupiedHost, maxSessionsStats); statisticsStorage.Set(QueryType.Oltp, someEmptyHost, new Statistics { IsOnline = true }); var oltpServers = statisticsStorage.Get(QueryType.Oltp); var decider = ServiceProvider.Resolve <IServerDecider>(); var availableServer = decider.FindAvailableServer(oltpServers, maxSessions); Assert.AreNotEqual(availableServer, someOccupiedHost); statisticsStorage.ReloadFromConfiguration(); }