public void SetUp()
 {
     provider = new CustomFormatterDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new CustomFormatterData();
 }
Beispiel #2
0
 public void SetUp()
 {
     provider            = new CustomFormatterDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new CustomFormatterData();
 }
Beispiel #3
0
        public void CustomFormatterNodeInitTest()
        {
            CustomFormatterData data = new CustomFormatterData();
            CustomFormatterNode node = new CustomFormatterNode(data);

            GeneratedApplicationNode.Nodes.Add(node);
            Assert.AreSame(data, node.FormatterData);
        }
Beispiel #4
0
 public void SetUp()
 {
     provider            = new ConfigurationElementManageabilityProviderWrapper(new CustomFormatterDataManageabilityProvider());
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     wmiSettings         = new List <ConfigurationSetting>();
     configurationObject = new CustomFormatterData();
 }
 public static void GenerateWmiObjects(CustomFormatterData data,
                                       ICollection <ConfigurationSetting> wmiSettings)
 {
     wmiSettings.Add(
         new CustomFormatterSetting(data,
                                    data.Name,
                                    data.Type.AssemblyQualifiedName,
                                    CustomDataWmiMapperHelper.GenerateAttributesArray(data.Attributes)));
 }
        internal static bool SaveChanges(CustomFormatterSetting setting,
                                         ConfigurationElement sourceElement)
        {
            CustomFormatterData element = (CustomFormatterData)sourceElement;

            element.TypeName = setting.FormatterType;
            CustomDataWmiMapperHelper.UpdateAttributes(setting.Attributes, element.Attributes);
            return(true);
        }
Beispiel #7
0
        public void CustomFormatterDataPropertiesTest()
        {
            CustomFormatterData data = new CustomFormatterData();
            NameValueItemCollection attributes = new NameValueItemCollection();
            attributes.Add(new NameValueItem("TEST", "test"));

            data.Attributes.Add(attributes[0]);

            Assert.AreEqual(attributes[0], data.Attributes[0]);
        }
Beispiel #8
0
        public void CustomFormatterDataPropertiesTest()
        {
            CustomFormatterData     data       = new CustomFormatterData();
            NameValueItemCollection attributes = new NameValueItemCollection();

            attributes.Add(new NameValueItem("TEST", "test"));

            data.Attributes.Add(attributes[0]);

            Assert.AreEqual(attributes[0], data.Attributes[0]);
        }
Beispiel #9
0
        /// <summary>
        /// Initialize a new instance of the <see cref="CustomFormatterNode"/> class with a <see cref="CustomFormatterData"/> instance.
        /// </summary>
        /// <param name="customFormatterData">A <see cref="CustomFormatterData"/> instance.</param>
        public CustomFormatterNode(CustomFormatterData customFormatterData)
        {
            if (null == customFormatterData) throw new ArgumentNullException("customFormatterData");

            customFormatterType = customFormatterData.Type;
            foreach (string key in customFormatterData.Attributes)
            {
                editableAttributes.Add(new EditableKeyValue(key, customFormatterData.Attributes[key]));
            }
            Rename(customFormatterData.Name);
        }
Beispiel #10
0
        public void CanCreatePoliciesForCustomLogFormatter()
        {
            CustomFormatterData data = new CustomFormatterData("name", typeof(MockCustomLogFormatter).AssemblyQualifiedName);

            data.Attributes.Add(MockCustomLogFormatter.AttributeKey, "attribute value");
            loggingSettings.Formatters.Add(data);
            container.AddExtension(new LoggingBlockExtension());
            MockCustomLogFormatter createdObject = (MockCustomLogFormatter)container.Resolve <ILogFormatter>("name");

            Assert.IsNotNull(createdObject);
            Assert.AreEqual("attribute value", createdObject.customValue);
        }
Beispiel #11
0
        public void BasePropetiesTest()
        {
            CustomFormatterData data = new CustomFormatterData();
            string typeName = "Test Type";
            string name = "Test Name";

            data.TypeName = typeName;
            data.Name = name;

            Assert.AreEqual(typeName, data.TypeName);
            Assert.AreEqual(name, data.Name);
        }
Beispiel #12
0
        public void BasePropetiesTest()
        {
            CustomFormatterData data = new CustomFormatterData();
            string typeName          = "Test Type";
            string name = "Test Name";

            data.TypeName = typeName;
            data.Name     = name;

            Assert.AreEqual(typeName, data.TypeName);
            Assert.AreEqual(name, data.Name);
        }
 public CustomFormatterNode(CustomFormatterData customFormatterData)
 {
     if (null == customFormatterData)
     {
         throw new ArgumentNullException("customFormatterData");
     }
     customFormatterTypeName = customFormatterData.TypeName;
     foreach (string key in customFormatterData.Attributes)
     {
         editableAttributes.Add(new EditableKeyValue(key, customFormatterData.Attributes[key]));
     }
     Rename(customFormatterData.Name);
 }
		public void CanCreatePoliciesForCustomLogFormatter()
		{
			CustomFormatterData data = new CustomFormatterData("name", typeof(MockCustomLogFormatter).AssemblyQualifiedName);
			data.Attributes.Add(MockCustomLogFormatter.AttributeKey, "attribute value");
			loggingSettings.Formatters.Add(data);

		    using (var container = CreateContainer())
		    {
		        MockCustomLogFormatter createdObject = (MockCustomLogFormatter)container.Resolve<ILogFormatter>("name");

		        Assert.IsNotNull(createdObject);
		        Assert.AreEqual("attribute value", createdObject.customValue);
		    }
		}
        public void CanBuildCustomLogFormatterFromGivenConfiguration()
        {
            CustomFormatterData customData
                = new CustomFormatterData("formatter", typeof(MockCustomLogFormatter));
            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            LoggingSettings settings = new LoggingSettings();
            settings.Formatters.Add(customData);
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
            configurationSource.Add(LoggingSettings.SectionName, settings);

            ILogFormatter formatter = GetFormatter("formatter", configurationSource);

            Assert.IsNotNull(formatter);
            Assert.AreSame(typeof(MockCustomLogFormatter), formatter.GetType());
            Assert.AreEqual("value1", ((MockCustomLogFormatter)formatter).customValue);
        }
        public void CustomFormatterDataTest()
        {
            string attributeKey      = "attKey";
            string attributeValue    = "attValue";
            string name              = "some name";
            Type   type              = typeof(BinaryLogFormatter);
            CustomFormatterData data = new CustomFormatterData();

            data.Name = name;
            data.Type = type;
            data.Attributes.Add(attributeKey, attributeValue);
            CustomFormatterNode node = new CustomFormatterNode(data);

            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type.AssemblyQualifiedName, node.Type);
            Assert.AreEqual(attributeKey, node.Attributes[0].Key);
            Assert.AreEqual(attributeValue, node.Attributes[0].Value);
        }
        public void CustomFormatterNodeTest()
        {
            string attributeKey               = "attKey";
            string attributeValue             = "attValue";
            string name                       = "some name";
            Type   type                       = typeof(BinaryLogFormatter);
            CustomFormatterNode formatterNode = new CustomFormatterNode();

            formatterNode.Attributes.Add(new EditableKeyValue(attributeKey, attributeValue));
            formatterNode.Name = name;
            formatterNode.Type = type.AssemblyQualifiedName;
            CustomFormatterData nodeData = (CustomFormatterData)formatterNode.FormatterData;

            Assert.AreEqual(name, nodeData.Name);
            Assert.AreEqual(type, nodeData.Type);
            Assert.AreEqual(attributeKey, nodeData.Attributes.AllKeys[0]);
            Assert.AreEqual(attributeValue, nodeData.Attributes[attributeKey]);
        }
        public void CanBuildCustomLogFormatterFromGivenConfiguration()
        {
            CustomFormatterData customData
                = new CustomFormatterData("formatter", typeof(MockCustomLogFormatter));

            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            LoggingSettings settings = new LoggingSettings();

            settings.Formatters.Add(customData);
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            configurationSource.Add(LoggingSettings.SectionName, settings);
            ILogFormatter formatter = LogFormatterCustomFactory.Instance.Create(context, "formatter", configurationSource, reflectionCache);

            Assert.IsNotNull(formatter);
            Assert.AreSame(typeof(MockCustomLogFormatter), formatter.GetType());
            Assert.AreEqual("value1", ((MockCustomLogFormatter)formatter).customValue);
        }
        public void CanBuildCustomLogFormatterFromSavedConfiguration()
        {
            CustomFormatterData customData
                = new CustomFormatterData("formatter", typeof(MockCustomLogFormatter));
            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            LoggingSettings settings = new LoggingSettings();
            settings.Formatters.Add(customData);

            IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>(1);
            sections[LoggingSettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            ILogFormatter formatter = GetFormatter("formatter", configurationSource);

            Assert.IsNotNull(formatter);
            Assert.AreSame(typeof(MockCustomLogFormatter), formatter.GetType());
            Assert.AreEqual("value1", ((MockCustomLogFormatter)formatter).customValue);
        }
        public void CustomFormatterDataTest()
        {
            string attributeKey = "attKey";
            string attributeValue = "attValue";
            string name = "some name";
            Type type = typeof(BinaryLogFormatter);

            CustomFormatterData data = new CustomFormatterData();
            data.Name = name;
            data.Type = type;

            data.Attributes.Add(attributeKey, attributeValue);

            CustomFormatterNode node = new CustomFormatterNode(data);

            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type, node.Type);
            Assert.AreEqual(attributeKey, node.Attributes[0].Key);
            Assert.AreEqual(attributeValue, node.Attributes[0].Value);
        }
        public void CanBuildCustomLogFormatterFromSavedConfiguration()
        {
            CustomFormatterData customData
                = new CustomFormatterData("formatter", typeof(MockCustomLogFormatter));

            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            LoggingSettings settings = new LoggingSettings();

            settings.Formatters.Add(customData);
            IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(1);

            sections[LoggingSettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);
            ILogFormatter formatter = LogFormatterCustomFactory.Instance.Create(context, "formatter", configurationSource, reflectionCache);

            Assert.IsNotNull(formatter);
            Assert.AreSame(typeof(MockCustomLogFormatter), formatter.GetType());
            Assert.AreEqual("value1", ((MockCustomLogFormatter)formatter).customValue);
        }
Beispiel #22
0
        public void CustomFormatterDataTest()
        {
            NameValueItem testItem = new NameValueItem("TEST", "VALUE");
            string        name     = "testName";
            string        type     = "testType";

            CustomFormatterData data = new CustomFormatterData();

            data.Attributes.Add(testItem);
            data.TypeName = type;
            data.Name     = name;

            CustomFormatterNode node = new CustomFormatterNode(data);

            GeneratedApplicationNode.Nodes.Add(node);
            CustomFormatterData nodeData = (CustomFormatterData)node.FormatterData;

            Assert.AreEqual(testItem, nodeData.Attributes[0]);
            Assert.AreEqual(name, nodeData.Name);
            Assert.AreEqual(type, nodeData.TypeName);
        }
Beispiel #23
0
        public void SavesChangesToConfigurationObject()
        {
            CustomFormatterData sourceElement = new CustomFormatterData("name", typeof(bool));

            sourceElement.Attributes.Add("att3", "val3");
            sourceElement.Attributes.Add("att4", "val4");
            sourceElement.Attributes.Add("att5", "val5");
            List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1);

            CustomFormatterDataWmiMapper.GenerateWmiObjects(sourceElement, settings);
            Assert.AreEqual(1, settings.Count);
            CustomFormatterSetting setting = settings[0] as CustomFormatterSetting;

            Assert.IsNotNull(setting);
            setting.Attributes    = new string[] { "att1=val1", "att2=val2" };
            setting.FormatterType = typeof(int).AssemblyQualifiedName;
            setting.Commit();
            Assert.AreEqual(2, sourceElement.Attributes.Count);
            Assert.AreEqual("val1", sourceElement.Attributes["att1"]);
            Assert.AreEqual("val2", sourceElement.Attributes["att2"]);
            Assert.AreEqual(typeof(int), sourceElement.Type);
        }
Beispiel #24
0
 /// <summary>
 /// Creates node with specified configuration data.
 /// </summary>
 /// <param name="data">Configuration data.</param>
 public CustomFormatterNode(CustomFormatterData data) : base(data)
 {
     this.customFormatterData = data;
 }
 internal CustomFormatterBuilder(string formatterName, Type customFormatterType, NameValueCollection attributes)
 {
     customFormatterData = new CustomFormatterData(formatterName, customFormatterType);
     customFormatterData.Attributes.Add(attributes);
 }
 internal CustomFormatterBuilder(string formatterName, Type customFormatterType, NameValueCollection attributes)
 {
     customFormatterData = new CustomFormatterData(formatterName, customFormatterType);
     customFormatterData.Attributes.Add(attributes);
 }
 public void Given()
 {
     this.formatterData = new CustomFormatterData("myName", typeof(MockCustomLogFormatter));
     this.formatterData.Attributes.Add(MockCustomLogFormatter.AttributeKey, "bar");
 }
Beispiel #28
0
 public CustomFormatterSetting(CustomFormatterData sourceElement, string name, string formatterType, string[] attributes)
     : base(sourceElement, name)
 {
     this.formatterType = formatterType;
     this.attributes    = attributes;
 }
 public void Given()
 {
     this.formatterData = new CustomFormatterData("myName", typeof(MockCustomLogFormatter));
     this.formatterData.Attributes.Add(MockCustomLogFormatter.AttributeKey, "bar");
 }
 public void Given()
 {
     formatterData = new CustomFormatterData("myName", typeof(MockCustomLogFormatter));
     formatterData.Attributes.Add("foo", "bar");
     registration = formatterData.GetRegistrations().First();
 }
Beispiel #31
0
 public void Given()
 {
     formatterData = new CustomFormatterData("myName", typeof(MockCustomLogFormatter));
     formatterData.Attributes.Add("foo", "bar");
     registration = formatterData.GetRegistrations().First();
 }