示例#1
0
        public void TestNotResponding()
        {
            WhatsYourName dialogUnit = new WhatsYourName();
            DialogContext context    = new DialogContext();

            DialogUnitTestUtils.TestNotResponding(dialogUnit, context, "привет");
        }
示例#2
0
        public void TestAsking(string response, string expectedName)
        {
            WhatsYourName dialogUnit = new WhatsYourName();
            DialogContext context    = new DialogContext();

            DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Как тебя зовут?", response);
            ClientName clientName = context.GetItem <ClientName>();

            Assert.NotNull(clientName);
            Assert.Equal(expectedName, clientName.Value);
        }
示例#3
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));
        }