public void ParseDuplicatedArgument(string arg1, string arg2)
        {
            string errorMsg = string.Empty;
            MainArguments arguments = new MainArguments();
            CommandLineArgumentParser parser = new CommandLineArgumentParser(arguments.GetType());

            Assert.AreEqual(false, parser.Parse(new string[] { arg1, arg2 }, arguments,
                delegate(string message) { errorMsg = message; }));
            Assert.AreEqual("Duplicate 'help' argument.", errorMsg);
        }
 public void ParseInvalidArgument(string arg)
 {
     string errorMsg = string.Empty;
     MainArguments arguments = new MainArguments();
     CommandLineArgumentParser parser = new CommandLineArgumentParser(arguments.GetType());
     
     Assert.AreEqual(false, parser.Parse(new string[] { arg }, arguments,
         delegate(string message) { errorMsg = message; }));
     Assert.AreEqual(string.Format("Unrecognized argument '{0}'.", arg), errorMsg);
 }
        public void ParseInvalidValueForBooleanArgument()
        {
            string errorMsg = string.Empty;
            MainArguments arguments = new MainArguments();
            CommandLineArgumentParser parser = new CommandLineArgumentParser(arguments.GetType());

            Assert.AreEqual(false, parser.Parse(new string[] { "/help:bad" }, arguments,
                delegate(string message) { errorMsg = message; }));
            Assert.AreEqual("Invalid 'help' argument value 'bad'.", errorMsg);
        }
        public void ParseResourceFile_InvalidFileTest()
        {
            string errorMsg = string.Empty;
            MainArguments arguments = new MainArguments();

            CommandLineArgumentParser parser = new CommandLineArgumentParser(arguments.GetType(),
                delegate(string responseFileName)
                {
                    Assert.AreEqual("InvalidFile", responseFileName);
                    throw new FileNotFoundException();
                });

            Assert.AreEqual(false, parser.Parse(new string[] { "@InvalidFile" }, arguments,
                delegate(string message) { errorMsg = message; }));

            Assert.Contains(errorMsg, "Response file '0' does not exist.");
        }
        public void ParseResourceFile()
        {
            string errorMsg = string.Empty;
            string fileContent = "C:\\file.dll";
            MainArguments arguments = new MainArguments();

            CommandLineArgumentParser parser = new CommandLineArgumentParser(arguments.GetType(),
                delegate(string responseFileName)
                {
                    Assert.AreEqual("ResourceFile", responseFileName);
                    return fileContent;
                });

            Assert.AreEqual(true, parser.Parse(new string[] { "@ResourceFile" },
                arguments, delegate(string message) { errorMsg = message; }));
            Console.WriteLine(errorMsg);
        }