public void AllExceptionTest_3() { CommandArgInputParser parser = new CommandArgInputParser(AllException3); parser.GetLegalKeyWords(); Assert.IsFalse(parser.CommandLegal); Assert.IsFalse(parser.CommandDuplicated); parser.LegalKeyWordCommands.ShouldDeepEqual(new List <string>(new string[] { "-c", "-w", "b", "-r", "-h", "-t", "-t", "a", "-t", "c", "-h", "x", "-h", "y" })); parser.CheckCommandCombinationLegal(); Assert.IsFalse(parser.CommandLegal); Assert.IsFalse(parser.CommandDuplicated); parser.FormatInitialList(); Assert.IsFalse(parser.CommandLegal); Assert.IsTrue(parser.CommandDuplicated); Assert.AreEqual(CommandArgInputParser.ConvertCommandListToString(parser.GetParsedCommandList()), "-c -w -r -t a -t c -h x -h y "); Assert.AreEqual(CommandArgInputParser.ConvertCommandListToString(parser.GetParsedCommandList(true)), "-c -w -r -t a -h x "); Assert.IsTrue(parser.IllegalCommandKeyWord); Assert.IsTrue(parser.IllegalKeyWordCombination); Assert.IsFalse(parser.MissingMustContainedKeyWord); Assert.IsTrue(parser.StartCharMissing); Assert.IsTrue(parser.EndCharMissing); Assert.IsTrue(parser.UnExpectedChar); }
public void CorrectArgTest1() { CommandArgInputParser parser = new CommandArgInputParser(CorrectArg1); parser.GetLegalKeyWords(); Assert.IsTrue(parser.CommandLegal); Assert.IsFalse(parser.CommandDuplicated); parser.LegalKeyWordCommands.ShouldDeepEqual(new List <string>(parser.InitialCommands)); parser.CheckCommandCombinationLegal(); Assert.IsTrue(parser.CommandLegal); Assert.IsFalse(parser.CommandDuplicated); parser.FormatInitialList(); Assert.IsFalse(parser.CommandDuplicated); Assert.IsTrue(parser.CommandLegal); parser.GetParsedCommandList(true).IsDeepEqual(parser.GetParsedCommandList(false)); Assert.AreEqual(CommandArgInputParser.ConvertCommandListToString(parser.GetParsedCommandList()), "-t x -h p -c "); Assert.IsFalse(parser.IllegalCommandKeyWord); Assert.IsFalse(parser.IllegalKeyWordCombination); Assert.IsFalse(parser.MissingMustContainedKeyWord); Assert.IsFalse(parser.StartCharMissing); Assert.IsFalse(parser.EndCharMissing); Assert.IsFalse(parser.UnExpectedChar); }
public void InvalidStartChar_Test() { CommandArgInputParser parser = new CommandArgInputParser(InvalidStartChar); parser.GetLegalKeyWords(); Assert.IsFalse(parser.CommandLegal); Assert.IsFalse(parser.CommandDuplicated); parser.LegalKeyWordCommands.ShouldDeepEqual(new List <string>(new string[] { "-c", "-r", "-h" })); parser.CheckCommandCombinationLegal(); Assert.IsFalse(parser.CommandLegal); Assert.IsFalse(parser.CommandDuplicated); parser.FormatInitialList(); Assert.IsFalse(parser.CommandLegal); Assert.IsFalse(parser.CommandDuplicated); Assert.AreEqual(CommandArgInputParser.ConvertCommandListToString(parser.GetParsedCommandList()), "-c -r "); Assert.AreEqual(CommandArgInputParser.ConvertCommandListToString(parser.GetParsedCommandList(true)), "-c -r "); Assert.IsTrue(parser.IllegalCommandKeyWord); Assert.IsFalse(parser.IllegalKeyWordCombination); Assert.IsFalse(parser.MissingMustContainedKeyWord); Assert.IsTrue(parser.StartCharMissing); Assert.IsFalse(parser.EndCharMissing); Assert.IsFalse(parser.UnExpectedChar); }