public async Task WhenGettingTheValue_DefaultsToIconAndManifest() { var provider = new ResourceSpecificationKindValueProvider(ITemporaryPropertyStorageFactory.Create()); var result = await provider.OnGetEvaluatedPropertyValueAsync( ResourceSpecificationKindValueProvider.ResourceSpecificationKindProperty, string.Empty, Mock.Of <IProjectProperties>()); Assert.Equal(expected: ResourceSpecificationKindValueProvider.IconAndManifestValue, actual: result); }
public async Task WhenGettingTheValue_ReturnsIconAndManifestIfManifestSet() { var provider = new ResourceSpecificationKindValueProvider(ITemporaryPropertyStorageFactory.Create()); var defaultProperties = IProjectPropertiesFactory.CreateWithPropertyAndValue(ResourceSpecificationKindValueProvider.ApplicationManifestMSBuildProperty, @"C:\alpha\beta\app.config"); var result = await provider.OnGetEvaluatedPropertyValueAsync( ResourceSpecificationKindValueProvider.ResourceSpecificationKindProperty, string.Empty, defaultProperties); Assert.Equal(expected: ResourceSpecificationKindValueProvider.IconAndManifestValue, actual: result); }
public async Task WhenGettingTheValue_ReturnsResourceFileIfWin32ResourceIsSet() { var provider = new ResourceSpecificationKindValueProvider(ITemporaryPropertyStorageFactory.Create()); var defaultProperties = IProjectPropertiesFactory.CreateWithPropertyAndValue(ResourceSpecificationKindValueProvider.Win32ResourceMSBuildProperty, @"C:\alpha\beta\gamma.res"); var result = await provider.OnGetEvaluatedPropertyValueAsync( ResourceSpecificationKindValueProvider.ResourceSpecificationKindProperty, string.Empty, defaultProperties); Assert.Equal(expected: ResourceSpecificationKindValueProvider.ResourceFileValue, actual: result); }
public async Task WhenSettingTheValue_TheNewValueIsStoredInTemporaryStorage() { var storageDictionary = new Dictionary <string, string>(); var provider = new ResourceSpecificationKindValueProvider(ITemporaryPropertyStorageFactory.Create(storageDictionary)); var result = await provider.OnSetPropertyValueAsync( ResourceSpecificationKindValueProvider.ResourceSpecificationKindProperty, ResourceSpecificationKindValueProvider.ResourceFileValue, Mock.Of <IProjectProperties>()); Assert.Null(result); Assert.True(storageDictionary.TryGetValue(ResourceSpecificationKindValueProvider.ResourceSpecificationKindProperty, out string savedValue)); Assert.Equal(expected: ResourceSpecificationKindValueProvider.ResourceFileValue, actual: savedValue); }
public async Task WhenGettingTheValue_TheValueIsRetrievedFromTemporaryStorageIfAvailable() { var storageDictionary = new Dictionary <string, string> { [ResourceSpecificationKindValueProvider.ResourceSpecificationKindProperty] = ResourceSpecificationKindValueProvider.ResourceFileValue }; var provider = new ResourceSpecificationKindValueProvider(ITemporaryPropertyStorageFactory.Create(storageDictionary)); var result = await provider.OnGetEvaluatedPropertyValueAsync( ResourceSpecificationKindValueProvider.ResourceSpecificationKindProperty, string.Empty, Mock.Of <IProjectProperties>()); Assert.Equal(expected: ResourceSpecificationKindValueProvider.ResourceFileValue, actual: result); }
public async Task WhenThePropertyIsSetInTheProject_TheValueIsSavedInTemporaryStorage() { IProjectProperties projectProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues( propertyNameAndValues: new Dictionary <string, string?>() { { "MyProperty", "Alpha" } }, inheritedPropertyNames: new()); Dictionary <string, string> storedValues = new(); ITemporaryPropertyStorage temporaryPropertyStorage = ITemporaryPropertyStorageFactory.Create(values: storedValues); await projectProperties.SaveValueIfCurrentlySetAsync("MyProperty", temporaryPropertyStorage); Assert.Contains(new KeyValuePair <string, string>("MyProperty", "Alpha"), storedValues); }
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); }