diff --git a/Src/NHibernate.Envers.Tests/NHibernate.Envers.Tests.csproj b/Src/NHibernate.Envers.Tests/NHibernate.Envers.Tests.csproj index 1d979df8..320f4ecd 100644 --- a/Src/NHibernate.Envers.Tests/NHibernate.Envers.Tests.csproj +++ b/Src/NHibernate.Envers.Tests/NHibernate.Envers.Tests.csproj @@ -1,4 +1,4 @@ - + netCoreApp2.0;net461 diff --git a/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/BackReferenceEntity.cs b/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/BackReferenceEntity.cs new file mode 100644 index 00000000..ef16ea31 --- /dev/null +++ b/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/BackReferenceEntity.cs @@ -0,0 +1,24 @@ +using NHibernate.Envers.Configuration.Attributes; + +namespace NHibernate.Envers.Tests.NetSpecific.Integration.ManyToMany.BackReference +{ + [Audited] + public class BackReferenceEntity + { + public virtual long Id { get; set; } + + public virtual OwningEntity Owning { get; set; } + + public override bool Equals(object obj) + { + if (!(obj is BackReferenceEntity other)) + return false; + return Id == other.Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/BackReferenceTest.cs b/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/BackReferenceTest.cs new file mode 100644 index 00000000..9c908c8f --- /dev/null +++ b/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/BackReferenceTest.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Envers.Tests.NetSpecific.Integration.ManyToMany.BackReference +{ + public class BackReferenceTest : TestBase + { + public BackReferenceTest(AuditStrategyForTest strategyType) : base(strategyType) + { + } + + protected override IEnumerable Mappings => new[] {"NetSpecific.Integration.ManyToMany.BackReference.Mapping.hbm.xml"}; + + protected override void Initialize() + { + } + + [Test] + public void VerifySave() + { + using (var tx = Session.BeginTransaction()) + { + var item = new BackReferenceEntity(); + + Session.Save(item); + + var entity = new OwningEntity + { + Items = { item } + }; + + Session.Save(entity); + + tx.Commit(); + } + } + } +} \ No newline at end of file diff --git a/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/Mapping.hbm.xml b/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/Mapping.hbm.xml new file mode 100644 index 00000000..91818e30 --- /dev/null +++ b/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/Mapping.hbm.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/OwningEntity.cs b/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/OwningEntity.cs new file mode 100644 index 00000000..22961432 --- /dev/null +++ b/Src/NHibernate.Envers.Tests/NetSpecific/Integration/ManyToMany/BackReference/OwningEntity.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using NHibernate.Envers.Configuration.Attributes; + +namespace NHibernate.Envers.Tests.NetSpecific.Integration.ManyToMany.BackReference +{ + [Audited] + public class OwningEntity + { + public virtual long Id { get; set; } + + public virtual IList Items { get; protected set; } = new List(); + + public override bool Equals(object obj) + { + if (!(obj is OwningEntity other)) + return false; + return Id == other.Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file