public void TestMenu() { m_player.ClearBuffer(); m_player.LatestMenu = null; m_game.SendCommand("x twin"); Assert.AreEqual("- <i>Please select which twin you mean:</i>", m_player.Buffer(1)); Assert.AreEqual(2, m_player.BufferLength, "Expected nothing else in the output buffer after menu displayed"); Assert.AreNotEqual(null, m_player.LatestMenu); Assert.AreEqual(2, m_player.LatestMenu.Options.Count); Assert.AreEqual("Twin 1", m_player.LatestMenu.Options.ElementAt(0).Value); Assert.AreEqual("Twin 2", m_player.LatestMenu.Options.ElementAt(1).Value); m_game.SetMenuResponse(m_player.LatestMenu.Options.ElementAt(0).Key); Assert.AreEqual("It's twin 1", m_player.Buffer(3)); }
public void ShowMenu(MenuData menuData) { ClearBuffer(); OutputText(menuData.Caption + "<br/>"); foreach (var option in menuData.Options) { OutputText(string.Format("{0}: {1}<br/>", option.Key, option.Value)); } string response; do { response = Console.ReadLine(); } while (!menuData.Options.ContainsKey(response)); Thread newThread = new Thread(() => { m_game.SetMenuResponse(response); ClearBuffer(); }); newThread.Start(); }