Esempio n. 1
0
        public void It_prefers_EXE_over_CMD_when_two_command_candidates_exist_and_using_WindowsExePreferredCommandSpecFactory()
        {
            var environment = CommandResolverTestUtils.SetupEnvironmentProviderWhichFindsExtensions(".exe");
            var platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory();

            var projectPathCommandResolver = new ProjectPathCommandResolver(environment, platformCommandSpecFactory);

            CommandResolverTestUtils.CreateNonRunnableTestCommand(s_testProjectDirectory, "projectpathtestcommand1", ".exe");
            CommandResolverTestUtils.CreateNonRunnableTestCommand(s_testProjectDirectory, "projectpathtestcommand1", ".cmd");

            var commandResolverArguments = new CommandResolverArguments()
            {
                CommandName      = "projectpathtestcommand1",
                CommandArguments = null,
                ProjectDirectory = s_testProjectDirectory
            };

            var result = projectPathCommandResolver.Resolve(commandResolverArguments);

            result.Should().NotBeNull();

            var commandFile = Path.GetFileName(result.Path);

            commandFile.Should().Be("projectpathtestcommand1.exe");
        }
Esempio n. 2
0
        public void It_wraps_command_with_CMD_EXE_when_command_has_CMD_Extension_and_using_WindowsExePreferredCommandSpecFactory()
        {
            var environment = new EnvironmentProvider(new[] { ".cmd" });
            var platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory();

            var pathCommandResolver = new ProjectPathCommandResolver(environment, platformCommandSpecFactory);

            var testCommandPath =
                CommandResolverTestUtils.CreateNonRunnableTestCommand(s_testProjectDirectory, "cmdWrapCommand", ".cmd");

            var commandResolverArguments = new CommandResolverArguments()
            {
                CommandName      = "cmdWrapCommand",
                CommandArguments = null,
                ProjectDirectory = s_testProjectDirectory
            };

            var result = pathCommandResolver.Resolve(commandResolverArguments);

            result.Should().NotBeNull();

            var commandFile = Path.GetFileName(result.Path);

            commandFile.Should().Be("cmd.exe");

            result.Args.Should().Contain(testCommandPath);
        }
Esempio n. 3
0
        public void It_resolves_commands_with_extensions_defined_in_InferredExtensions()
        {
            var extensions = new string[] { ".sh", ".cmd", ".foo", ".exe" };
            var projectPathCommandResolver = SetupPlatformProjectPathCommandResolver(forceGeneric: true);

            foreach (var extension in extensions)
            {
                var extensionTestDir = Path.Combine(s_testProjectDirectory, "testext" + extension);

                CommandResolverTestUtils.CreateNonRunnableTestCommand(extensionTestDir, "projectpathexttest", extension);

                var commandResolverArguments = new CommandResolverArguments()
                {
                    CommandName        = "projectpathexttest",
                    CommandArguments   = null,
                    ProjectDirectory   = extensionTestDir,
                    InferredExtensions = extensions
                };

                var result = projectPathCommandResolver.Resolve(commandResolverArguments);

                result.Should().NotBeNull();

                var commandFileName = Path.GetFileName(result.Path);
                commandFileName.Should().Be("projectpathexttest" + extension);
            }
        }
Esempio n. 4
0
        public void It_escapes_CommandArguments_when_returning_a_CommandSpec()
        {
            var environment            = CommandResolverTestUtils.SetupEnvironmentProviderWhichFindsExtensions(".exe");
            var appBaseCommandResolver = SetupPlatformAppBaseCommandResolver(environment, forceGeneric: true);

            CommandResolverTestUtils.CreateNonRunnableTestCommand(AppContext.BaseDirectory, "appbasetestcommand1", ".exe");

            var commandResolverArguments = new CommandResolverArguments()
            {
                CommandName      = "appbasetestcommand1",
                CommandArguments = new[] { "arg with space" }
            };

            var result = appBaseCommandResolver.Resolve(commandResolverArguments);

            result.Should().NotBeNull();
            result.Args.Should().Be("\"arg with space\"");
        }
Esempio n. 5
0
        public void It_returns_a_CommandSpec_with_Args_as_stringEmpty_when_returning_a_CommandSpec_and_CommandArguments_are_null()
        {
            var environment            = CommandResolverTestUtils.SetupEnvironmentProviderWhichFindsExtensions(".exe");
            var appBaseCommandResolver = SetupPlatformAppBaseCommandResolver(environment, forceGeneric: true);

            CommandResolverTestUtils.CreateNonRunnableTestCommand(AppContext.BaseDirectory, "appbasetestcommand1", ".exe");

            var commandResolverArguments = new CommandResolverArguments()
            {
                CommandName      = "appbasetestcommand1",
                CommandArguments = null
            };

            var result = appBaseCommandResolver.Resolve(commandResolverArguments);

            result.Should().NotBeNull();
            result.Args.Should().Be(string.Empty);
        }
Esempio n. 6
0
        public void It_returns_null_when_CommandName_exists_applocal_in_a_subdirectory()
        {
            var environment            = CommandResolverTestUtils.SetupEnvironmentProviderWhichFindsExtensions(".exe");
            var appBaseCommandResolver = SetupPlatformAppBaseCommandResolver(environment, forceGeneric: true);

            var testDir = Path.Combine(AppContext.BaseDirectory, "appbasetestsubdir");

            CommandResolverTestUtils.CreateNonRunnableTestCommand(testDir, "appbasetestsubdircommand", ".exe");

            var commandResolverArguments = new CommandResolverArguments()
            {
                CommandName      = "appbasetestsubdircommand",
                CommandArguments = null
            };

            var result = appBaseCommandResolver.Resolve(commandResolverArguments);

            result.Should().BeNull();
        }
Esempio n. 7
0
        public void It_returns_null_when_CommandName_exists_in_a_subdirectory_of_ProjectDirectory()
        {
            var environment = CommandResolverTestUtils.SetupEnvironmentProviderWhichFindsExtensions(".exe");
            var projectPathCommandResolver = SetupPlatformProjectPathCommandResolver(environment, forceGeneric: true);

            var testDir = Path.Combine(s_testProjectDirectory, "projectpathtestsubdir");

            CommandResolverTestUtils.CreateNonRunnableTestCommand(testDir, "projectpathtestsubdircommand", ".exe");

            var commandResolverArguments = new CommandResolverArguments()
            {
                CommandName      = "projectpathtestsubdircommand",
                CommandArguments = null,
                ProjectDirectory = s_testProjectDirectory
            };

            var result = projectPathCommandResolver.Resolve(commandResolverArguments);

            result.Should().BeNull();
        }
Esempio n. 8
0
        public void It_returns_a_CommandSpec_with_CommandName_as_FileName_when_CommandName_exists_applocal()
        {
            var environment            = CommandResolverTestUtils.SetupEnvironmentProviderWhichFindsExtensions(".exe");
            var appBaseCommandResolver = SetupPlatformAppBaseCommandResolver(environment, forceGeneric: true);

            CommandResolverTestUtils.CreateNonRunnableTestCommand(AppContext.BaseDirectory, "appbasetestcommand1", ".exe");

            var commandResolverArguments = new CommandResolverArguments()
            {
                CommandName      = "appbasetestcommand1",
                CommandArguments = null
            };

            var result = appBaseCommandResolver.Resolve(commandResolverArguments);

            result.Should().NotBeNull();

            var commandFile = Path.GetFileNameWithoutExtension(result.Path);

            commandFile.Should().Be("appbasetestcommand1");
        }
Esempio n. 9
0
        public void It_returns_a_CommandSpec_with_CommandName_as_FileName_when_CommandName_exists_in_ProjectDirectory()
        {
            var environment = CommandResolverTestUtils.SetupEnvironmentProviderWhichFindsExtensions(".exe");
            var projectPathCommandResolver = SetupPlatformProjectPathCommandResolver(environment, forceGeneric: true);

            CommandResolverTestUtils.CreateNonRunnableTestCommand(s_testProjectDirectory, "projectpathtestcommand1", ".exe");

            var commandResolverArguments = new CommandResolverArguments()
            {
                CommandName      = "projectpathtestcommand1",
                CommandArguments = null,
                ProjectDirectory = s_testProjectDirectory
            };

            var result = projectPathCommandResolver.Resolve(commandResolverArguments);

            result.Should().NotBeNull();

            var commandFile = Path.GetFileNameWithoutExtension(result.Path);

            commandFile.Should().Be("projectpathtestcommand1");
        }