public void HandlesHelpAsShortName()
            {
                string[] args = new string[1];
                args[0] = "/?";

                IDictionary<string, string> result = new CommandArgsParser().ParseArgs(args);
                Assert.IsTrue(result.Keys.Contains("--help"));
                Assert.AreEqual(true.ToString(), result["--help"]);
            }
示例#2
0
        private static void StartAsConsole(string[] args)
        {
            System.Diagnostics.Trace.TraceInformation("TextMin:StartAsConsole");
            CommandLineOptions cmdLineOptions = new CommandArgsParser().BuildCommandLineOptions(args);
            cmdLineOptions.FileExtensionsToCompress = _fileExtentionsToCompress;

            if (cmdLineOptions.DisplayHelp || string.IsNullOrEmpty(cmdLineOptions.ItemsToProcessDirectory)) {
                CompressorBase.ShowUsage();
                Console.ReadLine();
                return;
            }
            RunMinifier(cmdLineOptions);
        }
            public void BuildsTheCommandLineOptions()
            {
                string[] args = new[]{
                 "--cache",
                 "one.txt",
                 "--name",
                 "Azure",
                 "Image",
                 "Optimizer",
                 "--color",
                 "Green",
                 "--force"};
                var options = new CommandArgsParser().BuildCommandLineOptions(args);

                Assert.AreEqual("one.txt", options.OptimizerCacheFile);
                Assert.AreEqual("Azure Image Optimizer", options.Name);
                Assert.AreEqual("Green", options.Color);
                Assert.IsTrue(options.ShouldForceOptimize);
            }
            public void ReturnsTheValues()
            {
                string[] args = new[]{
                "--cache"
                ,"one.txt"
                ,"--name"
                ,"Azure"
                ,"Image"
                ,"Optimizer"
                ,"--color"
                ,"Green"
                ,"--force"};

                IDictionary<string, string> result = new CommandArgsParser().ParseArgs(args);
                Assert.AreEqual(4, result.Count);
                Assert.IsTrue(result.Keys.Contains("--cache"));
                Assert.IsTrue(result.Keys.Contains("--name"));
                Assert.IsTrue(result.Keys.Contains("--color"));
                Assert.AreEqual("one.txt", result["--cache"]);
                Assert.AreEqual("Azure Image Optimizer", result["--name"]);
                Assert.AreEqual("Green", result["--color"]);
                Assert.IsTrue(result.Keys.Contains("--force"));
            }