Exemplo n.º 1
0
        public void explicitArgs(int argCount, int?readArg, int?writeArg, String error)
        {
            String inPath  = Path.Combine(TestUtil.findTestFileLocation(), "encoding", "psalm23.unix.ansi.txt");
            String outPath = Path.Combine(TestUtil.findTestOutputLocation(), "argsOutput", Guid.NewGuid() + ".txt");

            FileUtil.assureDirectoryStructExists(outPath);

            String[] args;
            switch (argCount)
            {
            default: args = new string[0]; break;

            case 1: args = new [] { inPath }; break;

            case 2: args = new [] { inPath, outPath }; break;

            case 3: args = new [] { inPath, outPath, "junk" }; break;
            }
            ArgsInputOutput numbered = new ArgsInputOutput(args);

            using (Pnyx p = new Pnyx())
            {
                p.setSettings(processOnDispose: false);
                p.setNumberedInputOutput(numbered);

                try
                {
                    if (readArg == null)
                    {
                        p.read(inPath);
                    }
                    else
                    {
                        p.readArg(readArg.Value);
                    }

                    if (writeArg == null)
                    {
                        p.write(outPath);
                    }
                    else
                    {
                        p.writeArg(writeArg.Value);
                    }

                    p.compile();

                    Assert.Null(error);
                }
                catch (Exception err)
                {
                    Assert.Equal(error, err.Message);
                    return;
                }

                p.process();
            }

            Assert.Null(TestUtil.binaryDiff(inPath, outPath));
        }