public async Task DebugTokenReplacer_ReplaceTokensInStringTests(string input, string expected, bool expandEnvVars) { IUnconfiguredProjectCommonServices services = IUnconfiguredProjectCommonServicesFactory.Create(); var replacer = new DebugTokenReplacerUnderTest(IUnconfiguredProjectCommonServicesFactory.Create(), _envHelper.Object); // Test msbuild vars string result = await replacer.ReplaceTokensInStringAsync(input, expandEnvVars); Assert.Equal(expected, result); }
public async Task ReplaceTokensInProfileTests() { IUnconfiguredProjectCommonServices services = IUnconfiguredProjectCommonServicesFactory.Create(); IActiveDebugFrameworkServices activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>(); var replacer = new DebugTokenReplacerUnderTest(IUnconfiguredProjectCommonServicesFactory.Create(), _envHelper.Object, activeDebugFramework); // Tests all the possible replacements. env3 tests that enviroment vars are resolved before msbuild tokens var launchProfile = new LaunchProfile() { Name = "$(msbuildProperty1)", CommandLineArgs = "%env1%", CommandName = "$(msbuildProperty2)", ExecutablePath = "$(test this string", // Not a valid token WorkingDirectory = "c:\\test\\%env3%", LaunchBrowser = false, LaunchUrl = "http://localhost:8080/$(unknownproperty)", EnvironmentVariables = ImmutableDictionary <string, string> .Empty.Add("var1", "%env1%").Add("var2", "$(msbuildProperty3)"), OtherSettings = ImmutableDictionary <string, object> .Empty.Add("setting1", "%env1%").Add("setting2", true), }; var resolvedProfile = await replacer.ReplaceTokensInProfileAsync(launchProfile); // Name and Command name should never be touched Assert.Equal("$(msbuildProperty1)", resolvedProfile.Name); Assert.Equal("$(msbuildProperty2)", resolvedProfile.CommandName); Assert.Equal("envVariable1", resolvedProfile.CommandLineArgs); Assert.Equal("$(test this string", resolvedProfile.ExecutablePath); Assert.False(resolvedProfile.LaunchBrowser); Assert.Equal("http://localhost:8080/", resolvedProfile.LaunchUrl); Assert.Equal("c:\\test\\Property6", resolvedProfile.WorkingDirectory); Assert.Equal("envVariable1", resolvedProfile.EnvironmentVariables["var1"]); Assert.Equal("Property3", resolvedProfile.EnvironmentVariables["var2"]); Assert.Equal("envVariable1", resolvedProfile.OtherSettings["setting1"]); Assert.True((bool)resolvedProfile.OtherSettings["setting2"]); }