aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core.Tests/Internal
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2015-07-22 18:37:35 -0700
committerGravatar Jan Tattermusch <jtattermusch@google.com>2015-07-23 18:27:16 -0700
commit4113ba5420852aeadb8c5698b0af20fcf3da1bd0 (patch)
tree01578629ec24eef9c2cd89c0cf3535e3394d0d0d /src/csharp/Grpc.Core.Tests/Internal
parentf6410f54bc5426217f09a57dc9deaea2acf3d1d5 (diff)
implemented FromDateTime
Diffstat (limited to 'src/csharp/Grpc.Core.Tests/Internal')
-rw-r--r--src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs b/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs
index 69b94bb393..8469a9e3da 100644
--- a/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs
+++ b/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs
@@ -41,9 +41,22 @@ namespace Grpc.Core.Internal.Tests
public class TimespecTest
{
[Test]
- public void Now()
+ public void Now_IsInUtc()
+ {
+ Assert.AreEqual(DateTimeKind.Utc, Timespec.Now.ToDateTime().Kind);
+ }
+
+ [Test]
+ public void Now_AgreesWithUtcNow()
{
var timespec = Timespec.Now;
+ var utcNow = DateTime.UtcNow;
+
+ TimeSpan difference = utcNow - timespec.ToDateTime();
+
+ // This test is inherently a race - but the two timestamps
+ // should really be way less that a minute apart.
+ Assert.IsTrue(difference.TotalSeconds < 60);
}
[Test]