コード例 #1
0
ファイル: FlagTests.cs プロジェクト: mikeruhl/goflag
        public void TestChangingArgs()
        {
            ResetForTesting(() => Assert.True(false, "bad parse"));
            //the go src sets os.Args, which is the command line arguments, something that is read-only in .net
            var args   = new[] { "cmd", "-before", "subcmd", "-after", "args" };
            var before = Flag.Bool("before", false, "");
            var err    = Flag.CommandLine.Parse(args.Skip(1).ToArray());

            Assert.True(err == null, err?.ToString());

            var cmd   = Flag.Arg(0);
            var after = Flag.Bool("after", false, "");

            args = Flag.Args();
            Flag.CommandLine.Parse(args.Skip(1).ToArray());
            args = Flag.Args();
            Assert.True(before && cmd == "subcmd" && after && args[0] == "args", $"expected true subcmd true [args] got {before} {cmd} {after} {string.Join(',', args)}");
        }