public void MessageCoordinator_Close_ShouldSupportBeingCalledMultipleTimes() { // Arrange var coordinator = new MessageCoordinator(); // Act coordinator.Close(); coordinator.Close(); // Assert }
public void MessageCoordinator_Close_ShouldFireNeverReceivedCallbackInOrderOfSubscription() { // Arrange var coordinator = new MessageCoordinator(); var subscriberCount = 20; var firedCallbacks = new List<int>(); for (var i = 0; i < subscriberCount; i++) { var subscriberIndex = i; coordinator.Subscribe((string message) => { Assert.Fail("Callback should never have been called."); }, () => { firedCallbacks.Add(subscriberIndex); }); } // Act coordinator.Close(); // Assert var expectedFiringOrder = Enumerable.Range(0, subscriberCount).ToArray(); CollectionAssert.AreEquivalent(expectedFiringOrder, firedCallbacks); }
public void MessageCoordinator_Close_ShouldFireNeverReceivedCallbackInOrderOfSubscription() { // Arrange var coordinator = new MessageCoordinator(); var subscriberCount = 20; var firedCallbacks = new List <int>(); for (var i = 0; i < subscriberCount; i++) { var subscriberIndex = i; coordinator.Subscribe((string message) => { Assert.Fail("Callback should never have been called."); }, () => { firedCallbacks.Add(subscriberIndex); }); } // Act coordinator.Close(); // Assert var expectedFiringOrder = Enumerable.Range(0, subscriberCount).ToArray(); CollectionAssert.AreEquivalent(expectedFiringOrder, firedCallbacks); }
public void MessageCoordinator_Publish_ShouldThrowInvalidOperationExceptionIfCalledAfterClose() { // Arrange var coordinator = new MessageCoordinator(); // Act coordinator.Close(); coordinator.Publish("message"); // Assert }
public void MessageCoordinator_Subscribe_ShouldThrowInvalidOperationExceptionIfCalledAfterClose() { // Arrange var coordinator = new MessageCoordinator(); // Act coordinator.Close(); coordinator.Subscribe((string message) => { Assert.Fail(); }); // Assert }
public void MessageCoordinator_Close_ShouldFireNotDeliveredForSubscribersOfInheritedTypes() { // Arrange var coordinator = new MessageCoordinator(); coordinator.Subscribe<InheritedTestMessage>( (InheritedTestMessage message) => { Assert.Fail("The recieved callback should not be called"); }, () => { }); //Act coordinator.Publish(new TestMessage()); coordinator.Close(); // Assert }
public void MessageCoordinator_Close_ShouldFireNotDeliveredForSubscribersOfInheritedTypes() { // Arrange var coordinator = new MessageCoordinator(); coordinator.Subscribe <InheritedTestMessage>( (InheritedTestMessage message) => { Assert.Fail("The recieved callback should not be called"); }, () => { }); //Act coordinator.Publish(new TestMessage()); coordinator.Close(); // Assert }
public void MessageCoordinator_Close_ShouldFireNeverReceivedCallback() { // Arrange var coordinator = new MessageCoordinator(); bool neverReceivedCallbackFired = false; coordinator.Subscribe( (int message) => { Assert.Fail("Callback should never have been called."); }, () => { neverReceivedCallbackFired = true; }); // Act coordinator.Publish("hello"); coordinator.Close(); // Assert Assert.IsTrue(neverReceivedCallbackFired); }
public void MessageCoordinator_Close_ShouldNotFireNeverReceivedCallbackForMessagesThatHaveBeenReceived() { // Arrange var coordinator = new MessageCoordinator(); bool messageReceivedCallbackFired = false; coordinator.Subscribe( (string message) => { messageReceivedCallbackFired = true; }, () => { Assert.Fail("Callback should never have been called."); }); // Act coordinator.Publish("hello"); coordinator.Close(); // Assert Assert.IsTrue(messageReceivedCallbackFired); }
public void MessageCoordinator_Close_ShouldFireNeverReceivedCallback() { // Arrange var coordinator = new MessageCoordinator(); bool neverReceivedCallbackFired = false; coordinator.Subscribe( (int message) => { Assert.Fail("Callback should never have been called."); }, () => { neverReceivedCallbackFired = true; }); // Act coordinator.Publish("hello"); coordinator.Close(); // Assert Assert.IsTrue(neverReceivedCallbackFired); }
public void MessageCoordinator_Close_ShouldSupportBeingCalledMultipleTimes() { // Arrange var coordinator = new MessageCoordinator(); // Act coordinator.Close(); coordinator.Close(); // Assert }
public void MessageCoordinator_Close_ShouldNotFireNeverReceivedCallbackForMessagesThatHaveBeenReceived() { // Arrange var coordinator = new MessageCoordinator(); bool messageReceivedCallbackFired = false; coordinator.Subscribe( (string message) => { messageReceivedCallbackFired = true; }, () => { Assert.Fail("Callback should never have been called."); }); // Act coordinator.Publish("hello"); coordinator.Close(); // Assert Assert.IsTrue(messageReceivedCallbackFired); }
public void MessageCoordinator_Subscribe_ShouldThrowInvalidOperationExceptionIfCalledAfterClose() { // Arrange var coordinator = new MessageCoordinator(); // Act coordinator.Close(); coordinator.Subscribe((string message) => { Assert.Fail(); }); // Assert }
public void MessageCoordinator_Publish_ShouldThrowInvalidOperationExceptionIfCalledAfterClose() { // Arrange var coordinator = new MessageCoordinator(); // Act coordinator.Close(); coordinator.Publish("message"); // Assert }