Skip to content

Commit 3dd120e

Browse files
committed
Issue test improvements
1 parent eccf62d commit 3dd120e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs

+20-6
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,20 @@ protected override DomainConfiguration BuildConfiguration()
6262
return config;
6363
}
6464

65+
protected override void CheckRequirements()
66+
{
67+
Require.ProviderIs(StorageProvider.SqlServer | StorageProvider.Oracle);
68+
}
69+
6570
[Test]
6671
public void DateTimeOffsetCase()
6772
{
68-
// NRE on within PackedFieldAccessor.GetValue<T>
6973
using (var session = Domain.OpenSession())
7074
using (var tx = session.OpenTransaction()) {
71-
var cargo3 = new Cargo(session);
72-
var cargoLoad = new CargoLoad(session, null);
75+
var expectedDateTimeOffset = new DateTimeOffset(2021, 9, 13, 0, 0, 1, new TimeSpan(5, 0, 0));
76+
var cargo = new Cargo(session) { DateTimeOffsetField = expectedDateTimeOffset};
77+
var loadNoCargo = new CargoLoad(session, null);
78+
var loadWithCargo = new CargoLoad(session, cargo);
7379

7480
var query = session.Query.All<CargoLoad>()
7581
.LeftJoin(session.Query.All<Cargo>(),
@@ -78,17 +84,22 @@ public void DateTimeOffsetCase()
7884
(cl, c) => new { CargoLoad = cl, Cargo = c })
7985
.Select(t => t.Cargo.DateTimeOffsetField)
8086
.ToArray();
87+
88+
Assert.That(query.Length, Is.EqualTo(2));
89+
Assert.That(query.Any(d => d == DateTimeOffset.MinValue), Is.True);
90+
Assert.That(query.Any(d => d == expectedDateTimeOffset), Is.True);
8191
}
8292
}
8393

8494
[Test]
8595
public void DateTimeCase()
8696
{
87-
//Works fine.
8897
using (var session = Domain.OpenSession())
8998
using (var tx = session.OpenTransaction()) {
90-
var cargo3 = new Cargo(session);
91-
var cargoLoad = new CargoLoad(session, null);
99+
var expectedDateTime = new DateTime(2021, 9, 13, 0, 0, 1);
100+
var cargo = new Cargo(session) { DateTimeField = expectedDateTime };
101+
var loadNoCargo = new CargoLoad(session, null);
102+
var loadWithCargo = new CargoLoad(session, cargo);
92103

93104
var query = session.Query.All<CargoLoad>()
94105
.LeftJoin(session.Query.All<Cargo>(),
@@ -97,6 +108,9 @@ public void DateTimeCase()
97108
(cl, c) => new { CargoLoad = cl, Cargo = c })
98109
.Select(t => t.Cargo.DateTimeField)
99110
.ToArray();
111+
Assert.That(query.Length, Is.EqualTo(2));
112+
Assert.That(query.Any(d => d == DateTime.MinValue), Is.True);
113+
Assert.That(query.Any(d => d == expectedDateTime), Is.True);
100114
}
101115
}
102116
}

0 commit comments

Comments
 (0)