コード例 #1
0
        public static IEnumerable <object[]> GetTestApiArgumentTestCases()
        {
            //
            // Cmd.flag + Cmd.sign
            //
            yield return(TestCase(
                             @"export const x = Cmd.flag(""/nologo"", true);",
                             (context) => Cmd.Flag("/nologo")));

            yield return(TestCase(
                             @"export const x = Cmd.option(""/timeout"", 42);",
                             (context) => Cmd.Option("/timeout", 42)));

            yield return(TestCase(
                             @"export const x = Cmd.sign(""/unsafe"", true);",
                             (context) => Cmd.Option("/unsafe", "+")));

            yield return(TestCase(
                             @"export const x = Cmd.sign(""/unsafe"", false);",
                             (context) => Cmd.Option("/unsafe", "-")));

            yield return(TestCase(
                             @"export const x = Cmd.sign(""/unsafe"", undefined);",
                             (context) => Cmd.Undefined()));

            yield return(TestCase(
                             @"export const x = Cmd.sign(""/enableNoPlus"", true, true);",
                             (context) => Cmd.Flag("/enableNoPlus")));

            yield return(TestCase(
                             @"export const x = Cmd.sign(""/enableNoPlus"", false, true);",
                             (context) => Cmd.Option("/enableNoPlus", "-")));

            //
            // Cmd.option with files
            //
            yield return(TestCase(
                             String.Format(@"export const x = Cmd.option(""/out"", Artifact.output(p`{0}foo.txt`));", m_testAbsolutePath),
                             (context) => Cmd.Option("/out", Artifacts.Output(CreateAbsolutePath(context, String.Format("{0}foo.txt", m_testAbsolutePath))))));

            yield return(TestCase(
                             String.Format(@"export const x = Cmd.option(""/input"", Artifact.input(p`{0}foo.txt`));", m_testAbsolutePath),
                             (context) => Cmd.Option("/input", Artifacts.Input(CreateAbsolutePath(context, String.Format("{0}foo.txt", m_testAbsolutePath))))));

            yield return(TestCase(
                             String.Format(@"export const x = Cmd.option(""/outFolder"", Artifact.output(p`{0}foo`));", m_testAbsolutePath),
                             (context) => Cmd.Option("/outFolder", Artifacts.Output(CreateAbsolutePath(context, String.Format("{0}foo", m_testAbsolutePath))))));

            yield return(TestCase(
                             String.Format(@"export const x = Cmd.option(""/rewrite"", Artifact.rewritten(f`{0}foo.txt`, p`{0}boo.txt`));", m_testAbsolutePath),
                             (context) =>
                             Cmd.Option("/rewrite", Artifacts.Rewritten(
                                            CreateFile(context, String.Format("{0}foo.txt", m_testAbsolutePath)),
                                            CreateAbsolutePath(context, String.Format("{0}boo.txt", m_testAbsolutePath))))));

            yield return(TestCase(
                             String.Format(@"export const x = Cmd.option(""/rewrite"", Artifact.rewritten(f`{0}foo.txt`));", m_testAbsolutePath),
                             (context) =>
                             Cmd.Option("/rewrite", Artifacts.InPlaceRewritten(CreateFile(context, String.Format("{0}foo.txt", m_testAbsolutePath))))));

            //
            // Cmd.options
            //
            yield return(TestCase(
                             String.Format(@"export const x = Cmd.options(""/crazy"", [Artifact.output(p`{0}foo.txt`), Artifact.input(p`{0}boo.txt`)]);", m_testAbsolutePath),
                             (context) =>
                             Cmd.Options("/crazy",
                                         Artifacts.Output(CreateAbsolutePath(context, String.Format("{0}foo.txt", m_testAbsolutePath))),
                                         Artifacts.Input(CreateAbsolutePath(context, String.Format("{0}boo.txt", m_testAbsolutePath))))));
        }