|
From: <fab...@us...> - 2011-04-02 19:07:01
|
Revision: 5577
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5577&view=rev
Author: fabiomaulo
Date: 2011-04-02 19:06:54 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
subclass-join classes registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 18:58:51 UTC (rev 5576)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 19:06:54 UTC (rev 5577)
@@ -172,7 +172,7 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
}
- if(IsMappedFor(tablePerClassEntities, type))
+ if (IsMappedFor(tablePerClassEntities, type) || tablePerClassHierarchyJoinEntities.Contains(type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs 2011-04-02 19:06:54 UTC (rev 5577)
@@ -0,0 +1,78 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class SubclassJoinMappingStrategyTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+ private class Inherited2 : Inherited1
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.True();
+ inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredAsDeepSubclassJoinThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited2));
+
+ inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.True();
+ inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenCantRegisterAsJoinedSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenCantRegisterAsSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenCantRegisterAsUnionSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+ }
+}
\ 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-02 18:58:51 UTC (rev 5576)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 19:06:54 UTC (rev 5577)
@@ -510,6 +510,7 @@
<Compile Include="MappingByCode\ColumnsNamingConvetions.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|