Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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
            };
        }
Ejemplo n.º 3
0
        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']");
        }