public static void ConversationRunner(IConversation conversation) { IEnumerable<IDialog> currentDialogs = conversation.CurrentDialogs().ToList(); Console.WriteLine(conversation.GetDescription()); Console.WriteLine(""); Console.WriteLine("----------------------------"); while (currentDialogs.Any()) { if (currentDialogs.Count() == 1) { Console.WriteLine("-" + currentDialogs.First().GetText()); Console.ReadKey(); conversation.Next(); } else if (currentDialogs.Count() > 1) { Console.WriteLine("(Select an answer) 1-"+currentDialogs.Count()+")"); int i = 1; foreach (var dialog in currentDialogs) { Console.WriteLine(" "+i+")"+dialog.GetText()); i++; } int answer = ReadAnswerNumber(1, currentDialogs.Count()); conversation.Answer(currentDialogs.ToList()[answer-1]); } currentDialogs = conversation.CurrentDialogs(); } }
public static void ConversationRunner(IConversation conversation) { IEnumerable <IDialog> currentDialogs = conversation.CurrentDialogs().ToList(); Console.WriteLine(conversation.GetDescription()); Console.WriteLine(""); Console.WriteLine("----------------------------"); while (currentDialogs.Any()) { if (currentDialogs.Count() == 1) { Console.WriteLine("-" + currentDialogs.First().GetText()); Console.ReadKey(); conversation.Next(); } else if (currentDialogs.Count() > 1) { Console.WriteLine("(Select an answer) 1-" + currentDialogs.Count() + ")"); int i = 1; foreach (var dialog in currentDialogs) { Console.WriteLine(" " + i + ")" + dialog.GetText()); i++; } int answer = ReadAnswerNumber(1, currentDialogs.Count()); conversation.Answer(currentDialogs.ToList()[answer - 1]); } currentDialogs = conversation.CurrentDialogs(); } }
public void If_Start_Is_Branched_Get_Available_Dialogs() { conversation.SetStartDialog(new[] { dialog1, dialog2 }.ToList()); Assert.AreEqual(2, conversation.CurrentDialogs().Count()); }
public void Should_Set_Start() { conversation.SetStartDialog(new[] { dialog1 }.ToList()); Assert.AreEqual(dialog1, conversation.CurrentDialogs().First()); }