public void Parser_UnrecognizedArguments() { CommandLineParser parser; IEnumerable<ArgumentInstance> instances; TestLogger logger; string[] args = new string[] { "/a:XXX", "/unrecognized" }; ArgumentDescriptor d1 = new ArgumentDescriptor("id1", new string[] { "/a:" }, true, "desc1", false); // 1. Don't allow unrecognized parser = new CommandLineParser(new ArgumentDescriptor[] { d1 }, false); logger = CheckProcessingFails(parser, args); logger.AssertSingleErrorExists("/unrecognized"); logger.AssertErrorsLogged(1); // 2. Allow unrecognized parser = new CommandLineParser(new ArgumentDescriptor[] { d1 }, true); logger = new TestLogger(); instances = CheckProcessingSucceeds(parser, logger, args); AssertExpectedValue("id1", "XXX", instances); AssertExpectedInstancesCount(1, instances); logger.AssertMessagesLogged(0); // expecting unrecognized arguments to be ignored silently }