private ProjectPathCommandResolver SetupPlatformProjectPathCommandResolver( IEnvironmentProvider environment = null, bool forceGeneric = false) { environment = environment ?? new EnvironmentProvider(); IPlatformCommandSpecFactory platformCommandSpecFactory = new GenericPlatformCommandSpecFactory(); if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows && !forceGeneric) { platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory(); } var projectPathCommandResolver = new ProjectPathCommandResolver(environment, platformCommandSpecFactory); return projectPathCommandResolver; }
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"); }