Пример #1
0
        public void WmiSettingsAreGeneratedIfWmiIsEnabled()
        {
            configurationObject.Type = typeof(Object);
            configurationObject.Attributes.Add("name1", "value1");
            configurationObject.Attributes.Add("name2", "value2");
            configurationObject.InitData           = "init data";
            configurationObject.TraceOutputOptions = TraceOptions.None;

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

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(CustomTraceListenerSetting), wmiSettings[0].GetType());
            Assert.AreEqual(typeof(Object).AssemblyQualifiedName, ((CustomTraceListenerSetting)wmiSettings[0]).ListenerType);
            Assert.AreEqual("init data", ((CustomTraceListenerSetting)wmiSettings[0]).InitData);
            Assert.AreEqual(null, ((CustomTraceListenerSetting)wmiSettings[0]).Formatter);
            Assert.AreEqual(TraceOptions.None.ToString(), ((CustomTraceListenerSetting)wmiSettings[0]).TraceOutputOptions);

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

            foreach (String entry in ((CustomTraceListenerSetting)wmiSettings[0]).Attributes)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, attributesDictionary);
            }
            Assert.AreEqual(2, attributesDictionary.Count);
            Assert.AreEqual("value1", attributesDictionary["name1"]);
            Assert.AreEqual("value2", attributesDictionary["name2"]);
        }
        public void WmiSettingsAreGeneratedWithPolicyOverridesIfWmiIsEnabled()
        {
            OracleConnectionData connection1Data = new OracleConnectionData();

            connection1Data.Name = "data1";
            connection1Data.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connection1Data.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connection1Data);

            MockRegistryKey machinePackageKey = new MockRegistryKey(false);

            machineKey.AddSubKey("data1", machinePackageKey);
            machinePackageKey.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                             "package13=prefix13; package14=prefix14; package15=prefix15");

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

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(OracleConnectionSetting), wmiSettings[0].GetType());

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

            foreach (String entry in ((OracleConnectionSetting)wmiSettings[0]).Packages)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, packagesDictionary);
            }
            Assert.AreEqual(3, packagesDictionary.Count);
            Assert.AreEqual("prefix13", packagesDictionary["package13"]);
            Assert.AreEqual("prefix14", packagesDictionary["package14"]);
            Assert.AreEqual("prefix15", packagesDictionary["package15"]);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackageKey));
        }
        public void WmiSettingsAreGeneratedWithPolicyOverridesIfWmiIsEnabled()
        {
            configurationObject.PropertyMappings.Add(new FaultContractExceptionHandlerMappingData("name1", "value1"));
            configurationObject.PropertyMappings.Add(new FaultContractExceptionHandlerMappingData("name2", "value2"));
            configurationObject.ExceptionMessage  = "message";
            configurationObject.FaultContractType = "fault contract";

            machineKey.AddStringValue(FaultContractExceptionHandlerDataManageabilityProvider.AttributesPropertyName,
                                      "name3=value3;name4=value4;name5=value 5");
            machineKey.AddStringValue(FaultContractExceptionHandlerDataManageabilityProvider.ExceptionMessagePropertyName, "overriden message");
            machineKey.AddStringValue(FaultContractExceptionHandlerDataManageabilityProvider.FaultContractTypePropertyName, "overriden fault contract");

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

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(FaultContractExceptionHandlerSetting), wmiSettings[0].GetType());
            Assert.AreEqual("overriden message", ((FaultContractExceptionHandlerSetting)wmiSettings[0]).ExceptionMessage);
            Assert.AreEqual("overriden fault contract", ((FaultContractExceptionHandlerSetting)wmiSettings[0]).FaultContractType);
            Dictionary <String, String> attributesDictionary = new Dictionary <string, string>();

            foreach (String entry in ((FaultContractExceptionHandlerSetting)wmiSettings[0]).Attributes)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, attributesDictionary);
            }
            Assert.AreEqual(3, attributesDictionary.Count);
            Assert.AreEqual("value3", attributesDictionary["name3"]);
            Assert.AreEqual("value4", attributesDictionary["name4"]);
            Assert.AreEqual("value 5", attributesDictionary["name5"]);
        }
Пример #4
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(CustomFilterSetting), wmiSettings[0].GetType());
            Assert.AreEqual(typeof(object).AssemblyQualifiedName, ((CustomFilterSetting)wmiSettings[0]).FilterType);
            Dictionary <String, String> attributesDictionary = new Dictionary <string, string>();

            foreach (String entry in ((CustomFilterSetting)wmiSettings[0]).Attributes)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, attributesDictionary);
            }
            Assert.AreEqual(2, attributesDictionary.Count);
            Assert.AreEqual("value1", attributesDictionary["name1"]);
            Assert.AreEqual("value2", attributesDictionary["name2"]);
        }
        public void WmiSettingsAreGeneratedIfWmiIsEnabled()
        {
            configurationObject.PropertyMappings.Add(new FaultContractExceptionHandlerMappingData("name1", "value1"));
            configurationObject.PropertyMappings.Add(new FaultContractExceptionHandlerMappingData("name2", "value2"));
            configurationObject.ExceptionMessage  = "message";
            configurationObject.FaultContractType = "fault contract";

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

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(FaultContractExceptionHandlerSetting), wmiSettings[0].GetType());
            Assert.AreEqual("message", ((FaultContractExceptionHandlerSetting)wmiSettings[0]).ExceptionMessage);
            Assert.AreEqual("fault contract", ((FaultContractExceptionHandlerSetting)wmiSettings[0]).FaultContractType);
            Dictionary <String, String> attributesDictionary = new Dictionary <string, string>();

            foreach (String entry in ((FaultContractExceptionHandlerSetting)wmiSettings[0]).Attributes)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, attributesDictionary);
            }
            Assert.AreEqual(2, attributesDictionary.Count);
            Assert.AreEqual("value1", attributesDictionary["name1"]);
            Assert.AreEqual("value2", attributesDictionary["name2"]);
        }
        public void WmiSettingsAreGeneratedIfWmiIsEnabled()
        {
            OracleConnectionData connection1Data = new OracleConnectionData();

            connection1Data.Name = "data1";
            connection1Data.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connection1Data.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connection1Data);

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

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(OracleConnectionSetting), wmiSettings[0].GetType());

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

            foreach (String entry in ((OracleConnectionSetting)wmiSettings[0]).Packages)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, packagesDictionary);
            }
            Assert.AreEqual(2, packagesDictionary.Count);
            Assert.AreEqual("prefix11", packagesDictionary["package11"]);
            Assert.AreEqual("prefix12", packagesDictionary["package12"]);
        }