public void ShouldSuccessfullyUnregisterNotExistsWorker() { // Given var target = new MessageQueueListener(); // When TestDelegate action = () => target.UnregisterWorker("queue1"); // Then Assert.DoesNotThrow(action); }
public void UnregisterShouldStopWorker() { // Given var worker1 = new Mock <IMessageQueueWorker>(); var worker2 = new Mock <IMessageQueueWorker>(); var target = new MessageQueueListener(); // When target.RegisterWorker("queue1", worker1.Object); target.RegisterWorker("queue2", worker2.Object); target.StartListenAll(); target.UnregisterWorker("queue1"); // Then worker1.Verify(m => m.Start(), Times.Once()); worker1.Verify(m => m.Stop(), Times.Once()); worker2.Verify(m => m.Start(), Times.Once()); worker2.Verify(m => m.Stop(), Times.Never()); }