Esempio n. 1
0
        public void TestInitiating()
        {
            Greetings     dialogUnit = new Greetings();
            DialogContext context    = new DialogContext();

            DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Привет!", "Здрасте!");

            context.Upsert(new ClientName("Иван"));
            DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Привет, Иван!", "Здрасте!");

            context.Upsert(new ClientName(null));
            DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Привет!", "Здрасте!");
        }
Esempio n. 2
0
        public void TestInitiating()
        {
            Farewell      dialogUnit = new Farewell();
            DialogContext context    = new DialogContext();

            DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Пока!", "До свидания!");

            context.Upsert(new ClientName("Иван"));
            DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Пока, Иван!", "пока");

            context.Upsert(new ClientName(null));
            DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Пока!", "пока!");
        }
Esempio n. 3
0
        public void TestResponding()
        {
            Farewell      dialogUnit = new Farewell();
            DialogContext context    = new DialogContext();

            DialogUnitTestUtils.TestResponding(dialogUnit, context, "Пока!", "Пока!");

            context.Upsert(new ClientName("Иван"));
            DialogUnitTestUtils.TestResponding(dialogUnit, context, "Пока!", "Пока, Иван!");
        }
Esempio n. 4
0
        public void TestStating()
        {
            QuestionsCanAsk dialogUnit = new QuestionsCanAsk();
            DialogContext   context    = new DialogContext();

            DialogUnitTestUtils.TestStating(dialogUnit, context, "Ты можешь спросить меня:");

            context.Upsert(new ClientName("Иван"));
            DialogUnitTestUtils.TestStating(dialogUnit, context, "Иван, ты можешь спросить меня:");
        }
Esempio n. 5
0
        public void TestDifferentClientLists(string[] clients, string expectedAnswer)
        {
            DialogUnit    dialogUnit = new ConnectedClients();
            DialogContext context    = new DialogContext();

            context.Upsert <GetConnectedClients>(() => clients);

            DialogUnitHandleResult result = dialogUnit.Handle(context, "список пользователей");

            Assert.True(result.IsHandled);
            Assert.Equal(expectedAnswer, result.Message);
            Assert.False(result.IsResponseAwaiting);
        }
Esempio n. 6
0
        public void TestRespondingOnDifferentQuestions(string question)
        {
            DialogUnit    dialogUnit = new ConnectedClients();
            DialogContext context    = new DialogContext();

            context.Upsert <GetConnectedClients>(() => new string[] { "Иван" });

            DialogUnitHandleResult result = dialogUnit.Handle(context, question);

            Assert.True(result.IsHandled);
            Assert.Equal($"\n - Иван", result.Message);
            Assert.False(result.IsResponseAwaiting);
        }
Esempio n. 7
0
        public void TestNext()
        {
            Greetings       greetings       = new Greetings();
            WhatsYourName   whatsYourName   = new WhatsYourName();
            QuestionsCanAsk questionsCanAsk = new QuestionsCanAsk();

            DialogPlanItem[] items = new DialogPlanItem[]
            {
                new DialogPlanItem(new DialogUnit[] { greetings, whatsYourName }),

                new DialogPlanItem(
                    questionsCanAsk,
                    (context) => context.HasItem <ClientName>())
            };

            DialogPlan    dialogPlan    = new DialogPlan(items);
            DialogContext dialogContext = new DialogContext();

            Assert.Equal(new DialogUnit[] { greetings, whatsYourName }, dialogPlan.Next(dialogContext));
            Assert.Empty(dialogPlan.Next(dialogContext));

            dialogContext.Upsert(new ClientName(null));
            Assert.Equal(new DialogUnit[] { questionsCanAsk }, dialogPlan.Next(dialogContext));
        }
Esempio n. 8
0
 protected override void AddAnswerToContext(DialogContext context, string answer)
 {
     context.Upsert(new ClientName(answer));
 }