Skip to content

Commit

Permalink
Test: misc test for renewal info datetime precision parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Feb 14, 2025
1 parent ecfc033 commit 0b2907a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Certify.Tests/Certify.Core.Tests.Unit/Tests/MiscAcmeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Moq.Protected;
using Newtonsoft.Json;

namespace Certify.Core.Tests.Unit
{
Expand Down Expand Up @@ -218,5 +219,28 @@ public async Task TestAcmeDirectoryRateLimitWithRetry()
Assert.IsNotNull(dir);
Assert.IsNotNull(dir.NewOrder);
}

[TestMethod, Description("Test Renewal Info DateTime Precision")]
public async Task TestAcmeRenewalInfoDateTimePrecision()
{
var exampleJson = """
{
"suggestedWindow": {
"start": "2021-01-03T00:01:00.12345678999Z",
"end": "2021-01-07T00:01:00.12345678999Z"
},
"explanationURL": "https://example.com/docs/ari"
}
""";

var result = JsonConvert.DeserializeObject<AcmeRenewalInfo>(exampleJson);

Assert.IsTrue(result.SuggestedWindow.Start.Value.Millisecond == 123);

#if NET9_0_OR_GREATER
Assert.IsTrue(result.SuggestedWindow.Start.Value.Nanosecond == 800);
#endif
}
}
}

0 comments on commit 0b2907a

Please sign in to comment.