Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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]);
        }
Пример #5
0
        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);
        }