Ejemplo n.º 1
0
        public void HelpPageExampleTest()
        {
            CommandLineArgs args = new CommandLineArgs
            {
                ApplicationInfo = "MyCoolProgram v1.2 Copyright (C) John Smith <*****@*****.**>"
            };

            args.AddExample("example 1", "/flag /option=1");
            args.AddExample("great example", "/flag2");
            args.AddExample("example 2", "/option=222");

            using (TextWriter writer = new StringWriter())
            {
                args.OutputWriter = writer;

                args.PrintHelp();

                StringBuilder sb = new StringBuilder();
                sb.AppendLine(args.ApplicationInfo);
                sb.AppendLine();
                sb.AppendLine("Usage:");
                sb.AppendFormat("DotArgsTests ");
                sb.AppendLine();
                sb.AppendLine();
                sb.AppendLine("Examples:");
                sb.AppendLine();
                sb.AppendLine("example 1");
                sb.AppendLine("/flag /option=1");
                sb.AppendLine();
                sb.AppendLine("example 2");
                sb.AppendLine("/option=222");
                sb.AppendLine();
                sb.AppendLine("great example");
                sb.AppendLine("/flag2");

                Assert.AreEqual(sb.ToString(), writer.ToString());
            }
        }