Пример #1
0
        public void SavesChangesToConfigurationObject()
        {
            CustomHandlerData sourceElement = new CustomHandlerData("name",
                                                                    "System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
            List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1);

            CustomExceptionHandlerDataWmiMapper.GenerateWmiObjects(sourceElement, settings);
            Assert.AreEqual(1, settings.Count);
            CustomHandlerSetting setting = (CustomHandlerSetting)settings[0];

            Assert.IsNotNull(setting);
            setting.Commit();
            Assert.AreEqual(setting.ExceptionType, sourceElement.Attributes["ExceptionType"]);
        }
Пример #2
0
        public void WmiQueryReturnsSingleResultIfSinglePublishedInstance()
        {
            string[]             attributes = new string[] { "att1", "att2" };
            CustomHandlerSetting setting    = new CustomHandlerSetting(null, "name", "FilterType", attributes);

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM CustomHandlerSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("name", resultEnumerator.Current.Properties["Name"].Value);
                Assert.AreEqual("FilterType", resultEnumerator.Current.Properties["HandlerType"].Value);
                Assert.AreEqual("CustomHandlerSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                Assert.IsFalse(resultEnumerator.MoveNext());
            }
        }
Пример #3
0
        public void CanBindObject()
        {
            string[]             attributes = new string[] { "att1", "att2" };
            CustomHandlerSetting setting    = new CustomHandlerSetting(null, "name", "FilterType", attributes);

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Policy          = "Policy";
            setting.ExceptionType   = typeof(Exception).AssemblyQualifiedName;
            setting.Publish();
            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM CustomHandlerSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("CustomHandlerSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                ManagementObject managementObject = (ManagementObject)resultEnumerator.Current;
                Assert.IsNotNull(managementObject);
                managementObject.Put();
            }
        }