public async Task SendActivitiesAsyncShouldSucceed() { var slackResponse = new SlackResponse { Ok = true, Ts = "mockedTS", }; var slackApi = new Mock <SlackClientWrapper>(_testOptions); slackApi.Setup(x => x.TestAuthAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult("mockedUserId")); slackApi.Setup(x => x.PostMessageAsync(It.IsAny <NewSlackMessage>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(slackResponse)); var slackAdapter = new SlackAdapter(slackApi.Object); var activity = new Activity { Type = ActivityTypes.Message, Text = "text", Conversation = new ConversationAccount() { Id = "testConversationId", }, }; Activity[] activities = { activity }; var turnContext = new TurnContext(slackAdapter, activity); var responses = await slackAdapter.SendActivitiesAsync(turnContext, activities, default); Assert.Equal(slackResponse.Ts, responses[0].Id); }
public async Task SendActivitiesAsyncShouldThrowExceptionWithNullContext() { var slackApi = new Mock <SlackClientWrapper>(_testOptions); slackApi.Setup(x => x.TestAuthAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult("mockedUserId")); var slackAdapter = new SlackAdapter(slackApi.Object); var activity = new Activity { Id = "testId", Type = ActivityTypes.Message, Text = "text", Conversation = new ConversationAccount() { Id = "testConversationId", }, }; Activity[] activities = { activity }; await Assert.ThrowsAsync <ArgumentNullException>(async() => { await slackAdapter.SendActivitiesAsync(null, activities, default); }); }