public void Should_generate_code() { // TODO: not a very useful test, more of a sanity check const string USAGE = @"Test host app for T4 Docopt.NET Usage: prog command ARG <myarg> [OPTIONALARG] [-o -s=<arg> --long=ARG --switch] prog files FILE... Options: -o Short switch. -s=<arg> Short option with arg. --long=ARG Long option with arg. --swith Long switch. Explanation: This is a test usage file. "; const string expected = @" public bool CmdCommand { get { return _args[""command""].IsTrue; } } public string ArgArg { get { return _args[""ARG""].ToString(); } } public string ArgMyarg { get { return _args[""<myarg>""].ToString(); } } public string ArgOptionalarg { get { return _args[""OPTIONALARG""].ToString(); } } public bool OptO { get { return _args[""-o""].IsTrue; } } public string OptS { get { return _args[""-s""].ToString(); } } public string OptLong { get { return _args[""--long""].ToString(); } } public bool OptSwitch { get { return _args[""--switch""].IsTrue; } } public bool CmdFiles { get { return _args[""files""].IsTrue; } } public ArrayList ArgFile { get { return _args[""FILE""].AsList; } } "; var s = new Docopt().GenerateCode(USAGE); Assert.AreEqual(expected.Trim(), s.Trim()); }
public void Should_generate_code() { // TODO: not a very useful test, more of a sanity check const string USAGE = @"Test host app for T4 Docopt.NET Usage: prog command ARG <myarg> [OPTIONALARG] [-o -s=<arg> --long=ARG --switch] prog files FILE... Options: -o Short switch. -s=<arg> Short option with arg. --long=ARG Long option with arg. --swith Long switch. Explanation: This is a test usage file. "; const string expected = @" public bool CmdCommand { get { return _args[""command""].IsTrue; } } public string ArgArg { get { return _args[""ARG""].ToString(); } } public string ArgMyarg { get { return _args[""<myarg>""].ToString(); } } public string ArgOptionalarg { get { return _args[""OPTIONALARG""].ToString(); } } public bool OptO { get { return _args[""-o""].IsTrue; } } public string OptS { get { return _args[""-s""].ToString(); } } public string OptLong { get { return _args[""--long""].ToString(); } } public bool OptSwitch { get { return _args[""--switch""].IsTrue; } } public bool CmdFiles { get { return _args[""files""].IsTrue; } } public ArrayList ArgFile { get { return _args[""FILE""].AsList; } } "; var s = new Docopt().GenerateCode(USAGE); Assert.AreEqual(expected.Trim(), s.Trim()); }