|
| 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 | +} |
0 commit comments