public ToolingTest() { var cfg = new Configuration(); var path = new[] { "sandboxes", Guid.NewGuid().ToString() }.Aggregate(Path.Combine); Directory.CreateDirectory(path); cfg.Target = "dummy-target"; Console = new StringWriter(); Shell = new MockShell(); Context = new Context(path, cfg, Console, Shell); }
public ToolingTest() { var path = new[] { "sandboxes", Guid.NewGuid().ToString() }.Aggregate(Path.Combine); Directory.CreateDirectory(path); Console = new StringWriter(); Shell = new MockShell(); Context = new Context { WorkingDirectory = path, Console = Console, Shell = Shell }; }
public void TestRun() { var shell = new MockShell(); shell.AddResponse("output of mycommand"); var cli = new Cli("mycommand", shell); var output = cli.Run("arg1 arg2", null); shell.LastCommand.ShouldBe("mycommand arg1 arg2"); output.ShouldBe("output of mycommand"); shell.AddResponse("some error message", 3); var e = Assert.Throws <CliException>( () => cli.Run("bad args", null) ); e.ReturnCode.ShouldBe(3); e.Command.ShouldBe("mycommand bad args"); e.Error.ShouldBe("some error message"); e.Message.ShouldBe("some error message [rc=3,cmd='mycommand bad args']"); }