ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string> properties = null) { _mockFS.WriteAllText(@"c:\test\Project\someapp.exe", ""); _mockFS.CreateDirectory(@"c:\test\Project"); _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", ""); LaunchProfile activeProfile = new LaunchProfile() { Name = "MyApplication", CommandLineArgs = "--someArgs", ExecutablePath = @"c:\test\Project\someapp.exe" }; _mockEnvironment.Setup(s => s.GetEnvironmentVariable("Path")).Returns(() => _Path); var project = IUnconfiguredProjectFactory.Create(null, null, _ProjectFile); var outputTypeEnum = new PageEnumValue(new EnumValue() { Name = outputType }); var data = new PropertyPageData() { Category = ConfigurationGeneral.SchemaName, PropertyName = ConfigurationGeneral.OutputTypeProperty, Value = outputTypeEnum }; var projectProperties = ProjectPropertiesFactory.Create(project, data); if (properties == null) { properties = new Dictionary <string, string>() { { "TargetPath", @"c:\test\project\bin\project.dll" }, { "TargetFrameworkIdentifier", @".NetCoreApp" } }; } var delegatePropertiesMock = IProjectPropertiesFactory .MockWithPropertiesAndValues(properties); var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object); IConfiguredProjectServices configuredProjectServices = Mock.Of <IConfiguredProjectServices>(o => o.ProjectPropertiesProvider == delegateProvider); ConfiguredProject configuredProject = Mock.Of <ConfiguredProject>(o => o.UnconfiguredProject == project && o.Services == configuredProjectServices); _mockTokenReplace.Setup(s => s.ReplaceTokensInProfileAsync(It.IsAny <ILaunchProfile>())).Returns <ILaunchProfile>(p => Task.FromResult(p)); var debugProvider = new ConsoleDebugTargetsProvider( configuredProject, _mockTokenReplace.Object, _mockFS, _mockEnvironment.Object, projectProperties); return(debugProvider); }
public void GetExeAndArgumentsWithNullArgs() { string exeIn = @"c:\foo\bar.exe"; string cmdExePath = Path.Combine(Environment.SystemDirectory, "cmd.exe"); ConsoleDebugTargetsProvider.GetExeAndArguments(true, exeIn, null, out string finalExePath, out string finalArguments); Assert.Equal(cmdExePath, finalExePath); Assert.Equal("/c \"\"c:\\foo\\bar.exe\" & pause\"", finalArguments); }
public void GetExeAndArgumentsWithEscapedArgs() { string exeIn = @"c:\foo\bar.exe"; string argsInWithEscapes = "/foo /bar ^ < > &"; string cmdExePath = Path.Combine(Environment.SystemDirectory, "cmd.exe"); ConsoleDebugTargetsProvider.GetExeAndArguments(true, exeIn, argsInWithEscapes, out string finalExePath, out string finalArguments); Assert.Equal(cmdExePath, finalExePath); Assert.Equal("/c \"\"c:\\foo\\bar.exe\" /foo /bar ^^ ^< ^> ^& & pause\"", finalArguments); ConsoleDebugTargetsProvider.GetExeAndArguments(false, exeIn, argsInWithEscapes, out finalExePath, out finalArguments); Assert.Equal(exeIn, finalExePath); Assert.Equal(argsInWithEscapes, finalArguments); }
public void ConsoleDebugTargetsProvider_EscapeString_WorksCorrectly(string input, string expected) { Assert.Equal(expected, ConsoleDebugTargetsProvider.EscapeString(input, new[] { '^', '<', '>', '&' })); }