Example #1
0
        public void _ヘルプ表示依頼を処理する_コマンド指定()
        {
            var repo = new Ninject.StandardKernel()
                       .BindPurchaseContext()
                       .BindRunnerRepository()
                       .Get <IRunnerRepository>()
            ;

            var result = new HelpParseResult {
                Command = "ins"
            };
            var content = ConsoleAppHelper.ListHelpContents()
                          .Where(c => c.Command == result.Command).FirstOrDefault();

            var it = (new string[] { content.Usage, content.Description }).GetEnumerator();

            var runner = repo.FindRunner(result, (message) => {
                Assert.That(it.MoveNext(), Is.True);
                Assert.That(message, Is.Not.Null.And.Not.Empty);
                Assert.That(message, Is.EqualTo(it.Current));
            });

            runner();

            Assert.That(it.MoveNext(), Is.False);
        }
        public static IKernel BindRunnerRepository(this IKernel inSelf)
        {
            var help = ConsoleAppHelper.ListHelpContents();

            inSelf.Bind <IRunnerRepository>().ToMethod(ctx => new CommandRunnerRepository(help));

            return(inSelf);
        }
        public static string[] ListExpectedHelpContents()
        {
            var len = ConsoleAppHelper.ListHelpContents()
                      .Where(c => !c.Ignored)
                      .Max(c => c.Command.Length) + 2
            ;

            return(new string[] {
                //                "buy",
                "eject".PadRight(len) + "To eject inserted money is requested.",
                "help".PadRight(len) + "This message(s) is displayed.",
                "ins".PadRight(len) + "To insert money is requested.",
                "show amount".PadRight(len) + "To display the total amount of money inserted is requested.",
                "show item".PadRight(len) + "To display the layouted items is requested, where blank is unselectable, '*' is selectable, and '-' is soldout.",
            });
        }