Skip to content

Commit 3670c10

Browse files
committed
Tests for DateTime and DateTimeOffsets values with nanoseconds
1 parent 2c399df commit 3670c10

2 files changed

Lines changed: 40 additions & 6 deletions

File tree

Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTime/PartsExtractionTest.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright (C) 2016 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2016-2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alex Groznov
55
// Created: 2016.08.01
66

7+
using System;
78
using NUnit.Framework;
89
using Xtensive.Orm.Tests.Linq.DateTimeAndDateTimeOffset.Model;
910

@@ -118,6 +119,22 @@ public void ExtractDateTest()
118119
});
119120
}
120121

122+
[Test]
123+
[TestCase("2018-10-30 12:15:32.123")]
124+
[TestCase("2018-10-30 12:15:32.1234")]
125+
[TestCase("2018-10-30 12:15:32.12345")]
126+
[TestCase("2018-10-30 12:15:32.123456")]
127+
[TestCase("2018-10-30 12:15:32.1234567")]
128+
public void ExtractDateFromMicrosecondsTest(string testValueString)
129+
{
130+
Require.ProviderIs(StorageProvider.SqlServer);
131+
ExecuteInsideSession(() => {
132+
var testDateTimeOffset = DateTimeOffset.Parse(testValueString);
133+
_ = new SingleDateTimeOffsetEntity() { MillisecondDateTimeOffset = testDateTimeOffset };
134+
RunTest<SingleDateTimeOffsetEntity>(c => c.MillisecondDateTimeOffset.Date == testDateTimeOffset.Date);
135+
});
136+
}
137+
121138
[Test]
122139
public void ExtractTimeOfDayTest()
123140
{

Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffset/PartsExtractionTest.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright (C) 2016 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2016-2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alex Groznov
55
// Created: 2016.08.01
66

7+
using System;
78
using NUnit.Framework;
89
using Xtensive.Orm.Tests.Linq.DateTimeAndDateTimeOffset.Model;
910

@@ -148,6 +149,22 @@ public void ExtractDateTest()
148149
});
149150
}
150151

152+
[Test]
153+
[TestCase("2018-10-30 12:15:32.123 +05:10")]
154+
[TestCase("2018-10-30 12:15:32.1234 +05:10")]
155+
[TestCase("2018-10-30 12:15:32.12345 +05:10")]
156+
[TestCase("2018-10-30 12:15:32.123456 +05:10")]
157+
[TestCase("2018-10-30 12:15:32.1234567 +05:10")]
158+
public void ExtractDateFromMicrosecondsTest(string testValueString)
159+
{
160+
Require.ProviderIs(StorageProvider.SqlServer);
161+
ExecuteInsideSession(() => {
162+
var testDateTimeOffset = DateTimeOffset.Parse(testValueString);
163+
_ = new SingleDateTimeOffsetEntity() { MillisecondDateTimeOffset = testDateTimeOffset };
164+
RunTest<SingleDateTimeOffsetEntity>(c => c.MillisecondDateTimeOffset.Date == testDateTimeOffset.Date);
165+
});
166+
}
167+
151168
[Test]
152169
public void ExtractTimeOfDayTest()
153170
{

0 commit comments

Comments
 (0)