public void TestParseArrayErrors(string text, CommandParseErrorKind expectedKind) { CommandParser parser = CommandParser.TryCreate(text); CommandParseError error = Assert.Throws <CommandParseError>(() => parser.ParseArray()); Assert.Equal(expectedKind, error.Kind); }
private static string KindToString(CommandParseErrorKind kind) { switch (kind) { case CommandParseErrorKind.ExpectedWordAtEnd: return("Expected a word at the end"); case CommandParseErrorKind.MissingOpeningBracket: return("Missing '[' at the start of an array"); case CommandParseErrorKind.MissingComma: return("Missing ',' after an array element."); case CommandParseErrorKind.MissingClosingBracket: return("Missing ']' at the end of an array"); default: throw new ArgumentOutOfRangeException(nameof(kind), kind, null); } }
public CommandParseError(CommandParseErrorKind kind) : base(KindToString(kind)) { Kind = kind; }