public async Task WhenSettingAnExtensionProperty_TheExtensionValueProviderIsCalled() { string?updatedPropertyName = null; string?updatedPropertyValue = null; var extensionValueProvider = ILaunchProfileExtensionValueProviderFactory.Create( onSetPropertyValue: (propertyName, value, profile, globals, rule) => { updatedPropertyName = propertyName; updatedPropertyValue = value; }); var metadata = ILaunchProfileExtensionValueProviderMetadataFactory.Create("MyProperty"); var lazy = new Lazy <ILaunchProfileExtensionValueProvider, ILaunchProfileExtensionValueProviderMetadata>( () => extensionValueProvider, metadata); var properties = new LaunchProfileProjectProperties( DefaultTestProjectPath, "Profile1", CreateDefaultTestLaunchSettings(), ImmutableArray.Create(lazy), EmptyGlobalSettingExtensionValueProviders); await properties.SetPropertyValueAsync("MyProperty", "alpha"); Assert.Equal(expected: "MyProperty", actual: updatedPropertyName); Assert.Equal(expected: "alpha", actual: updatedPropertyValue); }
public async Task WhenSettingAnExtensionProperty_TheRuleIsPassedToTheExtensionValueProvider() { bool rulePassed = false; var extensionValueProvider = ILaunchProfileExtensionValueProviderFactory.Create( onSetPropertyValue: (propertyName, value, profile, globals, rule) => { rulePassed = rule is not null; }); var metadata = ILaunchProfileExtensionValueProviderMetadataFactory.Create("MyProperty"); var lazy = new Lazy <ILaunchProfileExtensionValueProvider, ILaunchProfileExtensionValueProviderMetadata>( () => extensionValueProvider, metadata); var properties = new LaunchProfileProjectProperties( DefaultTestProjectPath, "Profile1", CreateDefaultTestLaunchSettings(), ImmutableArray.Create(lazy), EmptyGlobalSettingExtensionValueProviders); properties.SetRuleContext(new Rule()); await properties.SetPropertyValueAsync("MyProperty", "alpha"); Assert.True(rulePassed); }
public async Task WhenSettingStandardPropertyValues_StandardCallbacksAreFound() { var profile1 = new WritableLaunchProfile { Name = "Profile1", CommandName = "epsilon", }; bool callbackInvoked; var launchSettingsProvider = ILaunchSettingsProviderFactory.Create( launchProfiles: new[] { profile1.ToLaunchProfile() }, tryUpdateProfileCallback: (profile, action) => { callbackInvoked = true; }); var properties = new LaunchProfileProjectProperties( DefaultTestProjectPath, "Profile1", launchSettingsProvider, EmptyLaunchProfileExtensionValueProviders, EmptyGlobalSettingExtensionValueProviders); var newValues = new Dictionary <string, string> { ["CommandLineArguments"] = "delta epsilon", ["CommandName"] = "arugula", ["EnvironmentVariables"] = "Three=3,Four=4", ["ExecutablePath"] = @"D:\nine\ten.exe", ["LaunchBrowser"] = "false", ["LaunchUrl"] = "https://localhost/myOtherProfile", ["WorkingDirectory"] = @"D:\aardvark", }; foreach (var(propertyName, newPropertyValue) in newValues) { callbackInvoked = false; await properties.SetPropertyValueAsync(propertyName, newPropertyValue); Assert.True(callbackInvoked); } }