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, "Привет!", "Здрасте!"); }
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, "Пока!", "пока!"); }
public void TestResponding() { Farewell dialogUnit = new Farewell(); DialogContext context = new DialogContext(); DialogUnitTestUtils.TestResponding(dialogUnit, context, "Пока!", "Пока!"); context.Upsert(new ClientName("Иван")); DialogUnitTestUtils.TestResponding(dialogUnit, context, "Пока!", "Пока, Иван!"); }
public void TestStating() { QuestionsCanAsk dialogUnit = new QuestionsCanAsk(); DialogContext context = new DialogContext(); DialogUnitTestUtils.TestStating(dialogUnit, context, "Ты можешь спросить меня:"); context.Upsert(new ClientName("Иван")); DialogUnitTestUtils.TestStating(dialogUnit, context, "Иван, ты можешь спросить меня:"); }
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); }
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); }
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)); }
protected override void AddAnswerToContext(DialogContext context, string answer) { context.Upsert(new ClientName(answer)); }