public DiscriminatorMapping()
 {
     _attributes = new AttributeStore<DiscriminatorMapping>();
     _attributes.SetDefault(x => x.IsNotNullable, true);
     _attributes.SetDefault(x => x.Insert, true);
     _attributes.SetDefault(x => x.DiscriminatorType, DiscriminatorType.String);
 }
 public void Cascade_should_be_fluent()
 {
     var oneToManyPart = new OneToManyPart<Artist, Album>(null);
     var attributeStore = new AttributeStore<ICollectionMapping>();
     var cascadePart = new CascadePart<OneToManyPart<Artist, Album>>(oneToManyPart, attributeStore);
     cascadePart.All().ShouldEqual(oneToManyPart);
 }
        public void Can_set_cascade_save_update()
        {
            var attributeStore = new AttributeStore<ICollectionMapping>();
            var cascadePart = new CascadePart<OneToManyPart<Artist, Album>>(null, attributeStore);
            cascadePart.SaveUpdate();

            attributeStore.Get(x => x.Cascade).ShouldEqual(CollectionCascadeType.SaveUpdate);
        }
        public void CopyTo(AttributeStore store)
        {
            foreach (var pair in attributes)
                store.attributes[pair.Key] = pair.Value;

            foreach (var pair in defaults)
                store.defaults[pair.Key] = pair.Value;
        }
        public void MappedShouldDefaultToTrueIfNameAttributeIsSet()
        {
            var store = new AttributeStore<CompositeIdMapping>();
            store.Set(x => x.Name, "someName");

            var mapping = new CompositeIdMapping(store.CloneInner());
            mapping.Mapped.ShouldBeTrue();
        }
        public void Can_set_cascade_all_delete_orphan()
        {
            var attributeStore = new AttributeStore<ICollectionMapping>();
            var cascadePart = new CollectionCascadePart<OneToManyPart<Artist, Album>>(null, attributeStore);
            cascadePart.AllDeleteOrphan();

            attributeStore.Get(x => x.Cascade).ShouldEqual(CollectionCascadeType.AllDeleteOrphan);
        }
        public void MappedShouldDefaultToFalseIfNameAttributeIsBlank()
        {
            var store = new AttributeStore<CompositeIdMapping>();
            store.Set(x => x.Name, string.Empty);

            var mapping = new CompositeIdMapping(store.CloneInner());
            mapping.Mapped.ShouldBeFalse();
        }
        public void Merge(AttributeStore otherStore)
        {
            foreach (var key in otherStore.defaults.Keys)
                defaults[key] = otherStore.defaults[key];

            foreach (var key in otherStore.attributes.Keys)
                attributes[key] = otherStore.attributes[key];
        }
        public DiscriminatorMapping(ClassMapping parentClass)
        {
            ParentClass = parentClass;

            attributes = new AttributeStore<DiscriminatorMapping>();
            attributes.SetDefault(x => x.NotNull, true);
            attributes.SetDefault(x => x.Insert, true);
            attributes.SetDefault(x => x.Type, typeof(string));
        }
        public void ShouldPassClassmappingsToTheVisitor()
        {
            // FakeItEasy calls ToString methods, which ends up in NullPointer
            // if Type attribute is not the AttributeStore
            var attributeStore = new AttributeStore();
            attributeStore.Set("Type", 0, typeof(object));

            var hibMap = new HibernateMapping();
            var classMap = new ClassMapping(attributeStore);
            hibMap.AddClass(classMap);

            var visitor = A.Fake<IMappingModelVisitor>();

            hibMap.AcceptVisitor(visitor);

            A.CallTo(() => visitor.Visit(classMap)).MustHaveHappened();
        }
示例#11
0
 protected ParentMapping(AttributeStore attributes)
 {
     this.attributes = attributes;
 }
示例#12
0
 public VersionMapping(AttributeStore underlyingStore)
     : base(underlyingStore)
 {
 }
示例#13
0
 public ColumnMapping(AttributeStore underlyingStore)
 {
     attributes = new AttributeStore <ColumnMapping>(new DerivedAttributeStore(underlyingStore));
 }
示例#14
0
 public FilterMapping(AttributeStore underlyingStore)
 {
     attributes = new AttributeStore <FilterMapping>(underlyingStore);
 }
 public ManyToOneMapping()
 {
     _attributes = new AttributeStore<ManyToOneMapping>();
 }
示例#16
0
 public NaturalIdMapping(AttributeStore attributes)
 {
     this.attributes = attributes;
 }
 public ColumnMapping(AttributeStore<ColumnMapping> attributes)
 {
     this.attributes = attributes;
 }
 protected ColumnBasedMappingBase(AttributeStore underlyingStore)
 {
     attributes = underlyingStore.Clone();
 }
示例#19
0
 public void CopyTo(AttributeStore theirStore)
 {
     layeredValues.CopyTo(theirStore.layeredValues);
 }
示例#20
0
 public AnyMapping(AttributeStore attributes)
 {
     this.attributes = attributes;
 }
 protected PropertyMapping(AttributeStore store)
     : base(store)
 {
     _attributes = new AttributeStore<PropertyMapping>(store);
 }
示例#22
0
 protected MetaValueMapping(AttributeStore attributes)
 {
     this.attributes = attributes;
 }
示例#23
0
 public FilterMapping(AttributeStore attributes)
 {
     this.attributes = attributes;
 }
示例#24
0
 public ImportMapping(AttributeStore attributes)
 {
     this.attributes = attributes;
 }
 protected ClassMapping(AttributeStore store)
     : base(store)
 {
     _attributes = new AttributeStore<ClassMapping>(store);
     _subclasses = new List<ISubclassMapping>();
 }
示例#26
0
 public void Merge(AttributeStore columnAttributes)
 {
     columnAttributes.layeredValues.CopyTo(layeredValues);
 }
 public FilterDefinitionMapping(AttributeStore underlyingStore)
 {
     attributes = new AttributeStore<FilterMapping>(underlyingStore);
     parameters = new Dictionary<string, IType>();
 }
示例#28
0
 public ColumnMapping(AttributeStore attributes)
 {
     this.attributes = attributes;
 }
 public void CopyTo(AttributeStore store)
 {
     foreach (KeyValuePair<string, object> pair in _attributes)
         store._attributes[pair.Key] = pair.Value;
 }
示例#30
0
 public VersionMapping(AttributeStore underlyingStore)
     : base(underlyingStore)
 {}
示例#31
0
 public void MergeAttributes(AttributeStore columnAttributes)
 {
     attributes.Merge(columnAttributes);
 }
示例#32
0
 public KeyMapping(AttributeStore underlyingStore)
 {
     attributes = new AttributeStore <KeyMapping>(underlyingStore);
 }
 public HibernateMapping()
 {
     attributes = new AttributeStore<HibernateMapping>();
     classes = new List<ClassMapping>();
     imports = new List<ImportMapping>();
 }
 public DiscriminatorMapping(AttributeStore underlyingStore)
     : base(underlyingStore)
 {
 }
        public void Should_pass_subclasses_to_the_visitor()
        {
            // FakeItEasy ;for some reason; calls ToString method on SubClassMapping
            // which ended in NullPointerException if AttributeStore didn't contain Type attribute.
            var attributeStore = new AttributeStore();
            attributeStore.Set("Type", 0, typeof(object));

            var classMap = new ClassMapping();
            classMap.Set(x => x.Name, Layer.Defaults, "class1");
            classMap.AddSubclass(new SubclassMapping(SubclassType.JoinedSubclass, attributeStore));

            var visitor = A.Fake<IMappingModelVisitor>();

            classMap.AcceptVisitor(visitor);

            A.CallTo(() => visitor.Visit(classMap.Subclasses.First())).MustHaveHappened();
        }
 protected ComponentMapping(AttributeStore store)
     : base(store)
 {
     _attributes = new AttributeStore<ComponentMapping>(store);
     _mappedMembers = new MappedMembers();
 }
 protected JoinedSubclassMapping(AttributeStore store)
     : base(store)
 {
     _subclasses = new List<JoinedSubclassMapping>();
     _attributes = new AttributeStore<JoinedSubclassMapping>(store);
 }
 public PropertyMapping(AttributeStore underlyingStore)
     : base(underlyingStore)
 {
 }
示例#39
0
 public static T GetOrDefault <T>(this AttributeStore store, string attribute)
 {
     return((T)(store.Get(attribute) ?? default(T)));
 }
 public OneToOneMapping(AttributeStore underlyingStore)
 {
     attributes = new AttributeStore <OneToOneMapping>(underlyingStore);
 }
示例#41
0
 public FilterMapping(AttributeStore underlyingStore)
 {
     attributes = new AttributeStore<FilterMapping>(underlyingStore);
 }
示例#42
0
 public JoinMapping(AttributeStore underlyingStore)
 {
     attributes    = new AttributeStore <JoinMapping>(underlyingStore);
     mappedMembers = new MappedMembers();
 }
示例#43
0
 public CacheMapping(AttributeStore underlyingStore)
 {
     attributes = new AttributeStore <CacheMapping>(underlyingStore);
 }
示例#44
0
 public ImportMapping(AttributeStore attributes)
 {
     this.attributes = attributes;
 }
 public HibernateMapping()
 {
     _attributes = new AttributeStore<HibernateMapping>();
     _classes = new List<ClassMapping>();
 }
 public ColumnMapping()
 {
     _attributes = new AttributeStore<ColumnMapping>();
 }
 protected MapsMemberBase(AttributeStore underlyingStore)
 {
     _attributes = new AttributeStore<MapsMemberBase>(underlyingStore);
     _attributes.SetDefault(x => x.MemberAccess, MemberAccess.CreateDefault());
 }
示例#48
0
 internal void MergeAttributes(AttributeStore <ColumnMapping> store)
 {
     attributes.Merge(store);
 }