From 6c57fdec78d89c0a68e4808a3a9a0187674d3bc6 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Sun, 29 Oct 2023 08:50:30 +0000 Subject: [PATCH 1/2] Fix test Fix test that fails in GMT (rather than BST). --- test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs b/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs index dbaa5ad899a..1e179efe96c 100644 --- a/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs +++ b/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs @@ -38,7 +38,7 @@ public void Should_return_zero_ttl_if_configured_to_expire_in_past() [Fact] public void Should_return_timespan_reflecting_time_until_expiry() { - DateTime today = DateTime.Today; + DateTime today = DateTime.UtcNow.Date; DateTime tomorrow = today.AddDays(1); AbsoluteTtl ttlStrategy = new AbsoluteTtl(tomorrow); From 8b467edaf6323ef4d550f1a03276374bba441c79 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Sun, 29 Oct 2023 08:56:53 +0000 Subject: [PATCH 2/2] Remove implicit DateTimeOffset conversions Use `DateTimeOffset` not `DateTime` to remove implicit conversions. --- test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs b/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs index 1e179efe96c..4b5c36cb310 100644 --- a/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs +++ b/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs @@ -6,7 +6,7 @@ public class AbsoluteTtlSpecs : IDisposable [Fact] public void Should_be_able_to_configure_for_near_future_time() { - Action configure = () => new AbsoluteTtl(DateTime.Today.AddDays(1)); + Action configure = () => new AbsoluteTtl(DateTimeOffset.UtcNow.Date.AddDays(1)); configure.Should().NotThrow(); } @@ -38,8 +38,8 @@ public void Should_return_zero_ttl_if_configured_to_expire_in_past() [Fact] public void Should_return_timespan_reflecting_time_until_expiry() { - DateTime today = DateTime.UtcNow.Date; - DateTime tomorrow = today.AddDays(1); + DateTimeOffset today = DateTimeOffset.UtcNow.Date; + DateTimeOffset tomorrow = today.AddDays(1); AbsoluteTtl ttlStrategy = new AbsoluteTtl(tomorrow);