private static ConfiguredProject CreateConfiguredProject(string[] capabilities, Dictionary <string, string?> propertyNamesAndValues) { return(ConfiguredProjectFactory.Create( IProjectCapabilitiesScopeFactory.Create(capabilities), services: ConfiguredProjectServicesFactory.Create( projectPropertiesProvider: IProjectPropertiesProviderFactory.Create( commonProps: IProjectPropertiesFactory.CreateWithPropertiesAndValues( propertyNamesAndValues))))); }
public async Task LocalDebuggerCommand_EmptyCommand_ReturnsDotnet() { var properties = IProjectPropertiesFactory.CreateWithPropertiesAndValues(new System.Collections.Generic.Dictionary <string, string>() { { WindowsLocalDebugger.LocalDebuggerCommandProperty, "" }, { WindowsLocalDebugger.DotnetPathProperty, "dotnet.exe" } }); var provider = new LocalDebuggerCommandValueProvider(); Assert.Equal("dotnet.exe", await provider.OnGetEvaluatedPropertyValueAsync(string.Empty, properties)); }
public async Task SetApplicationManifest(string appManifestPropValue, string noManifestPropValue, string valueToSet, string expectedAppManifestValue, string expectedNoManifestValue) { var provider = new ApplicationManifestValueProvider(UnconfiguredProjectFactory.Create(filePath: @"C:\projectdir\proj.proj")); var defaultProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues(new Dictionary <string, string> { { "ApplicationManifest", appManifestPropValue }, { "NoWin32Manifest", noManifestPropValue } }); var appManifestValue = await provider.OnSetPropertyValueAsync(valueToSet, defaultProperties); var noManifestValue = await defaultProperties.GetEvaluatedPropertyValueAsync("NoWin32Manifest"); Assert.Equal(expectedAppManifestValue, appManifestValue); Assert.Equal(expectedNoManifestValue, noManifestValue); }
public async Task GetPropertyValueTests(string propertyName, string optionStrict, string warningLevel, string treatWarningsAsErrors, string noWarn, string specificWarningsAsErrors, string expectedValue) { var provider = new VBWarningsValueProvider(); var defaultProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues(new Dictionary <string, string?>() { { VBWarningsValueProvider.OptionStrictPropertyName, optionStrict }, { VBWarningsValueProvider.WarningLevelPropertyName, warningLevel }, { VBWarningsValueProvider.TreatWarningsAsErrorsPropertyName, treatWarningsAsErrors }, { VBWarningsValueProvider.NoWarnPropertyName, noWarn }, { VBWarningsValueProvider.WarningsAsErrorsPropertyName, specificWarningsAsErrors } }); var result = await provider.OnGetEvaluatedPropertyValueAsync(propertyName, evaluatedPropertyValue : "", defaultProperties); Assert.Equal(expectedValue, result); }
public async Task WhenThePropertyIsNotSetAtAll_TheSavedValueIsRestored() { Dictionary <string, string?> propertyNamesAndValues = new() { { "MyProperty", null } }; IProjectProperties projectProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues( propertyNamesAndValues, inheritedPropertyNames: new() { "MyProperty" }); // If a property isn't defined _at all_ it is considered inherited. ITemporaryPropertyStorage temporaryPropertyStorage = ITemporaryPropertyStorageFactory.Create( values: new() { { "MyProperty", "Alpha" } }); await projectProperties.RestoreValueIfNotCurrentlySetAsync("MyProperty", temporaryPropertyStorage); Assert.Contains(new KeyValuePair <string, string?>("MyProperty", "Alpha"), propertyNamesAndValues); }
public async Task WhenThePropertyIsInherited_TheSavedValueIsRestored() { Dictionary <string, string?> propertyNamesAndValues = new() { { "MyProperty", "Beta" } }; IProjectProperties projectProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues( propertyNamesAndValues, inheritedPropertyNames: new() { "MyProperty" }); ITemporaryPropertyStorage temporaryPropertyStorage = ITemporaryPropertyStorageFactory.Create( values: new() { { "MyProperty", "Alpha" } }); await projectProperties.RestoreValueIfNotCurrentlySetAsync("MyProperty", temporaryPropertyStorage); Assert.Contains(new KeyValuePair <string, string?>("MyProperty", "Alpha"), propertyNamesAndValues); }
public async Task SetApplicationManifestKind(string newValue, string?currentApplicationManifestPropertyValue, string?currentNoManifestPropertyValue, string?expectedAppManifestPropertyValue, string?expectedNoManifestPropertyValue, string?expectedStoredValue) { Dictionary <string, string> storageDictionary = new(); var storage = ITemporaryPropertyStorageFactory.Create(storageDictionary); Dictionary <string, string?> defaultPropertiesDictionary = new(); defaultPropertiesDictionary["ApplicationManifest"] = currentApplicationManifestPropertyValue; defaultPropertiesDictionary["NoWin32Manifest"] = currentNoManifestPropertyValue; var defaultProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues(defaultPropertiesDictionary); var provider = new ApplicationManifestKindValueProvider(storage); await provider.OnSetPropertyValueAsync("", newValue, defaultProperties); defaultPropertiesDictionary.TryGetValue("ApplicationManifest", out string?finalAppManifestPropertyValue); defaultPropertiesDictionary.TryGetValue("NoWin32Manifest", out string?finalNoManifestPropertyValue); storageDictionary.TryGetValue("ApplicationManifestKind", out string?finalStoredValue); Assert.Equal(expectedAppManifestPropertyValue, finalAppManifestPropertyValue); Assert.Equal(expectedNoManifestPropertyValue, finalNoManifestPropertyValue); Assert.Equal(expectedStoredValue, finalStoredValue); }
public async Task SetPackageLicenseKind(string newValue, string?currentExpressionPropertyValue, string?currentFilePropertyValue, string?expectedExpressionPropertyValue, string?expectedFilePropertyValue, string?expectedStoredValue) { Dictionary <string, string> storageDictionary = new(); var storage = ITemporaryPropertyStorageFactory.Create(storageDictionary); Dictionary <string, string?> defaultPropertiesDictionary = new(); defaultPropertiesDictionary["PackageLicenseExpression"] = currentExpressionPropertyValue; defaultPropertiesDictionary["PackageLicenseFile"] = currentFilePropertyValue; var defaultProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues(defaultPropertiesDictionary); var provider = new PackageLicenseKindValueProvider(storage); await provider.OnSetPropertyValueAsync("", newValue, defaultProperties); defaultPropertiesDictionary.TryGetValue("PackageLicenseExpression", out string?finalExpressionPropertyValue); defaultPropertiesDictionary.TryGetValue("PackageLicenseFile", out string?finalFilePropertyValue); storageDictionary.TryGetValue("PackageLicenseKind", out string?finalStoredValue); Assert.Equal(expectedExpressionPropertyValue, finalExpressionPropertyValue); Assert.Equal(expectedFilePropertyValue, finalFilePropertyValue); Assert.Equal(expectedStoredValue, finalStoredValue); }
public async Task GetApplicationManifestKind(string applicationManifestPropertyValue, string noManifestPropertyValue, string?storedValue, string expectedValue) { Dictionary <string, string>?storedValues = null; if (storedValue is not null) { storedValues = new Dictionary <string, string> { { "ApplicationManifestKind", storedValue } }; } var storage = ITemporaryPropertyStorageFactory.Create(storedValues); var provider = new ApplicationManifestKindValueProvider(storage); var defaultProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues(new Dictionary <string, string?> { { "ApplicationManifest", applicationManifestPropertyValue }, { "NoWin32Manifest", noManifestPropertyValue } }); var kindValue = await provider.OnGetEvaluatedPropertyValueAsync(string.Empty, string.Empty, defaultProperties); Assert.Equal(expected: expectedValue, actual: kindValue); }
public async Task GetPackageLicenseKind(string?expressionPropertyValue, string?filePropertyValue, string?storedValue, string expectedValue) { Dictionary <string, string>?storedValues = null; if (storedValue is not null) { storedValues = new Dictionary <string, string> { { "PackageLicenseKind", storedValue } }; } var storage = ITemporaryPropertyStorageFactory.Create(storedValues); var provider = new PackageLicenseKindValueProvider(storage); var defaultProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues(new Dictionary <string, string?> { { "PackageLicenseExpression", expressionPropertyValue }, { "PackageLicenseFile", filePropertyValue } }); var kindValue = await provider.OnGetEvaluatedPropertyValueAsync(string.Empty, string.Empty, defaultProperties); Assert.Equal(expected: expectedValue, actual: kindValue); }