コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }