コード例 #1
0
ファイル: IdBagMapper.cs プロジェクト: hazzik/nhibernate-core
 public IdBagMapper(System.Type ownerType, System.Type elementType, IAccessorPropertyMapper accessorMapper, HbmIdbag mapping)
 {
     if (ownerType == null)
     {
         throw new ArgumentNullException("ownerType");
     }
     if (elementType == null)
     {
         throw new ArgumentNullException("elementType");
     }
     if (mapping == null)
     {
         throw new ArgumentNullException("mapping");
     }
     OwnerType    = ownerType;
     ElementType  = elementType;
     this.mapping = mapping;
     if (mapping.Key == null)
     {
         mapping.key = new HbmKey();
     }
     keyMapper = new KeyMapper(ownerType, mapping.Key);
     if (mapping.collectionid == null)
     {
         mapping.collectionid = new HbmCollectionId();
     }
     idMapper             = new CollectionIdMapper(mapping.collectionid);
     entityPropertyMapper = accessorMapper;
 }
コード例 #2
0
		public void WhenForceTypeThenNotChangeType()
		{
			var hbmId = new HbmCollectionId();
			var collectionIdMapper = new CollectionIdMapper(hbmId);
			collectionIdMapper.Type((IIdentifierType) NHibernateUtil.Int64);
			collectionIdMapper.Generator(Generators.HighLow);

			Assert.That(hbmId.generator.@class, Is.EqualTo("hilo"));
			Assert.That(hbmId.type, Is.EqualTo("Int64"));
		}
コード例 #3
0
		public void CantSetGeneratorAssigned()
		{
			var hbmId = new HbmCollectionId();
			var collectionIdMapper = new CollectionIdMapper(hbmId);
			Assert.That(() => collectionIdMapper.Generator(Generators.Assigned), Throws.TypeOf<NotSupportedException>());
		}
コード例 #4
0
		public void CanSetLength()
		{
			var hbmId = new HbmCollectionId();
			var mapper = new CollectionIdMapper(hbmId);
			mapper.Length(10);
			Assert.That(hbmId.length, Is.EqualTo("10"));
		}
コード例 #5
0
		public void CanSetColumnName()
		{
			var hbmId = new HbmCollectionId();
			var mapper = new CollectionIdMapper(hbmId);
			mapper.Column("MyName");
			Assert.That(hbmId.Columns.Single().name, Is.EqualTo("MyName"));
		}
コード例 #6
0
		public void CantSetGeneratorAssigned()
		{
			var hbmId = new HbmCollectionId();
			var collectionIdMapper = new CollectionIdMapper(hbmId);
			collectionIdMapper.Executing(x=> x.Generator(Generators.Assigned)).Throws<NotSupportedException>();
		}
コード例 #7
0
		public void CanSetLength()
		{
			var hbmId = new HbmCollectionId();
			var mapper = new CollectionIdMapper(hbmId);
			mapper.Length(10);
			hbmId.length.Should().Be("10");
		}
コード例 #8
0
		public void CanSetColumnName()
		{
			var hbmId = new HbmCollectionId();
			var mapper = new CollectionIdMapper(hbmId);
			mapper.Column("MyName");
			hbmId.Columns.Single().name.Should().Be("MyName");
		}