|
From: <fab...@us...> - 2011-04-16 18:09:14
|
Revision: 5709
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5709&view=rev
Author: fabiomaulo
Date: 2011-04-16 18:09:08 +0000 (Sat, 16 Apr 2011)
Log Message:
-----------
Conformist joined-subclass registration fix
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassCustomizer.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/ConformistMappingRegistrationTests/JoinedSubclassMappingRegistration.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassCustomizer.cs 2011-04-16 18:04:59 UTC (rev 5708)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassCustomizer.cs 2011-04-16 18:09:08 UTC (rev 5709)
@@ -3,7 +3,7 @@
namespace NHibernate.Mapping.ByCode.Impl.CustomizersImpl
{
- public class JoinedSubclassCustomizer<TEntity> : PropertyContainerCustomizer<TEntity>, IJoinedSubclassMapper<TEntity> where TEntity : class
+ public class JoinedSubclassCustomizer<TEntity> : PropertyContainerCustomizer<TEntity>, IJoinedSubclassMapper<TEntity>, IConformistHoldersProvider where TEntity : class
{
private readonly IKeyMapper<TEntity> keyMapper;
@@ -125,5 +125,19 @@
}
#endregion
+
+ #region IConformistHoldersProvider Members
+
+ ICustomizersHolder IConformistHoldersProvider.CustomizersHolder
+ {
+ get { return CustomizersHolder; }
+ }
+
+ IModelExplicitDeclarationsHolder IConformistHoldersProvider.ExplicitDeclarationsHolder
+ {
+ get { return ExplicitDeclarationsHolder; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/ConformistMappingRegistrationTests/JoinedSubclassMappingRegistration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/ConformistMappingRegistrationTests/JoinedSubclassMappingRegistration.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/ConformistMappingRegistrationTests/JoinedSubclassMappingRegistration.cs 2011-04-16 18:09:08 UTC (rev 5709)
@@ -0,0 +1,74 @@
+using System.Linq;
+using NHibernate.Cfg.MappingSchema;
+using NUnit.Framework;
+using NHibernate.Mapping.ByCode;
+using NHibernate.Mapping.ByCode.Conformist;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExpliticMappingTests.ConformistMappingRegistrationTests
+{
+ public class JoinedSubclassMappingRegistration
+ {
+ public class MyClass
+ {
+ public int Id { get; set; }
+ public string Something { get; set; }
+ }
+ public class Inherited : MyClass
+ {
+ public string SomethingElse { get; set; }
+ }
+
+ private class MyClassMap : ClassMapping<MyClass>
+ {
+ public MyClassMap()
+ {
+ Id(x => x.Id, map =>
+ {
+ map.Column("MyClassId");
+ map.Generator(Generators.HighLow);
+ });
+ Property(x => x.Something, map => map.Length(150));
+ }
+ }
+ private class InheritedMap : JoinedSubclassMapping<Inherited>
+ {
+ public InheritedMap()
+ {
+ Property(x => x.SomethingElse, map => map.Length(15));
+ }
+ }
+
+ [Test]
+ public void WhenRegisterClassMappingThenMapTheClass()
+ {
+ var mapper = new ModelMapper();
+ mapper.AddMapping<MyClassMap>();
+ mapper.AddMapping<InheritedMap>();
+ var hbmMapping = mapper.CompileMappingFor(new[] { typeof(Inherited) });
+
+ ModelIsWellFormed(hbmMapping);
+ }
+
+ [Test]
+ public void WhenRegisterClassMappingThroughTypeThenMapTheClass()
+ {
+ var mapper = new ModelMapper();
+ mapper.AddMapping(typeof(MyClassMap));
+ mapper.AddMapping(typeof(InheritedMap));
+ var hbmMapping = mapper.CompileMappingFor(new[] { typeof(Inherited) });
+
+ ModelIsWellFormed(hbmMapping);
+ }
+
+ private void ModelIsWellFormed(HbmMapping hbmMapping)
+ {
+ var hbmClass = hbmMapping.JoinedSubclasses.Single();
+ hbmClass.Should().Not.Be.Null();
+ hbmClass.extends.Should().Contain("MyClass");
+ var hbmProperty = hbmClass.Properties.OfType<HbmProperty>().Single();
+ hbmProperty.name.Should().Be("SomethingElse");
+ hbmProperty.length.Should().Be("15");
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-16 18:04:59 UTC (rev 5708)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-16 18:09:08 UTC (rev 5709)
@@ -529,6 +529,7 @@
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassSequenceRegistrationTests.cs" />
+ <Compile Include="MappingByCode\ExpliticMappingTests\ConformistMappingRegistrationTests\JoinedSubclassMappingRegistration.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\ConformistMappingRegistrationTests\ModelMapperAddMappingByTypeTests.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\ConformistMappingRegistrationTests\SubclassMappingRegistration.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\IdBagMappingTest.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|