Exemple #1
0
        public void WmiSettingsAreGeneratedWithPolicyOverridesIfWmiIsEnabled()
        {
            configurationObject.Type = typeof(Object);
            configurationObject.Attributes.Add("name1", "value1");
            configurationObject.Attributes.Add("name2", "value2");

            machineKey.AddStringValue(MockCustomProviderDataManageabilityProvider.ProviderTypePropertyName, typeof(String).AssemblyQualifiedName);
            machineKey.AddStringValue(MockCustomProviderDataManageabilityProvider.AttributesPropertyName,
                                      "name3=value3;name4=;name5=value 5");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(configurationObject, true, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(MockCustomProviderSetting), wmiSettings[0].GetType());
            Assert.AreEqual(typeof(String).AssemblyQualifiedName, ((MockCustomProviderSetting)wmiSettings[0]).providerTypeName);

            Dictionary <String, String> attributesDictionary = new Dictionary <string, string>();

            foreach (String entry in ((MockCustomProviderSetting)wmiSettings[0]).attributes)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, attributesDictionary);
            }
            Assert.AreEqual(3, attributesDictionary.Count);
            Assert.AreEqual("value3", attributesDictionary["name3"]);
            Assert.AreEqual("", attributesDictionary["name4"]);
            Assert.AreEqual("value 5", attributesDictionary["name5"]);
        }
Exemple #2
0
        public void EmptyStringResultsInEmptyDictionary()
        {
            String attributes = "";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(0, dictionary.Count);
        }
Exemple #3
0
        public void EntryWithEmptyNameIsIgnored()
        {
            String attributes = "=value1;name2=;=value3";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(1, dictionary.Count);
            Assert.AreEqual("", dictionary["name2"]);
        }
Exemple #4
0
        public void CanExtractSingleEmptyValueString()
        {
            String attributes = "name1=";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(1, dictionary.Count);
            Assert.AreEqual("", dictionary["name1"]);
        }
Exemple #5
0
        public void CanExtractSingleValueWithSpacesString()
        {
            String attributes = "name=value with spaces";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(1, dictionary.Count);
            Assert.AreEqual("value with spaces", dictionary["name"]);
        }
Exemple #6
0
        public void CanExtractSingleValueStringWithTrailingSemicolon()
        {
            String attributes = "name=value;";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(1, dictionary.Count);
            Assert.AreEqual("value", dictionary["name"]);
        }
Exemple #7
0
        public void EscapedTrailingSemicolonIsPartOfTheValue()
        {
            String attributes = "name1=value1;;value2;;";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(1, dictionary.Count);
            Assert.AreEqual("value1;value2;", dictionary["name1"]);
        }
Exemple #8
0
        public void CanExtractMultipleValueStrings()
        {
            String attributes = "name1=value1;name2=value2";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(2, dictionary.Count);
            Assert.AreEqual("value1", dictionary["name1"]);
            Assert.AreEqual("value2", dictionary["name2"]);
        }
Exemple #9
0
        public void CanExtractMultipleValueStringsWithEmtpyValues()
        {
            String attributes = "name1=;name2=;name3=value3";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(3, dictionary.Count);
            Assert.AreEqual("", dictionary["name1"]);
            Assert.AreEqual("", dictionary["name2"]);
            Assert.AreEqual("value3", dictionary["name3"]);
        }
Exemple #10
0
        public void EscapedSemicolonsCanBePartOfTheValue()
        {
            String attributes = " name1=va;;lue1;name2= ; name3 =va;;lue3";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(3, dictionary.Count);
            Assert.AreEqual("va;lue1", dictionary["name1"]);
            Assert.AreEqual(" ", dictionary["name2"]);
            Assert.AreEqual("va;lue3", dictionary["name3"]);
        }
Exemple #11
0
        public void SpacesSurroundingValueNameAreIgnored()
        {
            String attributes = " name1=value1;name2 =; name3 =value3";

            KeyValuePairParsingTestHelper.ExtractKeyValueEntries(attributes, dictionary);
            Assert.AreEqual(3, dictionary.Count);
            Assert.AreEqual("value1", dictionary["name1"]);
            Assert.AreEqual("", dictionary["name2"]);
            Assert.AreEqual("value3", dictionary["name3"]);
        }
Exemple #12
0
        public void WmiSettingsAreGeneratedIfWmiIsEnabled()
        {
            configurationObject.Type = typeof(Object);
            configurationObject.Attributes.Add("name1", "value1");
            configurationObject.Attributes.Add("name2", "value2");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(configurationObject, false, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(MockCustomProviderSetting), wmiSettings[0].GetType());
            Assert.AreEqual(typeof(Object).AssemblyQualifiedName, ((MockCustomProviderSetting)wmiSettings[0]).providerTypeName);

            Dictionary <String, String> attributesDictionary = new Dictionary <string, string>();

            foreach (String entry in ((MockCustomProviderSetting)wmiSettings[0]).attributes)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, attributesDictionary);
            }
            Assert.AreEqual(2, attributesDictionary.Count);
            Assert.AreEqual("value1", attributesDictionary["name1"]);
            Assert.AreEqual("value2", attributesDictionary["name2"]);
        }