-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
fix nhibernate#3607
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Linq; | ||
using NHibernate.Cfg; | ||
using NHibernate.Cfg.MappingSchema; | ||
using NHibernate.Mapping.ByCode; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3607 | ||
{ | ||
/// <summary> | ||
/// By code mapping serialization failure since v5.4.1. Adapted from <see href="https://github.com/craigfowler/NHibernate.XmlConversionBug" />. | ||
/// </summary> | ||
[TestFixture] | ||
public class FixtureByCode : TestCaseMappingByCode | ||
{ | ||
protected override HbmMapping GetMappings() | ||
{ | ||
var mapper = new ModelMapper(); | ||
mapper.AddMappings([typeof(OrderMapping), typeof(LineItemMapping), typeof(LineItemDataMapping)]); | ||
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / SQLite
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / SQLite
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / SQLite
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / SQLite
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / PostgreSQL
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / PostgreSQL
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / PostgreSQL
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / PostgreSQL
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / SqlServer2008
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / SqlServer2008
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / SqlServer2008
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / SqlServer2008
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / MySQL
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / MySQL
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / MySQL
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / MySQL
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / Firebird
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / Firebird
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / Firebird
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / Firebird
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / Oracle
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / Oracle
Check failure on line 18 in src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs GitHub Actions / Oracle
|
||
return mapper.CompileMappingForAllExplicitlyAddedEntities(); | ||
} | ||
|
||
[Test] | ||
public void SerializeMappingToXml() | ||
{ | ||
var mapping = GetMappings(); | ||
string serialized = ""; | ||
Assert.That(() => serialized = mapping.AsString(), Throws.Nothing, "Mapping serialization failure"); | ||
var config = new Configuration(); | ||
Assert.That(() => config.AddXml(serialized), Throws.Nothing, "Configuration with serialized mapping has failed"); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace NHibernate.Test.NHSpecificTest.GH3607; | ||
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItem.cs GitHub Actions / SQLite
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItem.cs GitHub Actions / PostgreSQL
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItem.cs GitHub Actions / SqlServer2008
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItem.cs GitHub Actions / MySQL
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItem.cs GitHub Actions / Firebird
|
||
|
||
public class LineItem | ||
{ | ||
public virtual int Id { get; set; } | ||
|
||
public virtual Order ParentOrder { get; set; } | ||
|
||
public virtual string ItemName { get; set; } | ||
|
||
public virtual decimal Amount { get; set; } | ||
|
||
public virtual LineItemData Data { get; set; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace NHibernate.Test.NHSpecificTest.GH3607; | ||
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemData.cs GitHub Actions / SQLite
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemData.cs GitHub Actions / PostgreSQL
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemData.cs GitHub Actions / SqlServer2008
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemData.cs GitHub Actions / MySQL
Check failure on line 1 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemData.cs GitHub Actions / Firebird
|
||
|
||
public class LineItemData | ||
{ | ||
public virtual LineItem LineItem { get; set; } | ||
|
||
public virtual string Data { get; set; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using NHibernate.Mapping.ByCode.Conformist; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3607; | ||
Check failure on line 3 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemDataMapping.cs GitHub Actions / SQLite
Check failure on line 3 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemDataMapping.cs GitHub Actions / PostgreSQL
Check failure on line 3 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemDataMapping.cs GitHub Actions / SqlServer2008
Check failure on line 3 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemDataMapping.cs GitHub Actions / MySQL
Check failure on line 3 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemDataMapping.cs GitHub Actions / Firebird
|
||
|
||
public class LineItemDataMapping : ClassMapping<LineItemData> | ||
{ | ||
public LineItemDataMapping() | ||
{ | ||
OneToOne(x => x.LineItem, m => m.Constrained(true)); | ||
|
||
Property(x => x.Data); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using NHibernate.Mapping.ByCode; | ||
using NHibernate.Mapping.ByCode.Conformist; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3607; | ||
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemMapping.cs GitHub Actions / SQLite
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemMapping.cs GitHub Actions / PostgreSQL
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemMapping.cs GitHub Actions / SqlServer2008
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemMapping.cs GitHub Actions / MySQL
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/LineItemMapping.cs GitHub Actions / Firebird
|
||
|
||
public class LineItemMapping : ClassMapping<LineItem> | ||
{ | ||
public LineItemMapping() | ||
{ | ||
Id(x => x.Id, m => m.Generator(new IdentityGeneratorDef())); | ||
|
||
Property(x => x.ItemName); | ||
|
||
Property(x => x.Amount); | ||
|
||
ManyToOne(x => x.ParentOrder); | ||
|
||
ManyToOne(x => x.Data); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3607; | ||
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/Order.cs GitHub Actions / SQLite
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/Order.cs GitHub Actions / PostgreSQL
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/Order.cs GitHub Actions / SqlServer2008
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/Order.cs GitHub Actions / MySQL
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/Order.cs GitHub Actions / Firebird
|
||
|
||
public class Order | ||
{ | ||
public virtual int Id { get; set; } | ||
|
||
public virtual DateTime CreatedDate { get; set; } | ||
|
||
public virtual ISet<LineItem> Items { get; protected set; } = new HashSet<LineItem>(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using NHibernate.Mapping.ByCode; | ||
using NHibernate.Mapping.ByCode.Conformist; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3607; | ||
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/OrderMapping.cs GitHub Actions / SQLite
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/OrderMapping.cs GitHub Actions / PostgreSQL
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/OrderMapping.cs GitHub Actions / SqlServer2008
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/OrderMapping.cs GitHub Actions / MySQL
Check failure on line 4 in src/NHibernate.Test/NHSpecificTest/GH3607/OrderMapping.cs GitHub Actions / Firebird
|
||
|
||
public class OrderMapping : ClassMapping<Order> | ||
{ | ||
public OrderMapping() | ||
{ | ||
Table("`Order`"); | ||
Id(x => x.Id, m => m.Generator(new IdentityGeneratorDef())); | ||
|
||
Property(x => x.CreatedDate); | ||
|
||
Set(x => x.Items, m => | ||
{ | ||
m.Inverse(true); | ||
m.OptimisticLock(true); | ||
}, a => a.OneToMany()); | ||
} | ||
} |