Esempio n. 1
0
        public void SlackNotificationClient_WithWrongUrl_ThrowWebException()
        {
            var slackInitParam = new SlackInitParams()
            {
                Channel  = null,
                Username = null,
                Url      = "https://hooks.slack.com/services/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"
            };

            var    slackClient = new SlackNotificationClient(slackInitParam, 0, new JsonSerializer());
            Action result      = () => slackClient.Send(_message);

            result.Should().Throw <WebException>().WithMessage("Serwer zdalny zwrócił błąd: (404) Nie znaleziono.");
        }
Esempio n. 2
0
        public SlackNotificationClient(SlackInitParams initParams, int id, ISerializer serializer) : base(id)
        {
            if (string.IsNullOrEmpty(initParams.Url))
            {
                throw new ArgumentNullException($"{nameof(initParams.Url)} is empty!");
            }
            _params     = initParams;
            _serializer = serializer;
            _uri        = new Uri(initParams.Url);

            if (!string.IsNullOrEmpty(initParams.ConfigPath))
            {
                var json = File.ReadAllText(initParams.ConfigPath, Encoding.Default);
                _color = _serializer.Deserialize <Dictionary <string, string> >(json);
            }
        }
Esempio n. 3
0
        public void SlackNotificationClient_CheckSlackConfig_ChangeColor()
        {
            var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\SlackConfig.json";

            var slackInitParam = new SlackInitParams()
            {
                Channel          = null,
                Username         = null,
                ExtractTheHeader = true,
                Url        = "https://hooks.slack.com/services/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",
                ConfigPath = path
            };

            var    slackClient = new SlackNotificationClient(slackInitParam, 0, new JsonSerializer());
            Action result      = () => slackClient.Send(_message);

            result.Should().Throw <WebException>().WithMessage("Serwer zdalny zwrócił błąd: (404) Nie znaleziono.");
        }