Ejemplo n.º 1
0
        private async Task should_raise_unknown_reaction_event(
            Mock <IWebSocketClient> webSocket,
            SlackConnection slackConnection)
        {
            // given
            var fixture        = new Fixture();
            var connectionInfo = new ConnectionInformation
            {
                Users =
                {
                    { "some-user",    new SlackUser {
                          Id = "some-user", Name = "i-have-a-name"
                      } },
                    { "another-user", new SlackUser {
                          Id = "another-user", Name = "i-have-a-name-too-thanks"
                      } }
                },
                WebSocket = webSocket.Object
            };
            await slackConnection.Initialise(connectionInfo);

            ISlackReaction lastReaction = null;

            slackConnection.OnReaction += reaction =>
            {
                lastReaction = reaction;
                return(Task.CompletedTask);
            };

            var inboundMessage = new ReactionMessage
            {
                User           = "******",
                Reaction       = fixture.Create <string>(),
                RawData        = fixture.Create <string>(),
                ReactingToUser = null,
                Timestamp      = fixture.Create <double>(),
                ReactingTo     = new UnknownReaction()
            };

            // when
            webSocket.Raise(x => x.OnMessage += null, null, inboundMessage);

            // then
            lastReaction.ShouldLookLike(new SlackUnknownReaction
            {
                User           = connectionInfo.Users["some-user"],
                Reaction       = inboundMessage.Reaction,
                RawData        = inboundMessage.RawData,
                ReactingToUser = null,
                Timestamp      = inboundMessage.Timestamp
            });
        }
Ejemplo n.º 2
0
        private async Task RaiseReactionReceived(ISlackReaction reaction)
        {
            var e = this.OnReaction;

            if (e != null)
            {
                try
                {
                    await e(reaction);
                }
                catch (Exception)
                {
                }
            }
        }
Ejemplo n.º 3
0
 private Task SlackConnectionOnOnReaction(ISlackReaction message)
 {
     return(Task.CompletedTask);
 }