Esempio n. 1
0
        public async void TipShouldSucceedOnMultipleRecipients()
        {
            const decimal tipAmount  = 42;
            const decimal balance    = 400;
            var           recipients = $"<@{TestConstants.RecipientAccount.SlackId}>, <@{TestConstants.RecipientAccount2.SlackId}>";
            var           txId2      = txId + 1;
            var           message    = CreateChannelMessage($"<@{botUserId}> tip {recipients} {tipAmount}");

            SetupNxtAccount(TestConstants.SenderAccount, balance);
            SetupNxtAccount(TestConstants.RecipientAccount, 0);
            SetupNxtAccount(TestConstants.RecipientAccount2, 0);

            nxtConnectorMock.Setup(c => c.Transfer(
                                       It.Is <NxtAccount>(a => a == TestConstants.SenderAccount),
                                       It.Is <string>(r => r == TestConstants.RecipientAccount.NxtAccountRs),
                                       It.Is <NxtTransferable>(t => t == Nxt.Singleton),
                                       It.Is <decimal>(amount => amount == tipAmount),
                                       It.IsAny <string>(),
                                       It.IsAny <string>()))
            .ReturnsAsync(txId);

            nxtConnectorMock.Setup(c => c.Transfer(
                                       It.Is <NxtAccount>(a => a == TestConstants.SenderAccount),
                                       It.Is <string>(r => r == TestConstants.RecipientAccount2.NxtAccountRs),
                                       It.Is <NxtTransferable>(t => t == Nxt.Singleton),
                                       It.Is <decimal>(amount => amount == tipAmount),
                                       It.IsAny <string>(),
                                       It.IsAny <string>()))
            .ReturnsAsync(txId2);

            slackConnectorMock.Setup(c => c.GetInstantMessageId(It.Is <string>(id => id == TestConstants.RecipientAccount.SlackId))).ReturnsAsync(imSession.Id);

            await slackHandler.TipBotChannelCommand(message, slackUser, channelSession);

            slackConnectorMock.Verify(c => c.SendMessage(channelSession.Id,
                                                         It.Is <string>(input => input.Equals(MessageConstants.MultitipSentChannel(slackUser.Id, recipients, tipAmount, "NXT", ""))), true));
            slackConnectorMock.Verify(c => c.SendMessage(imSession.Id,
                                                         It.Is <string>(input => input.Equals(MessageConstants.TipSentDirectMessage(slackUser.Id, tipAmount, "NXT", txId))), true));
        }