From 398ed109b142dff4b4e4cb782487d0ceb21d1019 Mon Sep 17 00:00:00 2001 From: Daniel Weber Date: Fri, 6 Sep 2024 16:15:32 +0200 Subject: [PATCH] Add tests for TimeSpan deserialization. --- ...tionTests.TimeSpan_from_float.verified.txt | 3 +++ ...rationTests.TimeSpan_from_int.verified.txt | 3 +++ .../IntegrationTests.cs | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 test/Providers.GremlinServer.Tests/IntegrationTests.TimeSpan_from_float.verified.txt create mode 100644 test/Providers.GremlinServer.Tests/IntegrationTests.TimeSpan_from_int.verified.txt diff --git a/test/Providers.GremlinServer.Tests/IntegrationTests.TimeSpan_from_float.verified.txt b/test/Providers.GremlinServer.Tests/IntegrationTests.TimeSpan_from_float.verified.txt new file mode 100644 index 000000000..8f8d607ca --- /dev/null +++ b/test/Providers.GremlinServer.Tests/IntegrationTests.TimeSpan_from_float.verified.txt @@ -0,0 +1,3 @@ +[ + 00:00:00.0423000 +] \ No newline at end of file diff --git a/test/Providers.GremlinServer.Tests/IntegrationTests.TimeSpan_from_int.verified.txt b/test/Providers.GremlinServer.Tests/IntegrationTests.TimeSpan_from_int.verified.txt new file mode 100644 index 000000000..1070de014 --- /dev/null +++ b/test/Providers.GremlinServer.Tests/IntegrationTests.TimeSpan_from_int.verified.txt @@ -0,0 +1,3 @@ +[ + 00:00:00.0420000 +] \ No newline at end of file diff --git a/test/Providers.GremlinServer.Tests/IntegrationTests.cs b/test/Providers.GremlinServer.Tests/IntegrationTests.cs index 83ab3ceb6..21bfba70d 100644 --- a/test/Providers.GremlinServer.Tests/IntegrationTests.cs +++ b/test/Providers.GremlinServer.Tests/IntegrationTests.cs @@ -1,4 +1,5 @@ using ExRam.Gremlinq.Core; +using ExRam.Gremlinq.Core.Execution; using ExRam.Gremlinq.Tests.Fixtures; using ExRam.Gremlinq.Tests.Infrastructure; @@ -195,6 +196,27 @@ public Task DateTimeOffset_from_string_3() => _g .Cast() .Verify(); + [Fact] + public Task TimeSpan_from_int() => _g + .Inject(42) + .Cast() + .Verify(); + + [Fact] + public Task TimeSpan_from_float() => _g + .Inject(42.3) + .Cast() + .Verify(); + + [Fact] + public Task TimeSpan_from_malformed_string() => _g + .Inject("abc") + .Cast() + .Awaiting(_ => _ + .FirstOrDefaultAsync()) + .Should() + .ThrowAsync(); + [Fact] public async Task Deserialization_of_typed_results_is_only_called_once() {