コード例 #1
0
        public void SimpleScenario_Colors()
        {
            var console = new TestConsole {
                Details = true
            };

            console.AddUserInput("2");

            var menu = new ConsoleMenu()
            {
                Console = console
            }
            .Add("One", () => { })
            .Add("Two", () => { })
            .Add("Close", ConsoleMenu.Close)
            .Add("Exit", () => Environment.Exit(0))
            .Configure(m =>
            {
                ConfigHelper.BaseTestConfiguration(m, console);
            });

            menu.Show();

            Assert.Equal(@"Pick an option:<fc: White, bc: Black>
   <fc: White, bc: Black>[0] One<fc: White, bc: Black>
   <fc: White, bc: Black>[1] Two<fc: White, bc: Black>
>> <fc: Black, bc: White>[2] Close<fc: Black, bc: White>
   <fc: White, bc: Black>[3] Exit<fc: White, bc: Black>

", console.ToString(), ignoreLineEndingDifferences: true);
        }
コード例 #2
0
        public void SimpleScenario()
        {
            var console = new TestConsole();

            console.AddUserInput("2");

            var menu = new ConsoleMenu()
            {
                Console = console
            }
            .Add("One", () => { })
            .Add("Two", () => { })
            .Add("Close", ConsoleMenu.Close)
            .Add("Exit", () => Environment.Exit(0))
            .Configure(m =>
            {
                ConfigHelper.BaseTestConfiguration(m, console);
            });

            menu.Show();

            Assert.Equal(@"Pick an option:
   [0] One
   [1] Two
>> [2] Close
   [3] Exit

", console.ToString(), ignoreLineEndingDifferences: true);
        }
コード例 #3
0
        public void Reentry_Submenu()
        {
            var console = new TestConsole();

            console.AddUserInput(ConsoleKey.D1);
            console.AddUserInputWithActionBefore(ConsoleKey.D1, () =>
            {
                AssertHelper.Equal(@"Pick an option:
   [0] One
>> [1] Close
", console.ToString());
            });

            // open submenu once again
            console.AddUserInputWithActionBefore(ConsoleKey.D1, () =>
            {
                AssertHelper.Equal(@"Pick an option:
   [0] Sub_One
>> [1] Sub_Close
", console.ToString());
            });
            console.AddUserInputWithActionBefore(ConsoleKey.D1, () =>
            {
                AssertHelper.Equal(@"Pick an option:
   [0] One
>> [1] Close
", console.ToString());
            });
            var submenu = new ConsoleMenu()
            {
                Console = console
            }
            .Add("Sub_One", () => { })
            .Add("Sub_Close", ConsoleMenu.Close)
            .Configure(m =>
            {
                ConfigHelper.BaseTestConfiguration(m, console);
            });

            var menu = new ConsoleMenu()
            {
                Console = console
            }
            .Add("One", submenu.Show)
            .Add("Close", ConsoleMenu.Close)
            .Configure(m =>
            {
                ConfigHelper.BaseTestConfiguration(m, console);
            });

            menu.Show();

            AssertHelper.Equal(@"Pick an option:
   [0] One
>> [1] Close

", console.ToString());
        }