public void Should_not_write_the_default_access_type()
        {
            var component = new ComponentMapping();

            _componentWriter.VerifyXml(component)
                .DoesntHaveAttribute("access");
        }
        public void Should_apply_to_components()
        {
            var propertyInfo = ReflectionHelper.GetProperty((SalaryEmployee e) => e.Salary);
            var componentMapping = new ComponentMapping {PropertyInfo = propertyInfo};

            _namingConvention.ProcessComponent(componentMapping);

            componentMapping.PropertyName.ShouldEqual(propertyInfo.Name);
        }
        public void ShouldWriteAnys()
        {
            var mapping = new ComponentMapping();

            mapping.AddAny(new AnyMapping());

            writer.VerifyXml(mapping)
                .Element("any").Exists();
        }
        public void ShouldWriteBags()
        {
            var mapping = new ComponentMapping();

            mapping.AddCollection(new BagMapping());

            writer.VerifyXml(mapping)
                .Element("bag").Exists();
        }
        public void ShouldWriteComponents()
        {
            var mapping = new ComponentMapping();

            mapping.AddComponent(new ComponentMapping());

            writer.VerifyXml(mapping)
                .Element("component").Exists();
        }
        public void ShouldWriteDynamicComponents()
        {
            var mapping = new ComponentMapping(ComponentType.DynamicComponent);

            mapping.AddComponent(new ComponentMapping(ComponentType.DynamicComponent));

            writer.VerifyXml(mapping)
                .Element("dynamic-component").Exists();
        }
        public override void ProcessComponent(ComponentMapping componentMapping)
        {
            if (!componentMapping.Attributes.IsSpecified(x => x.PropertyName))
            {
                if(componentMapping.MappedMember == null)
                    throw new ConventionException("Cannot apply the naming convention. No member specified.", componentMapping);

                componentMapping.PropertyName = DetermineNameFromMember(componentMapping.MappedMember);
            }
        }
        public void Should_write_multiple_nestings_of_components()
        {
            var componentMapping = new ComponentMapping();

            componentMapping.AddComponent(new ComponentMapping { PropertyName = "Child"});
            componentMapping.Components.First().AddComponent(new ComponentMapping { PropertyName = "Grandchild" });

            _componentWriter.VerifyXml(componentMapping)
                .Element("component").Exists().HasAttribute("name", "Child")
                .Element("component").Exists().HasAttribute("name", "Grandchild");
        }
        public void Should_write_the_collections()
        {
            var componentMapping = new ComponentMapping();
            componentMapping.AddCollection(new BagMapping());

            _mocker.Get<IHbmWriter<ICollectionMapping>>()
                .Expect(x => x.Write(componentMapping.Collections.First()))
                .Return(new HbmBag());

            _componentWriter.VerifyXml(componentMapping)
                .Element("bag").Exists();
        }
        private PropertyMapping GetPropertyMapping(Type type, PropertyInfo property, ComponentMapping component)
        {
            var mapping = new PropertyMapping
            {
                ContainingEntityType = type,
                PropertyInfo = property
            };

            var columnName = property.Name;

            if (component != null)
                columnName = expressions.GetComponentColumnPrefix(component.PropertyInfo) + columnName;

            mapping.AddDefaultColumn(new ColumnMapping { Name = columnName });

            if (!mapping.IsSpecified(x => x.Name))
                mapping.Name = mapping.PropertyInfo.Name;

            if (!mapping.IsSpecified(x => x.Type))
                mapping.SetDefaultValue(x => x.Type, new TypeReference(mapping.PropertyInfo.PropertyType));

            return mapping;
        }
        private PropertyMapping GetPropertyMapping(Type type, Member property, ComponentMapping component)
        {
            var mapping = new PropertyMapping
            {
                ContainingEntityType = type,
                Member = property
            };

            var columnName = property.Name;
            
            if (component != null)
                columnName = cfg.GetComponentColumnPrefix(component.Member) + columnName;

            mapping.AddDefaultColumn(new ColumnMapping { Name = columnName });

            if (!mapping.IsSpecified("Name"))
                mapping.Name = mapping.Member.Name;

            if (!mapping.IsSpecified("Type"))
                mapping.SetDefaultValue("Type", GetDefaultType(property));

            return mapping;
        }
        public void ShouldWriteManyToOnes()
        {
            var mapping = new ComponentMapping();

            mapping.AddReference(new ManyToOneMapping());

            writer.VerifyXml(mapping)
                .Element("many-to-one").Exists();
        }
        public void Should_write_the_references()
        {
            var componentMapping = new ComponentMapping();
            componentMapping.AddReference(new ManyToOneMapping());

            _mocker.Get<IHbmWriter<ManyToOneMapping>>()
                .Expect(x => x.Write(componentMapping.References.First()))
                .Return(new HbmManyToOne());

            _componentWriter.VerifyXml(componentMapping)
                .Element("many-to-one").Exists();
        }
 public void CreateDsl()
 {
     mapping = new ComponentMapping(ComponentType.Component);
     inspector = new ComponentInspector(mapping);
 }
        public void Should_produce_valid_hbm()
        {
            var component = new ComponentMapping {PropertyName = "EmailAddress"};

            _componentWriter.ShouldGenerateValidOutput(component);
        }
 public virtual void Visit(ComponentMapping componentMapping)
 {
 }
        public void Should_write_the_properties()
        {
            var componentMapping = new ComponentMapping();
            componentMapping.AddProperty(new PropertyMapping());
            _mocker.Get<IHbmWriter<PropertyMapping>>()
                .Expect(x => x.Write(componentMapping.Properties.First()))
                .Return(new HbmProperty());

            _componentWriter.VerifyXml(componentMapping)
                .Element("property").Exists();
        }
 public virtual void ProcessComponent(ComponentMapping mapping)
 {
 }
        public void ShouldWriteSets()
        {
            var mapping = new ComponentMapping(ComponentType.DynamicComponent);

            mapping.AddCollection(new SetMapping());

            writer.VerifyXml(mapping)
                .Element("set").Exists();
        }
 public void AddComponent(ComponentMapping componentMapping)
 {
     _components.Add(componentMapping);
 }
        public void Should_write_the_components()
        {
            var componentMapping = new ComponentMapping();
            componentMapping.AddComponent(new ComponentMapping());

            _componentWriter.VerifyXml(componentMapping)
                .Element("component").Exists();
        }
        public void ShouldWriteOneToOnes()
        {
            var mapping = new ComponentMapping();

            mapping.AddOneToOne(new OneToOneMapping());

            writer.VerifyXml(mapping)
                .Element("one-to-one").Exists();
        }
        public void ShouldWriteProperties()
        {
            var mapping = new ComponentMapping();

            mapping.AddProperty(new PropertyMapping());

            writer.VerifyXml(mapping)
                .Element("property").Exists();
        }
        public void ShouldWriteLists()
        {
            var mapping = new ComponentMapping(ComponentType.Component);

            mapping.AddCollection(CollectionMapping.List());

            writer.VerifyXml(mapping)
                .Element("list").Exists();
        }
 public override void ProcessComponent(ComponentMapping mapping)
 {
     base.ProcessComponent(mapping);
 }
Beispiel #26
0
 public ComponentBaseInspector(ComponentMapping mapping)
 {
     this.mapping = mapping;
 }
 public DynamicComponentInstance(ComponentMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
     nextBool = true;
 }
        public void Should_write_the_specified_access_type()
        {
            var component = new ComponentMapping();
            component.MemberAccess = MemberAccess.Create(AccessStrategy.Field, NamingStrategy.CamelCase);

            _componentWriter.VerifyXml(component)
                .HasAttribute("access", "field.camelcase");
        }
        public override void establish_context()
        {
            visitor = new ComponentColumnPrefixVisitor();
            reference_with_a_prefix = new ReferenceComponentMapping(new DummyPropertyInfo("PROPERTY", typeof(Target)).ToMember(), typeof(ComponentTarget), typeof(Target), column_prefix);

            var external_mapping = new ExternalComponentMapping();

            external_mapping.AddAny(any_with_column("anyColumn"));
            external_mapping.AddCollection(collection_with_column("collectionColumn"));

            var component = new ComponentMapping();
            component.AddProperty(property_with_column("componentPropertyColumn"));

            external_mapping.AddComponent(component);
            external_mapping.AddProperty(property_with_column("propertyColumn"));
            external_mapping.AddReference(reference_with_column("referenceColumn"));

            reference_with_a_prefix.AssociateExternalMapping(external_mapping);
        }
        public void ShouldWriteMaps()
        {
            var mapping = new ComponentMapping(ComponentType.Component);

            mapping.AddCollection(new MapMapping());

            writer.VerifyXml(mapping)
                .Element("map").Exists();
        }