Skip to content

Commit 9ab7970

Browse files
committed
Test showing the same situation but with classes that passes
1 parent 2f1b5fe commit 9ab7970

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

src/FluentNHibernate.Testing/PersistenceModelTests/SubclassPersistenceModelTests.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,18 @@ public void ShouldHandleEverettsWeirdMapping()
204204
colorSource.Subclasses.Count().ShouldEqual(2);
205205
}
206206

207+
[Test]
208+
public void CanBuildConfigurationForTablePerType()
209+
{
210+
var model = new PersistenceModel();
211+
model.Add(new TablePerType.TPT_TopMap());
212+
model.Add(new TablePerType.TPT_TopSubclassMap());
213+
model.Add(new TablePerType.TPT_MiddleMap());
214+
model.Add(new TablePerType.TPT_MiddleSubclassMap());
215+
216+
model.BuildMappings();
217+
}
218+
207219
[Test]
208220
public void CanBuildConfigurationForTablePerTypeWithInterfaces()
209221
{
@@ -377,6 +389,62 @@ public class I_BottomMostMap : SubclassMap<I_BottomMost>
377389
{ }
378390
}
379391

392+
namespace TablePerType
393+
{
394+
public class TPT_Top
395+
{
396+
public virtual int Id { get; protected set; }
397+
}
398+
public class TPT_Middle
399+
: TPT_Top
400+
{
401+
public virtual string MiddleProperty { get; set; }
402+
}
403+
public class TPT_TopSubclass
404+
: TPT_Top
405+
{
406+
}
407+
public class TPT_MiddleSubclass
408+
: TPT_Middle
409+
{
410+
public virtual string OwnProperty { get; set; }
411+
}
412+
413+
public class TPT_TopMap
414+
: ClassMap<TPT_Top>
415+
{
416+
public TPT_TopMap()
417+
{
418+
Id(x => x.Id);
419+
}
420+
}
421+
public class TPT_TopSubclassMap
422+
: SubclassMap<TPT_TopSubclass>
423+
{
424+
public TPT_TopSubclassMap()
425+
{
426+
KeyColumn("Id");
427+
}
428+
}
429+
public class TPT_MiddleMap
430+
: SubclassMap<TPT_Middle>
431+
{
432+
public TPT_MiddleMap()
433+
{
434+
KeyColumn("Id");
435+
Map(x => x.MiddleProperty);
436+
}
437+
}
438+
public class TPT_MiddleSubclassMap
439+
: SubclassMap<TPT_MiddleSubclass>
440+
{
441+
public TPT_MiddleSubclassMap()
442+
{
443+
KeyColumn("Id");
444+
Map(x => x.OwnProperty);
445+
}
446+
}
447+
}
380448

381449
namespace TablePerTypeWithInterfaces
382450
{
@@ -437,6 +505,7 @@ public TPTWI_MiddleSubclassMap()
437505
}
438506
}
439507
}
508+
440509
namespace Branching
441510
{
442511
public class B_Top

0 commit comments

Comments
 (0)