Inheritance: CollectionMappingBase
        public void ShouldWriteBagForBagMapping()
        {
            var mapping = new BagMapping();

            writer.VerifyXml(mapping)
                .RootElement.HasName("bag");
        }
        public void Should_not_write_the_default_access_type()
        {
            var bag = new BagMapping();

            _writer.VerifyXml(bag)
                .DoesntHaveAttribute("access");
        }
 public BagInspector(BagMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
     mappedProperties.AutoMap();
     mappedProperties.Map(x => x.LazyLoad, x => x.Lazy);
 }
        public void ShouldWriteCacheElement()
        {
            var mapping = new BagMapping();

            mapping.Cache = new CacheMapping();

            writer.VerifyXml(mapping)
                .Element("cache").Exists();
        }
        protected ICollectionMapping collection_with_column(string column)
        {
            var collection = new BagMapping();

            collection.Key = new KeyMapping();
            collection.Key.AddDefaultColumn(new ColumnMapping { Name = column });

            return collection;
        }
        public void Should_apply_to_collection_mapping()
        {
            var bagMapping = new BagMapping();
            bagMapping.BindToMember(ReflectionHelper.GetMember((Album a) => a.Tracks));

            _namingConvention.ProcessBag(bagMapping);

            bagMapping.Name.ShouldEqual(bagMapping.MappedMember.Name);
        }
        public void Should_apply_to_collection_mapping()
        {
            var propertyInfo = ReflectionHelper.GetProperty((Album a) => a.Tracks);
            var bagMapping = new BagMapping { PropertyInfo = propertyInfo };

            _namingConvention.ProcessBag(bagMapping);

            bagMapping.Name.ShouldEqual(bagMapping.PropertyInfo.Name);
        }
        public void Should_write_the_contents()
        {
            var bag = new BagMapping {Contents = new OneToManyMapping()};

            _mocker.Get<IHbmWriter<ICollectionContentsMapping>>()
                .Expect(x => x.Write(bag.Contents))
                .Return(new HbmOneToMany());

            _writer.VerifyXml(bag)
                .Element("one-to-many").Exists();
        }
        public void Should_write_the_key()
        {
            var bag = new BagMapping { Key = new KeyMapping()};

            _mocker.Get<IHbmWriter<KeyMapping>>()
                .Expect(x => x.Write(bag.Key))
                .Return(new HbmKey());

            _writer.VerifyXml(bag)
                .Element("key").Exists();
        }
Example #10
0
 public bool Equals(BagMapping other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(base.Equals(other) && Equals(other.attributes, attributes));
 }
        public void CanAddBag()
        {
            var bag = new BagMapping
                          {
                              Name = "bag1",
                              Key = new KeyMapping(),
                              Contents = new OneToManyMapping { ClassName = "class1" }
                          };
            _classMapping.AddCollection(bag);

            _classMapping.Collections.ShouldContain(bag);
        }
        public void CanAddBag()
        {
            var bag = new BagMapping
                          {
                              Name = "bag1",
                              Key = new KeyMapping(),
                              Relationship = new OneToManyMapping { Class = new TypeReference("class1") }
                          };
            _classMapping.AddCollection(bag);

            _classMapping.Collections.ShouldContain(bag);
        }
        public void Should_produce_valid_hbm()
        {
            var bag = new BagMapping { Name = "bag1", Contents = new OneToManyMapping(), Key = new KeyMapping() };

            _mocker.Get<IHbmWriter<ICollectionContentsMapping>>()
                .Expect(x => x.Write(bag.Contents)).Return(new HbmOneToMany { @class = "class1" });

            _mocker.Get<IHbmWriter<KeyMapping>>()
                .Expect(x => x.Write(bag.Key)).Return(new HbmKey());

            _writer.ShouldGenerateValidOutput(bag);
        }
        public void Should_produce_valid_hbm()
        {
            var bag = new BagMapping { Name = "bag1", Contents = new OneToManyMapping(), Key = new KeyMapping() };

            var contentsWriter = MockRepository.GenerateStub<IXmlWriter<ICollectionContentsMapping>>();
            contentsWriter.Expect(x => x.Write(bag.Contents)).Return(new HbmOneToMany { @class = "class1" });

            var keyWriter = MockRepository.GenerateStub<IXmlWriter<KeyMapping>>();
            keyWriter.Expect(x => x.Write(bag.Key)).Return(new HbmKey());

            var writer = new HbmBagWriter(contentsWriter, keyWriter);
            writer.ShouldGenerateValidOutput(bag);
        }
        public void Should_write_the_key()
        {
            var bag = new BagMapping { Key = new KeyMapping()};

            var keyWriter = MockRepository.GenerateMock<IXmlWriter<KeyMapping>>();
            keyWriter.Expect(x => x.Write(bag.Key))
                .Return(new HbmKey());

            var writer = new HbmBagWriter(null, keyWriter);

            writer.VerifyXml(bag)
                .Element("key").Exists();
        }
        public void Should_write_the_contents()
        {
            var bag = new BagMapping {Contents = new OneToManyMapping()};

            var contentsWriter = MockRepository.GenerateMock<IXmlWriter<ICollectionContentsMapping>>();
            contentsWriter.Expect(x => x.Write(bag.Contents))
                .Return(new HbmOneToMany());

            var writer = new HbmBagWriter(contentsWriter, null);

            writer.VerifyXml(bag)
                .Element("one-to-many").Exists();
        }
 public void ShouldNotWriteCollectionTypeWhenEmpty()
 {
     var bagMapping = new BagMapping {CollectionType = TypeReference.Empty};
     writer.VerifyXml(bagMapping)
         .DoesntHaveAttribute("collection-type");
 }
 public virtual void ProcessBag(BagMapping bagMapping)
 {
 }
 public void CreateDsl()
 {
     mapping = new BagMapping();
     inspector = new BagInspector(mapping);
 }
        public void Should_write_the_specified_access_type()
        {
            var bag = new BagMapping();
            bag.MemberAccess = MemberAccess.Create(AccessStrategy.Field, NamingStrategy.CamelCase);

            _writer.VerifyXml(bag)
                .HasAttribute("access", "field.camelcase");
        }
        public void ShouldWriteKey()
        {
            var mapping = new BagMapping
            {
                Key = new KeyMapping()
            };

            writer.VerifyXml(mapping)
                .Element("key").Exists();
        }
        public void ShouldWriteRelationshipElement()
        {
            var mapping = new BagMapping();

            mapping.Relationship = new OneToManyMapping();

            writer.VerifyXml(mapping)
                .Element("one-to-many").Exists();
        }
 public override void ProcessBag(BagMapping bagMapping)
 {
     ProcessCollection(bagMapping);
 }
        public void ShouldWriteElement()
        {
            var mapping = new BagMapping();

            mapping.Element = new ElementMapping();

            writer.VerifyXml(mapping)
                .Element("element").Exists();
        }
 public void MutableShouldBeTrueByDefaultOnBagMapping()
 {
     var mapping = new BagMapping();
     mapping.Mutable.ShouldBeTrue();
 }
 public BagInstance(BagMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
 }