コード例 #1
0
        public async Task ShowsFirstMessageAndCallsAzureDialogDirectly()
        {
            // Arrange
            var feedbackOptions     = new FeedbackOptions();
            var mockTemplateManager = SimpleMockFactory.CreateMockTemplateManager("mock template message");

            var mockDialog = new Mock <AzureDialog>(Configuration, _telemetryClient, mockTemplateManager.Object);

            mockDialog.Setup(x => x.BeginDialogAsync(It.IsAny <DialogContext>(), It.IsAny <object>(), It.IsAny <CancellationToken>()))
            .Returns(async(DialogContext dialogContext, object options, CancellationToken cancellationToken) =>
            {
                dialogContext.Dialogs.Add(new TextPrompt("MockDialog"));
                return(await dialogContext.PromptAsync("MockDialog",
                                                       new PromptOptions()
                {
                    Prompt = MessageFactory.Text($"{nameof(AzureDialog)} mock invoked")
                }, cancellationToken));
            });
            var fileSearchDialog = new Mock <FileSearchDialog>(_telemetryClient, Configuration);

            var mainDialog = new MainDialog(_telemetryClient, feedbackOptions, _mockLogger.Object, mockTemplateManager.Object, _userState, mockDialog.Object, fileSearchDialog.Object);
            var testClient = new DialogTestClient(Channels.Test, mainDialog, middlewares: new[] { new XUnitDialogTestLogger(Output) });

            // Act/Assert
            var reply = await testClient.SendActivityAsync <IMessageActivity>("hi");

            Assert.Equal("mock template message", reply.Text);

            reply = await testClient.SendActivityAsync <IMessageActivity>("next");

            Assert.Equal($"{nameof(AzureDialog)} mock invoked", reply.Text);
        }
コード例 #2
0
        public async Task ShowsAnswerFromQnAMaker()
        {
            var mockTemplateManager = SimpleMockFactory.CreateMockTemplateManager("mock template message");
            var azureDialog         = new AzureDialog(_configurationLazy.Value, _telemetryClient, mockTemplateManager.Object);
            var testClient          = new DialogTestClient(Channels.Test, azureDialog, middlewares: new[] { new XUnitDialogTestLogger(Output) });

            var reply = await testClient.SendActivityAsync <IMessageActivity>("azure database for mysql");

            Assert.NotNull(reply);
        }