Exemplo n.º 1
0
        public async Task RunAsyncShouldSetTelemetryClient()
        {
            var adapter           = new Mock <BotAdapter>();
            var dialog            = new SimpleComponentDialog();
            var conversationState = new ConversationState(new MemoryStorage());

            // ChannelId and Conversation.Id are required for ConversationState and
            // ChannelId and From.Id are required for UserState.
            var activity = new Activity
            {
                ChannelId    = "test-channel",
                Conversation = new ConversationAccount {
                    Id = "test-conversation-id"
                },
                From = new ChannelAccount {
                    Id = "test-id"
                }
            };

            var telemetryClientMock = new Mock <IBotTelemetryClient>();

            using (var turnContext = new TurnContext(adapter.Object, activity))
            {
                turnContext.TurnState.Add(telemetryClientMock.Object);

                await DialogExtensions.RunAsync(dialog, turnContext, conversationState.CreateProperty <DialogState>("DialogState"), CancellationToken.None);
            }

            Assert.Equal(telemetryClientMock.Object, dialog.TelemetryClient);
        }
Exemplo n.º 2
0
 /// <inheritdoc/>
 public Task RunAsync(ITurnContext turnContext, IStatePropertyAccessor <DialogState> accessor, CancellationToken cancellationToken)
 {
     return(DialogExtensions.RunAsync(this, turnContext, accessor, cancellationToken));
 }