public async void SendActivitiesAsyncShouldSucceedAndNoActivityReturnedWithActivityTypeNotMessage() { // Arrange var activity = new Mock <Activity>().SetupAllProperties(); activity.Object.Type = ActivityTypes.Trace; activity.Object.Attachments = new List <Attachment> { new Attachment(contentUrl: "http://example.com") }; activity.Object.Conversation = new ConversationAccount(id: "MockId"); activity.Object.Text = "Trace content"; const string resourceIdentifier = "ringCentralContentId"; var mockOptions = new RingCentralOptions() { RingCentralEngageApiAccessToken = "1111", RingCentralEngageApiUrl = "http://someurl.com", BotId = "testbot" }; var rcw = new Mock <RingCentralClientWrapper>(OptionsHelper.GetOptionsMonitor(mockOptions)); var mockBotAdapter = new Mock <IBotFrameworkHttpAdapter>().Object; rcw.Setup(x => x.SendContentToRingCentralAsync(activity.Object, "9f4bba850e69dc636a707fd6")).Returns(Task.FromResult(resourceIdentifier)); var adapter = new RingCentralAdapter(rcw.Object, mockBotAdapter, new StaticHandoffRequestRecognizer()); // Act var resourceResponses = await adapter.SendActivitiesAsync(null, new Activity[] { activity.Object }, default).ConfigureAwait(false); // Assert Assert.True(resourceResponses.Length == 0); }
public async void SendActivitiesAsyncShouldSucceed() { var activity = new Mock <Activity>().SetupAllProperties(); activity.Object.Type = "message"; activity.Object.Attachments = new List <Attachment> { new Attachment(contentUrl: "http://example.com") }; activity.Object.Conversation = new ConversationAccount(id: "MockId"); activity.Object.Text = "Hello, Bot!"; var turnContext = new Mock <ITurnContext>(); turnContext.SetupGet(tc => tc.Activity).Returns(() => new Activity() { ChannelData = new RingCentralChannelData() { SourceId = "9f4bba850e69dc636a707fd6", ThreadId = "a_thread_id" } }); const string resourceIdentifier = "ringCentralContentId"; var mockOptions = new RingCentralOptions() { RingCentralEngageApiAccessToken = "1111", RingCentralEngageApiUrl = "http://someurl.com", BotId = "testbot" }; var rcw = new Mock <RingCentralClientWrapper>(OptionsHelper.GetOptionsMonitor(mockOptions)); var mockBotAdapter = new Mock <IBotFrameworkHttpAdapter>().Object; rcw.Setup(x => x.SendContentToRingCentralAsync(activity.Object, "9f4bba850e69dc636a707fd6")).Returns(Task.FromResult(resourceIdentifier)); var adapter = new RingCentralAdapter(rcw.Object, mockBotAdapter, new StaticHandoffRequestRecognizer()); var resourceResponses = await adapter.SendActivitiesAsync(turnContext.Object, new Activity[] { activity.Object }, default).ConfigureAwait(false); Assert.True(resourceResponses[0].Id == resourceIdentifier); }