Example #1
0
        public void SimpleUpdate()
        {
            // given
            var client = ClientHelper.GetClient(_config.Slack.UserAuthToken);
            var messageId = PostedMessage(client);
            UpdateResponse actual = null;

            // when
            using (var sync = new InSync())
            {
                client.Update(
                    response =>
                    {
                        actual = response;
                        sync.Proceed();
                    },
                    messageId,
                    _config.Slack.TestChannel,
                    "[changed]",
                    attachments: SlackMother.SomeAttachments,
                    as_user: true);
            }

            // then
            Assert.IsTrue(actual.Ok, "Error while posting message to channel. ");
            Assert.AreEqual(actual.message.text, "[changed]");
            Assert.AreEqual(actual.message.type, "message");
        }
Example #2
0
 public void UpdatePresence()
 {
     var client = ClientHelper.GetClient(_config.Slack.UserAuthToken);
     using (var sync = new InSync())
     {
         client.EmitPresence((presence) =>
         {
             presence.AssertOk();
             sync.Proceed();
         }, Presence.away);
     }
 }
Example #3
0
 private string PostedMessage(SlackSocketClient client)
 {
     string messageId = null;
     using (var sync = new InSync())
     {
         client.PostMessage(
             response =>
             {
                 messageId = response.ts;
                 Assert.IsTrue(response.Ok, "Error while posting message to channel. ");
                 sync.Proceed();
             },
             _config.Slack.TestChannel,
             "Hi there!",
             as_user: true);
     }
     return messageId;
 }
Example #4
0
        public void Attachments()
        {
            // given
            var client = ClientHelper.GetClient(_config.Slack.UserAuthToken);
            PostMessageResponse actual = null;

            // when
            using (var sync = new InSync())
            {
                client.PostMessage(
                    response =>
                    {
                        actual = response;
                        sync.Proceed();
                    },
                    _config.Slack.TestChannel,
                    string.Empty,
                    attachments: SlackMother.SomeAttachments);
            }

            // then
            Assert.IsTrue(actual.Ok, "Error while posting message to channel. ");
        }
Example #5
0
        public void SimpleMessageDelivery()
        {
            // given
            var client = ClientHelper.GetClient(_config.Slack.UserAuthToken);
            PostMessageResponse actual = null;

            // when
            using (var sync = new InSync())
            {
                client.PostMessage(
                    response =>
                    {
                        actual = response;
                        sync.Proceed();
                    },
                    _config.Slack.TestChannel,
                    "Hi there!");
            }

            // then
            Assert.IsTrue(actual.Ok, "Error while posting message to channel. ");
            Assert.AreEqual(actual.message.text, "Hi there!");
            Assert.AreEqual(actual.message.type, "message");
        }