public void ReturnsTextKey()
 {
     var sut = new SlackClient(Helpers.Random);
     var jsonString = sut.GetJson(Helpers.Random);
     var jobject = JObject.Parse(jsonString);
     Assert.IsNotNull(jobject.SelectToken("text"));
 }
Example #2
0
        public void MoreTalking()
        {
            DataTable dtable = new DataTable();
            dtable.Columns.Add("Class");
            dtable.Columns.Add("Errors/Failures/Totals");

            dtable.Rows.Add("BusinessObjects.Domains.Tests-nunitTestResults", "0/0/64");
            dtable.Rows.Add("BusinessObjects.Domains.Tests-nunitTestResults", "0/6/6");

            sut = new SlackClient(new Uri("https://hooks.slack.com/services/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").ToString());
            var msg = new SlackMessage();
            //msg.Attach(new SlackAttachment());
            msg.AddData(dtable)
                //.UsingLeftBarColor(Color.White)
                ;

            sut.Send(msg);
        }
Example #3
0
 public void Setup()
 {
     sut = new SlackClient("https://hooks.slack.com/services/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");
 }
            public void Setup()
            {
                messageString = Helpers.Random;
                sut = new SlackClient(Helpers.RandomUri.OriginalString);
                _JsonPathAndValues = new Dictionary<string, string>
                {
                    {"attachments[0].fallback",Helpers.Random}
                    ,{"attachments[0].color",Color.Gold.ToHex()}
                    ,{"attachments[0].pretext",Helpers.Random}
                    ,{"attachments[0].text",messageString}
                    ,{"attachments[0].author_name",Helpers.Random}
                    ,{"attachments[0].author_icon",Helpers.RandomUri.OriginalString}
                    ,{"attachments[0].author_link",Helpers.RandomUri.OriginalString}
                    ,{"attachments[0].title",Helpers.Random}
                    ,{"attachments[0].title_link",Helpers.RandomUri.OriginalString}
                    ,{"attachments[0].fields[0].title",Helpers.Random}
                    ,{"attachments[0].fields[0].value",Helpers.Random}
                    ,{"attachments[0].fields[0].short","True"}
                    ,{"attachments[0].image_url",Helpers.RandomUri.OriginalString}
                    ,{"attachments[0].thumb_url",Helpers.RandomUri.OriginalString}
                    ,{"username",Helpers.Random}
                    , {"text",messageString }
                };
                _fallback = _JsonPathAndValues["attachments[0].fallback"];
                _pretext = _JsonPathAndValues["attachments[0].pretext"];
                _color =  _JsonPathAndValues["attachments[0].color"].ToColor();
                _authorIcon = new Uri(_JsonPathAndValues["attachments[0].author_icon"]);
                _authorName = _JsonPathAndValues["attachments[0].author_name"];
                _authorLink = new Uri(_JsonPathAndValues["attachments[0].author_link"]); ;
                _titleName = _JsonPathAndValues["attachments[0].title"];
                _titleLink = new Uri(_JsonPathAndValues["attachments[0].title_link"]);
                _text = _JsonPathAndValues["attachments[0].text"];
                _fieldTitle = _JsonPathAndValues["attachments[0].fields[0].title"];
                _fieldValue = _JsonPathAndValues["attachments[0].fields[0].value"];
                _fieldShort = bool.Parse(_JsonPathAndValues["attachments[0].fields[0].short"]);
                _thumbUrl = new Uri(_JsonPathAndValues["attachments[0].thumb_url"]);
                _imageUrl = new Uri(_JsonPathAndValues["attachments[0].image_url"]);
                _username = _JsonPathAndValues["username"];
                _attachment = new SlackAttachment
                {
                    Fallback = _fallback
                    ,Author = new SlackAuthor { Icon = _authorIcon, Link = _authorLink, Name = _authorName}
                    ,Color = _color
                    ,Pretext = _pretext
                    ,Title = new LinkedElement {Link = _titleLink, Name = _titleName}
                    ,Text = _text
                    ,ImageUri = _imageUrl
                    ,ThumbUri = _thumbUrl

                };
                _attachment.AddField(_fieldTitle, _fieldValue, _fieldShort);
                _message = new SlackMessage
                {
                };
                _message.WithMessageText(_text);
                _message.Attach(_attachment);
                _message.AsUser(_username);

                _json = sut.GetJson(_message);
            }
 public void WebHookUrl()
 {
     var sut = new SlackClient(Helpers.Random);
     Assert.IsNotNull(sut.WebHookUrl);
 }