From a7db28fe4da18da9acdb3990d8449729a044f3a1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch <jtattermusch@google.com> Date: Wed, 18 May 2016 12:26:16 -0700 Subject: [PATCH] dont call into C core to get Timespec.InfPast and Timespec.InfFuture --- .../Grpc.Core.Tests/Internal/TimespecTest.cs | 8 +++---- src/csharp/Grpc.Core/Internal/Timespec.cs | 23 +++++++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs b/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs index 74f7f2497a..1f6110c120 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs @@ -61,15 +61,15 @@ namespace Grpc.Core.Internal.Tests } [Test] - public void InfFuture() + public void InfFutureMatchesNativeValue() { - var timespec = Timespec.InfFuture; + Assert.AreEqual(Timespec.NativeInfFuture, Timespec.InfFuture); } [Test] - public void InfPast() + public void InfPastMatchesNativeValue() { - var timespec = Timespec.InfPast; + Assert.AreEqual(Timespec.NativeInfPast, Timespec.InfPast); } [Test] diff --git a/src/csharp/Grpc.Core/Internal/Timespec.cs b/src/csharp/Grpc.Core/Internal/Timespec.cs index 56172a5dda..6420a4f3ae 100644 --- a/src/csharp/Grpc.Core/Internal/Timespec.cs +++ b/src/csharp/Grpc.Core/Internal/Timespec.cs @@ -71,7 +71,7 @@ namespace Grpc.Core.Internal { get { - return Native.gprsharp_inf_future(GPRClockType.Realtime); + return new Timespec(long.MaxValue, 0, GPRClockType.Realtime); } } @@ -82,7 +82,7 @@ namespace Grpc.Core.Internal { get { - return Native.gprsharp_inf_past(GPRClockType.Realtime); + return new Timespec(long.MinValue, 0, GPRClockType.Realtime); } } @@ -231,6 +231,7 @@ namespace Grpc.Core.Internal } } + // for tests only internal static int NativeSize { get @@ -238,5 +239,23 @@ namespace Grpc.Core.Internal return Native.gprsharp_sizeof_timespec(); } } + + // for tests only + internal static Timespec NativeInfFuture + { + get + { + return Native.gprsharp_inf_future(GPRClockType.Realtime); + } + } + + // for tests only + public static Timespec NativeInfPast + { + get + { + return Native.gprsharp_inf_past(GPRClockType.Realtime); + } + } } } -- GitLab