Skip to content

Commit 1076ef1

Browse files
committed
Tests for FbZonedDateTime type
1 parent 8c2c955 commit 1076ef1

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* The contents of this file are subject to the Initial
3+
* Developer's Public License Version 1.0 (the "License");
4+
* you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
* https://github.com/FirebirdSQL/NETProvider/blob/master/license.txt.
7+
*
8+
* Software distributed under the License is distributed on
9+
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
10+
* express or implied. See the License for the specific
11+
* language governing rights and limitations under the License.
12+
*
13+
* All Rights Reserved.
14+
*/
15+
16+
//$Authors = Jiri Cincura ([email protected])
17+
18+
using System;
19+
using FirebirdSql.Data.Types;
20+
using NUnit.Framework;
21+
22+
namespace FirebirdSql.Data.FirebirdClient.Tests
23+
{
24+
public class FbZonedDateTimeTests
25+
{
26+
static readonly object[] SimpleEqualityTrueSource = new object[]
27+
{
28+
new object[] { new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), "UTC"), new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), "UTC") },
29+
new object[] { new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), "UTC"), new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), "utc") },
30+
};
31+
[TestCaseSource(nameof(SimpleEqualityTrueSource))]
32+
public void EqualityTrue(FbZonedDateTime expected, FbZonedDateTime actual)
33+
{
34+
Assert.AreEqual(expected, actual);
35+
}
36+
37+
static readonly object[] SimpleEqualityFalseSource = new object[]
38+
{
39+
new object[] { new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), "UTC"), new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 1, DateTimeKind.Utc), "UTC") },
40+
new object[] { new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), "foo"), new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), "bar") },
41+
};
42+
[TestCaseSource(nameof(SimpleEqualityFalseSource))]
43+
public void EqualityFalse(FbZonedDateTime expected, FbZonedDateTime actual)
44+
{
45+
Assert.AreNotEqual(expected, actual);
46+
}
47+
48+
public void DateTimeShouldBeUtc()
49+
{
50+
Assert.Throws<ArgumentException>(() =>
51+
{
52+
new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Local), "foo");
53+
});
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)