Exemplo n.º 1
0
            public void AddsToAttachments()
            {
                var attachment = new SlackAttachment();
                int initial    = _sut.Attachments.Count;

                _result = _sut.Attach(attachment);

                Assert.AreEqual(initial + 1, _sut.Attachments.Count);
            }
Exemplo n.º 2
0
 public void Setup()
 {
     _slackMessage = new SlackMessage();
     _attachment   = new SlackAttachment();
     _slackMessage.Attach(_attachment);
     settings = new JsonSerializerSettings {
         ContractResolver = new LowerCaseContractResolver()
     };
 }
Exemplo n.º 3
0
            public void SetsAttachmentTextWhenPossible()
            {
                var randomMessage = Helpers.Random;
                var attachment    = new SlackAttachment {
                };
                var sut           = new SlackMessage();

                sut.Attach(attachment);

                sut.WithMessageText(randomMessage);

                Assert.AreEqual(randomMessage, attachment.Text);
            }
Exemplo n.º 4
0
            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 AddDefaultAttachment()
 {
     Sut.Attach(DefaultAttachment);
 }