public override void Specify() { given("a no-op command that requires a parameter", delegate() { var noopCommand = new CommandWithRequiredParameter(); var commands = new ConsoleCommand[] { noopCommand }; when("that command is ran without the parameter", delegate() { StringWriter output = new StringWriter(); var exitCode = arrange(() => ConsoleCommandDispatcher.DispatchCommand(commands, new[] { "required" }, output)); then("the output indicates the parameter wasn't specified", delegate() { expect(() => output.ToString().Contains("Missing option: foo")); }); then("the exit code indicates the call failed", delegate() { expect(() => exitCode == -1); }); }); when("that command is ran with the parameter", delegate() { StringWriter output = new StringWriter(); var exitCode = arrange(() => ConsoleCommandDispatcher.DispatchCommand(commands, new[] { "required", "-foo", "bar" }, output)); then("the output is empty", delegate() { expect(() => string.IsNullOrEmpty(output.ToString().Trim())); }); then("the exit code indicates the call succeeded", delegate() { expect(() => exitCode == 0); }); then("the option is actually received", delegate() { expect(() => noopCommand.Foo == "bar"); }); }); }); }
public override void Specify() { given("a no-op command that requires a parameter", delegate() { var noopCommand = new CommandWithRequiredParameter(); var commands = new ConsoleCommand[] { noopCommand }; when("that command is ran without the parameter", delegate() { StringWriter output = new StringWriter(); var exitCode = arrange(() => ConsoleCommandDispatcher.DispatchCommand(commands, new[] { "required" }, output)); then("the output indicates the parameter wasn't specified", delegate() { expect(() => output.ToString().Contains("Missing option: foo")); }); then("the exit code indicates the call failed", delegate() { expect(() => exitCode == -1); }); }); when("that command is ran with the parameter", delegate() { StringWriter output = new StringWriter(); var exitCode = arrange(() => ConsoleCommandDispatcher.DispatchCommand(commands, new[] { "required", "-foo", "bar" }, output)); then("the output is empty", delegate() { expect(() => string.IsNullOrEmpty(output.ToString().Trim())); }); then("the exit code indicates the call succeeded", delegate() { expect(() => exitCode == 0); }); then("the option is actually received", delegate() { expect(() => noopCommand.Foo == "bar"); }); }); }); }