Beispiel #1
0
        public async Task HandlesBotAndSkillsTestCases(FlowTestCase testCase, bool shouldSendEoc)
        {
            var dialog   = new SimpleComponentDialog();
            var testFlow = CreateTestFlow(dialog, testCase, locale: "en-GB");
            await testFlow.Send("Hi")
            .AssertReply("Hello, what is your name?")
            .Send("SomeName")
            .AssertReply("Hello SomeName, nice to meet you!")
            .StartTestAsync();

            Assert.AreEqual(DialogReason.EndCalled, dialog.EndReason);

            if (shouldSendEoc)
            {
                Assert.IsNotNull(_eocSent, "Skills should send EndConversation to channel");
                Assert.AreEqual(ActivityTypes.EndOfConversation, _eocSent.Type);
                Assert.AreEqual(EndOfConversationCodes.CompletedSuccessfully, _eocSent.Code);
                Assert.AreEqual("SomeName", _eocSent.Value);
                Assert.AreEqual("en-GB", _eocSent.Locale);
            }
            else
            {
                Assert.IsNull(_eocSent, "Root bot should not send EndConversation to channel");
            }
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public async Task SkillHandlesEocFromParent()
        {
            var dialog   = new SimpleComponentDialog();
            var testFlow = CreateTestFlow(dialog, FlowTestCase.LeafSkill);
            await testFlow.Send("Hi")
            .AssertReply("Hello, what is your name?")
            .Send(new Activity(ActivityTypes.EndOfConversation)
            {
                CallerId = _parentBotId
            })
            .StartTestAsync();

            Assert.IsNull(_eocSent, "Skill should not send back EoC when an EoC is sent from a parent");
            Assert.AreEqual(DialogReason.CancelCalled, dialog.EndReason);
        }
Beispiel #4
0
        public async Task SkillHandlesRepromptFromParent()
        {
            var dialog   = new SimpleComponentDialog();
            var testFlow = CreateTestFlow(dialog, FlowTestCase.LeafSkill);
            await testFlow.Send("Hi")
            .AssertReply("Hello, what is your name?")
            .Send(new Activity(ActivityTypes.Event)
            {
                CallerId = _parentBotId,
                Name     = DialogEvents.RepromptDialog
            })
            .AssertReply("Hello, what is your name?")
            .StartTestAsync();

            Assert.AreEqual(DialogReason.BeginCalled, dialog.EndReason);
        }