Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Deryck Brown
committed
Jun 9, 2022
1 parent
054b87a
commit 5c712c4
Showing
6 changed files
with
80 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/HotChocolate/Core/test/Types.Tests/Types/Scalars/Iso8601DurationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace HotChocolate.Types; | ||
|
||
public class Iso8601DurationTests | ||
{ | ||
public static IEnumerable<object[]> TryParseTests => new List<object[]> | ||
{ | ||
new object[] { "-P1D", TimeSpan.FromDays(-1) }, | ||
new object[] { "PT0.0000001S", TimeSpan.FromMilliseconds(1) / 1000 / 10 }, | ||
new object[] { "-PT0.0000001S", TimeSpan.FromMilliseconds(-1) / 1000 / 10 }, | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(TryParseTests))] | ||
public void TryParse(string duration, TimeSpan? expected) | ||
{ | ||
// act | ||
var result = Iso8601Duration.TryParse(duration, out var actual); | ||
|
||
// assert | ||
Assert.True(result); | ||
Assert.Equal(expected, actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/StrawberryShake/Client/test/Core.Tests/Serialization/Iso8601DurationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace StrawberryShake.Serialization | ||
{ | ||
public class Iso8601DurationTests | ||
{ | ||
public static IEnumerable<object[]> TryParseTests => new List<object[]> | ||
{ | ||
new object[] { "-P1D", TimeSpan.FromDays(-1) }, | ||
new object[] { "PT0.0000001S", TimeSpan.FromMilliseconds(1) / 1000 / 10 }, | ||
new object[] { "-PT0.0000001S", TimeSpan.FromMilliseconds(-1) / 1000 / 10 } | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(TryParseTests))] | ||
public void TryParse(string duration, TimeSpan? expected) | ||
{ | ||
// act | ||
var result = Iso8601Duration.TryParse(duration, out var actual); | ||
|
||
// assert | ||
Assert.True(result); | ||
Assert.Equal(expected, actual); | ||
} | ||
} | ||
} |