// public for tests public void OnProcessFeedbackSSE(object sender, SSEActionsEventArgs e) { _log.Debug($"OnProcessFeedbackSSE Action: {e.Action}"); switch (e.Action) { case SSEClientActions.CONNECTED: ProcessConnected(); break; case SSEClientActions.RETRYABLE_ERROR: ProcessDisconnect(retry: true); break; case SSEClientActions.DISCONNECT: case SSEClientActions.NONRETRYABLE_ERROR: ProcessDisconnect(retry: false); break; case SSEClientActions.SUBSYSTEM_DOWN: ProcessSubsystemDown(); break; case SSEClientActions.SUBSYSTEM_READY: ProcessSubsystemReady(); break; case SSEClientActions.SUBSYSTEM_OFF: ProcessSubsystemOff(); break; } }
public void HandleIncominEvent_ControlStreamingResumed_ShouldNotDispatchEvent() { // Arrange. _event = null; var occupancyNoti = new OccupancyNotification { Channel = "control_pri", Metrics = new OccupancyMetricsData { Publishers = 0 }, Type = NotificationType.OCCUPANCY }; var notification = new ControlNotification { Channel = "control_pri", ControlType = ControlType.STREAMING_RESUMED, Type = NotificationType.CONTROL }; // Act & Assert. _notificationManagerKeeper.HandleIncomingEvent(occupancyNoti); Assert.AreEqual(SSEClientActions.SUBSYSTEM_DOWN, _event.Action); _event = null; _notificationManagerKeeper.HandleIncomingEvent(notification); Assert.IsNull(_event); }
public void HandleIncominEvent_ControlStreamingDisabled_ShouldDispatchEvent() { // Arrange. _event = null; var notification = new ControlNotification { Channel = "control_pri", ControlType = ControlType.STREAMING_DISABLED, Type = NotificationType.CONTROL }; // Act. _notificationManagerKeeper.HandleIncomingEvent(notification); // Assert. Assert.AreEqual(SSEClientActions.SUBSYSTEM_OFF, _event.Action); }
public void HandleIncominEvent_OccupancyWithPublishers_FirstTime_ShouldNotDispatchEvent() { // Arrange. _event = null; var notification = new OccupancyNotification { Channel = "control_pri", Type = NotificationType.OCCUPANCY, Metrics = new OccupancyMetricsData { Publishers = 2 } }; // Act. _notificationManagerKeeper.HandleIncomingEvent(notification); // Assert. Assert.IsNull(_event); }
private void OnActionEvent(object sender, SSEActionsEventArgs e) { _event = e; }
public void HandleIncominEvent_OccupancyWithPublishers_ManyEvents_MultiReg() { // Arrange. _event = null; var notificationPri = new OccupancyNotification { Channel = "control_pri", Type = NotificationType.OCCUPANCY, Metrics = new OccupancyMetricsData { Publishers = 2 } }; // Act. _notificationManagerKeeper.HandleIncomingEvent(notificationPri); // Assert. Assert.IsNull(_event); // Event control_pri with 0 publishers - should return false // Arrange. notificationPri.Metrics.Publishers = 0; // Act. _notificationManagerKeeper.HandleIncomingEvent(notificationPri); // Assert. Assert.AreEqual(SSEClientActions.SUBSYSTEM_DOWN, _event.Action); // Event control_sec with 2 publishers - should return true // Arrange. var notificationSec = new OccupancyNotification { Channel = "control_sec", Type = NotificationType.OCCUPANCY, Metrics = new OccupancyMetricsData { Publishers = 2 } }; // Act. _notificationManagerKeeper.HandleIncomingEvent(notificationSec); // Assert. Assert.AreEqual(SSEClientActions.SUBSYSTEM_READY, _event.Action); // Event control_pri with 2 publishers - should return null // Arrange. _event = null; notificationPri.Metrics.Publishers = 2; // Act. _notificationManagerKeeper.HandleIncomingEvent(notificationPri); // Assert. Assert.IsNull(_event); // Event control_pri with 0 publishers - should return null // Arrange. notificationPri.Metrics.Publishers = 0; // Act. _notificationManagerKeeper.HandleIncomingEvent(notificationPri); // Assert. Assert.IsNull(_event); // Event control_sec with 0 publishers - should return false // Arrange. notificationSec.Metrics.Publishers = 0; // Act. _notificationManagerKeeper.HandleIncomingEvent(notificationSec); // Assert. Assert.AreEqual(SSEClientActions.SUBSYSTEM_DOWN, _event.Action); // Event control_sec with 0 publishers - should return null // Arrange. _event = null; notificationSec.Metrics.Publishers = 0; // Act. _notificationManagerKeeper.HandleIncomingEvent(notificationSec); // Assert. Assert.IsNull(_event); // Event control_sec with 1 publishers - should return true // Arrange. notificationSec.Metrics.Publishers = 1; // Act. _notificationManagerKeeper.HandleIncomingEvent(notificationSec); // Assert. Assert.AreEqual(SSEClientActions.SUBSYSTEM_READY, _event.Action); }