コード例 #1
0
        public void url_resource_is_in_expected_format()
        {
            ITriggerResult result =
                _pusher.Trigger(
                    channelName,
                    eventName,
                    eventData
                    );

            _subClient.Received().Execute(
                Arg.Is <IRestRequest>(
                    x => CheckRequestHasExpectedUrl(x)
                    )
                );
        }
コード例 #2
0
        public IPubSubResult Publish <T>(T message) where T : class, IPubSubMessage
        {
            Requires.NotNull(message, nameof(message));
            Requires.NotNullOrEmpty(message.Channel, nameof(message.Channel));
            Requires.NotNullOrEmpty(message.Event, nameof(message.Event));
            Requires.NotNull(message.Payload, nameof(message.Payload));

            ITriggerResult triggerResult = _pusher.Trigger(message.Channel, message.Event, message.Payload);

            return(new PusherResult
            {
                Body = triggerResult.Body,
                StatusCode = triggerResult.StatusCode
            });
        }
コード例 #3
0
        public void trigger_calls_are_made_over_HTTP_by_default()
        {
            IPusherOptions options = new PusherOptions()
            {
                RestClient = _subClient
            };

            _pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);

            _pusher.Trigger(channelName, eventName, eventData);

            _subClient.Received().Execute(
                Arg.Is <IRestRequest>(
                    x => CheckRequestScheme("http", _subClient, x)
                    )
                );
        }
コード例 #4
0
        public void trigger_calls_are_made_over_port_443_when_Encrypted_option_is_set()
        {
            IPusherOptions options = new PusherOptions()
            {
                RestClient = _subClient,
                Encrypted  = true,
                HostName   = Config.HttpHost
            };

            _pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);

            _pusher.Trigger(channelName, eventName, eventData);

            _subClient.Received().Execute(
                Arg.Is <IRestRequest>(
                    x => _CheckRequestPort(443, _subClient, x)
                    )
                );
        }
コード例 #5
0
        public void trigger_calls_are_made_over_configured_Port_when_option_is_set()
        {
            int            expectedPort = 900;
            IPusherOptions options      = new PusherOptions()
            {
                RestClient = _subClient,
                Port       = expectedPort
            };

            _pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);

            _pusher.Trigger(channelName, eventName, eventData);

            _subClient.Received().Execute(
                Arg.Is <IRestRequest>(
                    x => _CheckRequestPort(expectedPort, _subClient, x)
                    )
                );
        }
コード例 #6
0
        public void trigger_calls_are_made_over_HTTPS_when_Encrypted_option_is_set()
        {
            IPusherOptions options = new PusherOptions()
            {
                RestClient = _subClient,
                Encrypted  = true
            };

            _pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);

            ITriggerResult result =
                _pusher.Trigger(
                    channelName,
                    eventName,
                    eventData
                    );

            _subClient.Received().Execute(
                Arg.Is <IRestRequest>(
                    x => CheckRequestIsMadeOver("https://", _subClient, x)
                    )
                );
        }
コード例 #7
0
        public void trigger_calls_are_made_over_port_443_when_Encrypted_option_is_set()
        {
            IPusherOptions options = new PusherOptions()
            {
                RestClient = _subClient,
                Encrypted = true
            };

            _pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);

            ITriggerResult result =
                _pusher.Trigger(
                    channelName,
                    eventName,
                    eventData
                );

            _subClient.Received().Execute(
                Arg.Is<IRestRequest>(
                    x => _CheckRequestPort(443, _subClient, x)
                )
            );
        }
コード例 #8
0
        public void trigger_calls_are_made_over_HTTP_by_default()
        {
            IPusherOptions options = new PusherOptions()
            {
                RestClient = _subClient
            };

            _pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);

            ITriggerResult result =
                _pusher.Trigger(
                    channelName,
                    eventName,
                    eventData
                );

            _subClient.Received().Execute(
                Arg.Is<IRestRequest>(
                    x => CheckRequestIsMadeOver("http://", _subClient, x)
                )
            );
        }
コード例 #9
0
        public void trigger_calls_are_made_over_configured_Port_when_option_is_set()
        {
            int expectedPort = 900;
            IPusherOptions options = new PusherOptions()
            {
                RestClient = _subClient,
                Port = expectedPort
            };

            _pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);

            ITriggerResult result =
                _pusher.Trigger(
                    channelName,
                    eventName,
                    eventData
                );

            _subClient.Received().Execute(
                Arg.Is<IRestRequest>(
                    x => _CheckRequestPort(expectedPort, _subClient, x)
                )
            );
        }
コード例 #10
0
        public void It_should_return_a_200_response()
        {
            ITriggerResult result = _pusher.Trigger("my-channel", "my_event", new { hello = "world" });

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }