Skip to content

Commit 2202bb8

Browse files
committed
Add test for nhibernate#3707
1 parent e851310 commit 2202bb8

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
3+
namespace NHibernate.Test.NHSpecificTest.GH3707
4+
{
5+
partial class Entity
6+
{
7+
public virtual Guid Id { get; set; }
8+
public virtual string Name { get; set; }
9+
10+
public virtual DateTime DateTime1 { get; set; }
11+
public virtual DateTime DateTime2 { get; set; }
12+
}
13+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Linq;
3+
using NHibernate.Dialect;
4+
using NUnit.Framework;
5+
6+
namespace NHibernate.Test.NHSpecificTest.GH3707
7+
{
8+
[TestFixture]
9+
public class Fixture : BugTestCase
10+
{
11+
protected override bool AppliesTo(Dialect.Dialect dialect)
12+
{
13+
return dialect is Oracle8iDialect;
14+
}
15+
16+
protected override void OnSetUp()
17+
{
18+
using var session = OpenSession();
19+
using var transaction = session.BeginTransaction();
20+
21+
session.Save(new Entity
22+
{
23+
Name = "Bob",
24+
DateTime1 = new DateTime(2015, 10, 21),
25+
DateTime2 = new DateTime(2015, 10, 21),
26+
});
27+
28+
session.Save(new Entity
29+
{
30+
Name = "Alice",
31+
DateTime1 = new DateTime(2015, 10, 21),
32+
DateTime2 = new DateTime(2015, 10, 21),
33+
});
34+
35+
transaction.Commit();
36+
}
37+
38+
protected override void OnTearDown()
39+
{
40+
using var session = OpenSession();
41+
using var transaction = session.BeginTransaction();
42+
43+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
44+
45+
transaction.Commit();
46+
}
47+
48+
[Test]
49+
public void ShouldStoreSameValues()
50+
{
51+
using (var session = OpenSession())
52+
{
53+
using var transaction = session.BeginTransaction();
54+
55+
session.CreateQuery("update Entity set DateTime1 = current_timestamp, DateTime2 = current_timestamp where name = 'Bob'")
56+
.ExecuteUpdate();
57+
58+
session.CreateQuery("update Entity set DateTime1 = localtimestamp, DateTime2 = localtimestamp where name = 'Alice'")
59+
.ExecuteUpdate();
60+
61+
transaction.Commit();
62+
}
63+
64+
using (var session = OpenSession())
65+
{
66+
var bob = session
67+
.Query<Entity>()
68+
.Single(e => e.Name == "Bob");
69+
70+
Assert.That(bob.DateTime1, Is.EqualTo(bob.DateTime2));
71+
Assert.That(bob.DateTime1.Kind, Is.EqualTo(DateTimeKind.Unspecified));
72+
Assert.That(bob.DateTime2.Kind, Is.EqualTo(DateTimeKind.Unspecified));
73+
Assert.That(bob.DateTime1, Is.EqualTo(DateTime.Now).Within(TimeSpan.FromSeconds(5)));
74+
}
75+
}
76+
}
77+
}
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" assembly="NHibernate.Test"
3+
namespace="NHibernate.Test.NHSpecificTest.GH3707">
4+
5+
<class name="Entity">
6+
<id name="Id" generator="guid.comb"/>
7+
<property name="Name"/>
8+
<property name="DateTime1">
9+
<column name="DT1" sql-type="TIMESTAMP"/>
10+
</property>
11+
<property name="DateTime2">
12+
<column name="DT2" sql-type="TIMESTAMP WITH TIME ZONE"/>
13+
</property>
14+
</class>
15+
16+
</hibernate-mapping>

0 commit comments

Comments
 (0)