Skip to content

Commit 13bdb94

Browse files
committed
Merge pull request #247 from RogerKratz/NH3590
Failing test for NH3590
2 parents 62efc2b + 246bff5 commit 13bdb94

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace NHibernate.Test.NHSpecificTest.NH3590
5+
{
6+
public class Entity
7+
{
8+
public Entity()
9+
{
10+
Dates = new HashSet<DateTime>();
11+
}
12+
13+
public virtual Guid Id { get; protected set; }
14+
public virtual ISet<DateTime> Dates { get; protected set; }
15+
16+
public override bool Equals(object obj)
17+
{
18+
var that = obj as Entity;
19+
return that != null && that.Id == Id;
20+
}
21+
22+
public override int GetHashCode()
23+
{
24+
return Id.GetHashCode();
25+
}
26+
}
27+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System;
2+
using NUnit.Framework;
3+
using SharpTestsEx;
4+
5+
namespace NHibernate.Test.NHSpecificTest.NH3590
6+
{
7+
[TestFixture]
8+
public class Fixture : BugTestCase
9+
{
10+
private Entity entity;
11+
12+
protected override void OnSetUp()
13+
{
14+
entity = new Entity();
15+
using (var s = OpenSession())
16+
{
17+
using (var tx = s.BeginTransaction())
18+
{
19+
s.Save(entity);
20+
tx.Commit();
21+
}
22+
}
23+
}
24+
25+
[Test, KnownBug("3590")]
26+
public void ShouldUpdate()
27+
{
28+
entity.Dates.Add(DateTime.Now);
29+
using (var s = OpenSession())
30+
{
31+
using (var tx = s.BeginTransaction())
32+
{
33+
s.Update(entity);
34+
tx.Commit();
35+
}
36+
}
37+
38+
using (var s = OpenSession())
39+
{
40+
using (s.BeginTransaction())
41+
{
42+
s.Get<Entity>(entity.Id).Dates.Count
43+
.Should().Be.EqualTo(1);
44+
}
45+
}
46+
}
47+
48+
[Test, KnownBug("3590")]
49+
public void ShouldMerge()
50+
{
51+
entity.Dates.Add(DateTime.Now);
52+
using (var s = OpenSession())
53+
{
54+
using (var tx = s.BeginTransaction())
55+
{
56+
s.Merge(entity);
57+
tx.Commit();
58+
}
59+
}
60+
61+
using (var s = OpenSession())
62+
{
63+
using (s.BeginTransaction())
64+
{
65+
s.Get<Entity>(entity.Id).Dates.Count
66+
.Should().Be.EqualTo(1);
67+
}
68+
}
69+
}
70+
71+
protected override void OnTearDown()
72+
{
73+
using (var s = OpenSession())
74+
{
75+
using (var tx = s.BeginTransaction())
76+
{
77+
s.Delete(s.Get<Entity>(entity.Id));
78+
tx.Commit();
79+
}
80+
}
81+
}
82+
}
83+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
3+
namespace="NHibernate.Test.NHSpecificTest.NH3590"
4+
assembly="NHibernate.Test">
5+
6+
<class name="Entity">
7+
<id name="Id"
8+
type="guid">
9+
<generator class="guid.comb" />
10+
</id>
11+
<set name="Dates">
12+
<key column="entity_id" />
13+
<element column="Date" type="DateTime"/>
14+
</set>
15+
</class>
16+
</hibernate-mapping>

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,8 @@
11551155
<Compile Include="NHSpecificTest\ProxyValidator\ShouldBeProxiableTests.cs" />
11561156
<Compile Include="NHSpecificTest\NH2898\ItemWithLazyProperty.cs" />
11571157
<Compile Include="NHSpecificTest\NH2898\Fixture.cs" />
1158+
<Compile Include="NHSpecificTest\NH3590\Entity.cs" />
1159+
<Compile Include="NHSpecificTest\NH3590\Fixture.cs" />
11581160
<Compile Include="NHSpecificTest\SqlConverterAndMultiQuery\Fixture.cs" />
11591161
<Compile Include="NHSpecificTest\SqlConverterAndMultiQuery\Model.cs" />
11601162
<Compile Include="NHSpecificTest\SqlConverterAndMultiQuery\SqlConverter.cs" />
@@ -3009,6 +3011,7 @@
30093011
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
30103012
</ItemGroup>
30113013
<ItemGroup>
3014+
<EmbeddedResource Include="NHSpecificTest\NH3590\Mappings.hbm.xml" />
30123015
<EmbeddedResource Include="NHSpecificTest\NH3377\Mappings.hbm.xml" />
30133016
<EmbeddedResource Include="NHSpecificTest\NH2865\Mappings.hbm.xml" />
30143017
<EmbeddedResource Include="NHSpecificTest\NH2756\Mappings.hbm.xml" />

0 commit comments

Comments
 (0)