public void ReadingElementSetsName()
 {
     var builder = new ContentTypeDefinitionBuilder();
     _reader.Merge(new XElement("foo"), builder);
     var type = builder.Build();
     Assert.That(type.Name, Is.EqualTo("foo"));
 }
 public void AttributesAreAppliedAsSettings()
 {
     var builder = new ContentTypeDefinitionBuilder();
     _reader.Merge(new XElement("foo", new XAttribute("x", "1")), builder);
     var type = builder.Build();
     Assert.That(type.Settings["x"], Is.EqualTo("1"));
 }
 public static void AlterTypeDefinition(this IContentDefinitionManager manager, string name, Action<ContentTypeDefinitionBuilder> alteration)
 {
     var typeDefinition = manager.GetTypeDefinition(name) ?? new ContentTypeDefinition(name, name.CamelFriendly());
     var builder = new ContentTypeDefinitionBuilder(typeDefinition);
     alteration(builder);
     manager.StoreTypeDefinition(builder.Build());
 }
 public void ChildElementsAreAddedAsPartsWithSettings()
 {
     var builder = new ContentTypeDefinitionBuilder();
     _reader.Merge(new XElement("foo", new XElement("bar", new XAttribute("y", "2"))), builder);
     var type = builder.Build();
     Assert.That(type.Parts.Single().PartDefinition.Name, Is.EqualTo("bar"));
     Assert.That(type.Parts.Single().Settings["y"], Is.EqualTo("2"));
 }
        public void PartsCanBeRemovedByNameWhenImporting()
        {
            const string partToBeRemoved = "alpha";

            var builder = new ContentTypeDefinitionBuilder();
            _reader.Merge(new XElement("foo",
                new XElement(partToBeRemoved),
                new XElement("remove", new XAttribute("name", partToBeRemoved))
                ), builder);
            var type = builder.Build();

            Assert.That(type.Parts.FirstOrDefault(part => part.PartDefinition.Name == partToBeRemoved), Is.Null);
        }
 public static ContentTypeDefinition Import(this IContentDefinitionReader reader, XElement source)
 {
     var target = new ContentTypeDefinitionBuilder();
     reader.Merge(source, target);
     return target.Build();
 }