public void EventEmitterShouldNotEmitAnEventToAnUnregisteredPusherEventGeneralListener() { // Arrange Tuple <string, PusherEvent> emittedEvent = null; var myAction = new Action <string, PusherEvent>((e, o) => emittedEvent = new Tuple <string, PusherEvent>(e, o)); var emitter = new PusherClient.EventEmitter(); emitter.BindAll(myAction); emitter.UnbindAll(); // Act emitter.EmitEvent("pusher event general listener event", CreateTestEvent()); // Assert Assert.IsNull(emittedEvent); }
public void EventEmitterShouldEmitAnEventToARegisteredRawListener() { // Arrange string emittedEvent = null; var myAction = new Action <string>(o => emittedEvent = o); var emitter = new PusherClient.EventEmitter(); emitter.Bind("raw listener event", myAction); // Act emitter.EmitEvent("raw listener event", CreateTestEvent()); // Assert Assert.IsNotNull(emittedEvent); StringAssert.AreEqualIgnoringCase("{\"user_id\":\"a user\",\"channel\":\"a channel name\",\"event\":\"channel event\",\"data\":\"{\\\"stuff\\\":1234}\"}", emittedEvent); }
public void EventEmitterShouldEmitAnEventToARegisteredListener() { // Arrange dynamic emittedEvent = null; var myAction = new Action <dynamic>(o => emittedEvent = o); var emitter = new PusherClient.EventEmitter(); emitter.Bind("listener event", myAction); // Act emitter.EmitEvent("listener event", CreateTestEvent()); // Assert Assert.IsNotNull(emittedEvent); StringAssert.AreEqualIgnoringCase("channel event", [email protected]); }
public void EventEmitterShouldEmitAnEventToARegisteredGeneralListener() { // Arrange Tuple <string, dynamic> emittedEvent = null; var myAction = new Action <string, dynamic>((e, o) => emittedEvent = new Tuple <string, dynamic>(e, o)); var emitter = new PusherClient.EventEmitter(); emitter.BindAll(myAction); // Act emitter.EmitEvent("general listener event", CreateTestEvent()); // Assert Assert.IsNotNull(emittedEvent); StringAssert.AreEqualIgnoringCase("general listener event", emittedEvent.Item1); StringAssert.AreEqualIgnoringCase("channel event", [email protected]); }
public void EventEmitterShouldEmitAnEventToARegisteredPusherEventListener() { // Arrange PusherEvent emittedEvent = null; var myAction = new Action <PusherEvent>(o => emittedEvent = o); var emitter = new PusherClient.EventEmitter(); emitter.Bind("pusher event listener event", myAction); // Act emitter.EmitEvent("pusher event listener event", CreateTestEvent()); // Assert Assert.IsNotNull(emittedEvent); StringAssert.AreEqualIgnoringCase("channel event", emittedEvent.EventName); StringAssert.AreEqualIgnoringCase("{\"stuff\":1234}", emittedEvent.Data); }
public void EventEmitterShouldNotEmitAnEventToAnUnregisteredPusherEventEventName() { // Arrange PusherEvent emittedEvent = null; PusherEvent emittedEvent2 = null; var myAction = new Action <PusherEvent>(o => emittedEvent = o); var myAction2 = new Action <PusherEvent>(o => emittedEvent2 = o); var emitter = new PusherClient.EventEmitter(); emitter.Bind("pusher event listener event", myAction); emitter.Bind("pusher event listener event", myAction2); emitter.Unbind("pusher event listener event"); // Act emitter.EmitEvent("pusher event listener event", CreateTestEvent()); // Assert Assert.IsNull(emittedEvent); Assert.IsNull(emittedEvent2); }
public void EventEmitterShouldNotEmitAnEventToAnUnregisteredRawListener() { // Arrange string emittedEvent = null; string emittedEvent2 = null; var myAction = new Action <string>(o => emittedEvent = o); var myAction2 = new Action <string>(o => emittedEvent2 = o); var emitter = new PusherClient.EventEmitter(); emitter.Bind("raw listener event", myAction); emitter.Bind("raw listener event", myAction2); emitter.Unbind("raw listener event", myAction); // Act emitter.EmitEvent("raw listener event", CreateTestEvent()); // Assert Assert.IsNull(emittedEvent); Assert.IsNotNull(emittedEvent2); }