public async Task LegacyConversationIdFactoryTest() { var legacyFactory = new TestLegacyConversationIdFactory(); var conversationReference = new ConversationReference { Conversation = new ConversationAccount(id: Guid.NewGuid().ToString("N")), ServiceUrl = "http://testbot.com/api/messages" }; // Testing the deprecated method for backward compatibility. #pragma warning disable 618 var conversationId = await legacyFactory.CreateSkillConversationIdAsync(conversationReference, CancellationToken.None); #pragma warning restore 618 BotCallbackHandler botCallback = null; _mockAdapter.Setup(x => x.ContinueConversationAsync(It.IsAny <ClaimsIdentity>(), It.IsAny <ConversationReference>(), It.IsAny <string>(), It.IsAny <BotCallbackHandler>(), It.IsAny <CancellationToken>())) .Callback <ClaimsIdentity, ConversationReference, string, BotCallbackHandler, CancellationToken>((identity, reference, audience, callback, cancellationToken) => { botCallback = callback; Console.WriteLine("blah"); }); var sut = CreateSkillHandlerForTesting(legacyFactory); var activity = Activity.CreateMessageActivity(); activity.ApplyConversationReference(conversationReference); await sut.TestOnSendToConversationAsync(_claimsIdentity, conversationId, (Activity)activity, CancellationToken.None); Assert.IsNotNull(botCallback); await botCallback.Invoke(new TurnContext(_mockAdapter.Object, (Activity)activity), CancellationToken.None); }
public async Task LegacyConversationIdFactoryWorksTest() { var legacyFactory = new TestLegacyConversationIdFactory(); var conversationReference = new ConversationReference { Conversation = new ConversationAccount(id: Guid.NewGuid().ToString("N")), ServiceUrl = "http://testbot.com/api/messages" }; // Testing the deprecated method for backward compatibility. #pragma warning disable 612 var conversationId = await legacyFactory.CreateSkillConversationIdAsync(conversationReference, CancellationToken.None); #pragma warning restore 612 _mockAdapter.Setup(x => x.ContinueConversationAsync(It.IsAny <ClaimsIdentity>(), It.IsAny <ConversationReference>(), It.IsAny <string>(), It.IsAny <BotCallbackHandler>(), It.IsAny <CancellationToken>())) .Callback <ClaimsIdentity, ConversationReference, string, BotCallbackHandler, CancellationToken>(async(identity, reference, audience, callback, cancellationToken) => { // Invoke the callback created by the handler so we can assert the rest of the execution. var turnContext = new TurnContext(_mockAdapter.Object, _conversationReference.GetContinuationActivity()); await callback(turnContext, cancellationToken); }); var activity = Activity.CreateMessageActivity(); activity.ApplyConversationReference(conversationReference); var sut = CreateSkillHandlerForTesting(legacyFactory); await sut.TestOnSendToConversationAsync(_claimsIdentity, conversationId, (Activity)activity, CancellationToken.None); }