예제 #1
0
        public void KCommandShowsErrorWhenGivenSubcommandWasNotFoundInProjectJson(DisposableDir runtimeHomeDir)
        {
            var projectStructure = @"{
  'project.json': '{ }'
}";

            using (runtimeHomeDir)
                using (var projectPath = TestUtils.CreateTempDir())
                {
                    DirTree.CreateFromJson(projectStructure).WriteTo(projectPath);

                    string stdOut, stdErr;
                    var    exitCode = KCommandTestUtils.ExecKCommand(
                        runtimeHomeDir,
                        subcommand: "invalid",
                        arguments: string.Empty,
                        stdOut: out stdOut,
                        stdErr: out stdErr,
                        environment: new Dictionary <string, string> {
                        { EnvironmentNames.AppBase, projectPath }
                    });

                    Assert.NotEqual(0, exitCode);
                    Assert.Contains("Unable to load application or execute command 'invalid'.", stdErr);
                }
        }
예제 #2
0
        public void KCommandReturnsZeroExitCodeWhenHelpOptionWasGiven(DisposableDir runtimeHomeDir)
        {
            using (runtimeHomeDir)
            {
                string stdOut, stdErr;
                var    exitCode = KCommandTestUtils.ExecKCommand(
                    runtimeHomeDir,
                    subcommand: string.Empty,
                    arguments: "--help",
                    stdOut: out stdOut,
                    stdErr: out stdErr);

                Assert.Equal(0, exitCode);
            }
        }
예제 #3
0
        public void KCommandReturnsNonZeroExitCodeWhenNoArgumentWasGiven(DisposableDir kreHomeDir)
        {
            using (kreHomeDir)
            {
                string stdOut, stdErr;
                var    exitCode = KCommandTestUtils.ExecKCommand(
                    kreHomeDir,
                    subcommand: string.Empty,
                    arguments: string.Empty,
                    stdOut: out stdOut,
                    stdErr: out stdErr);

                Assert.NotEqual(0, exitCode);
            }
        }
예제 #4
0
        public void KCommandShowsVersionAndReturnsZeroExitCodeWhenVersionOptionWasGiven(DisposableDir runtimeHomeDir)
        {
            using (runtimeHomeDir)
            {
                string stdOut, stdErr;
                var    exitCode = KCommandTestUtils.ExecKCommand(
                    runtimeHomeDir,
                    subcommand: string.Empty,
                    arguments: "--version",
                    stdOut: out stdOut,
                    stdErr: out stdErr);

                Assert.Equal(0, exitCode);
                Assert.Contains(TestUtils.GetRuntimeVersion(), stdOut);
            }
        }
예제 #5
0
        public void KCommandShowsErrorWhenNoProjectJsonWasFound(DisposableDir runtimeHomeDir)
        {
            using (runtimeHomeDir)
                using (var emptyFolder = TestUtils.CreateTempDir())
                {
                    string stdOut, stdErr;
                    var    exitCode = KCommandTestUtils.ExecKCommand(
                        runtimeHomeDir,
                        subcommand: "run",
                        arguments: string.Empty,
                        stdOut: out stdOut,
                        stdErr: out stdErr,
                        environment: new Dictionary <string, string> {
                        { EnvironmentNames.AppBase, emptyFolder }
                    });

                    Assert.NotEqual(0, exitCode);
                    Assert.Contains("Unable to locate project.json", stdErr);
                }
        }