public void Changes_CS_configuration_when_primary_server_is_available() { A.CallTo(() => backupServers.GetNextPrimaryServer()).Returns(BackupServer); handler.Handle(new ServerStoppedResponding()); A.CallTo(() => cfgProvider.ChangeConfiguration(BackupServer.Address, BackupServer.Port)) .MustHaveHappened(); }
public void Handle(ServerStoppedResponding notification) { var server = backupManager.GetNextPrimaryServer(); if (server != null) { logger.Error($"Primary CS is down, restoring connection to {server.Address}:{server.Port}."); cfgProvider.ChangeConfiguration(server.Address, server.Port); mediator.Publish(new ConnectionRestored()); } else { logger.Error("Primary CS is down, notifying system we need to work as primary"); mediator.Publish(new SwitchedToPrimary()); } }