public void ConvertTo()
        {
            var xml = string.Format(
                "<s0:Properties xmlns:s0=\"{0}\" xmlns:s1=\"urn\">"
                + "<s1:Property1 xpath=\"*/some-node\" />"
                + "<s1:Property2 mode=\"promote\" xpath=\"*/other-node\" />"
                + "</s0:Properties>",
                SchemaAnnotations.NAMESPACE);

            var sut = new PropertyExtractorCollectionConverter();
            var extractorCollection = new PropertyExtractorCollection(
                new XPathExtractor(new XmlQualifiedName("Property1", "urn"), "*/some-node", ExtractionMode.Write),
                new XPathExtractor(new XmlQualifiedName("Property2", "urn"), "*/other-node", ExtractionMode.Promote));

            Assert.That(
                sut.ConvertTo(extractorCollection, typeof(string)),
                Is.EqualTo(xml));
        }
        public void ConvertFrom()
        {
            var xml = string.Format(
                @"<san:Properties xmlns:s0='urn' xmlns:san='{0}'>
  <s0:Property1 xpath='*/some-node'/>
  <s0:Property2 promoted='true' xpath='*/other-node'/>
</san:Properties>",
                SchemaAnnotations.NAMESPACE);

            var sut = new PropertyExtractorCollectionConverter();

            Assert.That(
                sut.ConvertFrom(xml),
                Is.EqualTo(
                    new[] {
                new XPathExtractor(new XmlQualifiedName("Property1", "urn"), "*/some-node", ExtractionMode.Write),
                new XPathExtractor(new XmlQualifiedName("Property2", "urn"), "*/other-node", ExtractionMode.Promote)
            }));
        }
Example #3
0
 /// <summary>
 /// Saves the current component configuration into the property bag
 /// </summary>
 /// <param name="propertyBag">Configuration property bag</param>
 protected override void Save(IPropertyBag propertyBag)
 {
     propertyBag.WriteProperty("Extractors", PropertyExtractorCollectionConverter.Serialize(Extractors));
 }
Example #4
0
 /// <summary>
 /// Loads configuration properties for the component
 /// </summary>
 /// <param name="propertyBag">Configuration property bag</param>
 protected override void Load(IPropertyBag propertyBag)
 {
     propertyBag.ReadProperty("Extractors", value => Extractors = PropertyExtractorCollectionConverter.Deserialize(value));
 }
        public void ConvertFromNull()
        {
            var sut = new PropertyExtractorCollectionConverter();

            Assert.That(sut.ConvertFrom(null), Is.Empty);
        }
        public void ConvertFromEmpty()
        {
            var sut = new PropertyExtractorCollectionConverter();

            Assert.That(sut.ConvertFrom(string.Empty), Is.Empty);
        }
        public void CanConvertTo()
        {
            var sut = new PropertyExtractorCollectionConverter();

            Assert.That(sut.CanConvertTo(typeof(string)));
        }
        public void ConvertToNull()
        {
            var sut = new PropertyExtractorCollectionConverter();

            Assert.That(sut.ConvertTo(new PropertyExtractorCollection(), typeof(string)), Is.Null);
        }