Skip to content

Commit 02ba3db

Browse files
committed
chore: migrates to newer TimeOnly and DateOnly APIs
Signed-off-by: Vincent Biret <[email protected]>
1 parent b888063 commit 02ba3db

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

test/Microsoft.OpenAPI.OData.Reader.Tests/Vocabulary/Capabilities/CustomParameterTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System;
67
using System.IO;
78
using System.Xml;
89
using Microsoft.OData.Edm;
@@ -29,7 +30,7 @@ public void InitializeCustomParameterWithRecordSuccess()
2930
new EdmPropertyConstructor("ExampleValues",
3031
new EdmCollectionExpression(
3132
new EdmRecordExpression(new EdmPropertyConstructor("Value", new EdmStringConstant("html"))),
32-
new EdmRecordExpression(new EdmPropertyConstructor("Value", new EdmTimeOfDayConstant(new TimeOfDay(3, 4, 5, 6)))))));
33+
new EdmRecordExpression(new EdmPropertyConstructor("Value", new EdmTimeOfDayConstant(new TimeOnly(3, 4, 5, 6)))))));
3334

3435
// Act
3536
CustomParameter parameter = new CustomParameter();
@@ -102,7 +103,7 @@ private static void VerifyCustomParameter(CustomParameter parameter)
102103
value = parameter.ExampleValues[1];
103104
Assert.Null(value.Description);
104105
Assert.NotNull(value.Value);
105-
Assert.Equal(new TimeOfDay(3, 4, 5, 6), value.Value.Value);
106+
Assert.Equal(new TimeOnly(3, 4, 5, 6).ToString("HH:mm:ss.fffffff"), value.Value.Value.ToString());
106107
}
107108

108109
private IEdmModel GetEdmModel(string annotation)

test/Microsoft.OpenAPI.OData.Reader.Tests/Vocabulary/Capabilities/RevisionRecordTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public void InitializeWithDeprecatedRevisionsTypeRecordSuccess()
4343
{
4444
// Arrange
4545
IEdmRecordExpression record = new EdmRecordExpression(
46-
new EdmPropertyConstructor("Date", new EdmDateConstant(new Date(2021, 8, 24))),
47-
new EdmPropertyConstructor("RemovalDate", new EdmDateConstant(new Date(2021, 10, 24))),
46+
new EdmPropertyConstructor("Date", new EdmDateConstant(new DateOnly(2021, 8, 24))),
47+
new EdmPropertyConstructor("RemovalDate", new EdmDateConstant(new DateOnly(2021, 10, 24))),
4848
new EdmPropertyConstructor("Kind", new EdmEnumMemberExpression(deprecatedValue)),
4949
new EdmPropertyConstructor("Description", new EdmStringConstant("The identityProvider API is deprecated and will stop returning data on March 2023. Please use the new identityProviderBase API.")),
5050
new EdmPropertyConstructor("Version", new EdmStringConstant("2021-05/test")));
@@ -71,15 +71,15 @@ public void WorksForAllKinds()
7171
{
7272
// Arrange
7373
IEdmRecordExpression record1 = new EdmRecordExpression(
74-
new EdmPropertyConstructor("Date", new EdmDateConstant(new Date(2021, 8, 24))),
75-
new EdmPropertyConstructor("RemovalDate", new EdmDateConstant(new Date(2021, 10, 24))),
74+
new EdmPropertyConstructor("Date", new EdmDateConstant(new DateOnly(2021, 8, 24))),
75+
new EdmPropertyConstructor("RemovalDate", new EdmDateConstant(new DateOnly(2021, 10, 24))),
7676
new EdmPropertyConstructor("Kind", new EdmEnumMemberExpression(addedValue)),
7777
new EdmPropertyConstructor("Description", new EdmStringConstant("The identityProvider API is deprecated and will stop returning data on March 2023. Please use the new identityProviderBase API.")),
7878
new EdmPropertyConstructor("Version", new EdmStringConstant("2021-05/test")));
7979

8080
IEdmRecordExpression record2 = new EdmRecordExpression(
81-
new EdmPropertyConstructor("Date", new EdmDateConstant(new Date(2023, 3, 2))),
82-
new EdmPropertyConstructor("RemovalDate", new EdmDateConstant(new Date(2023, 05, 30))),
81+
new EdmPropertyConstructor("Date", new EdmDateConstant(new DateOnly(2023, 3, 2))),
82+
new EdmPropertyConstructor("RemovalDate", new EdmDateConstant(new DateOnly(2023, 05, 30))),
8383
new EdmPropertyConstructor("Kind", new EdmEnumMemberExpression(deprecatedValue)),
8484
new EdmPropertyConstructor("Description", new EdmStringConstant("Private preview test.")),
8585
new EdmPropertyConstructor("Version", new EdmStringConstant("2023-03/test")));

test/Microsoft.OpenAPI.OData.Reader.Tests/Vocabulary/Core/PrimitiveExampleValueTests.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public void InitializeWithPrimitiveValueRecordSuccess()
6969
new object[] { @"Int=""42""", (long)42 },
7070
new object[] { @"Bool=""true""", true },
7171
new object[] { @"Bool=""false""", false },
72-
new object[] { @"TimeOfDay=""15:38:25.1090000""", new TimeOfDay(15, 38, 25, 109) },
73-
new object[] { @"Date=""2014-10-13""", new Date(2014, 10, 13) },
72+
new object[] { @"TimeOfDay=""15:38:25.1090000""", new TimeOnly(15, 38, 25, 109) },
73+
new object[] { @"Date=""2014-10-13""", new DateOnly(2014, 10, 13) },
7474
new object[] { @"Duration=""PT0S""", new TimeSpan() },
7575
// new object[] { @"Binary=""AQ==""", new byte[] { 1 }, }, has problem in ODL?
7676
new object[] { @"Float=""3.14""", 3.14 },
@@ -106,7 +106,18 @@ public void PrimitiveExamplevalueInitializeWorksForPrimitiveData(string data, ob
106106
Assert.NotNull(value);
107107
Assert.Equal("Primitive example value", value.Description);
108108
Assert.NotNull(value.Value);
109-
Assert.Equal(except, value.Value.Value);
109+
switch (except)
110+
{
111+
case DateOnly dateOnly:
112+
Assert.Equal(dateOnly.ToString("yyyy-MM-dd"), value.Value.Value.ToString());
113+
break;
114+
case TimeOnly timeOnly:
115+
Assert.Equal(timeOnly.ToString("HH:mm:ss.fffffff"), value.Value.Value.ToString());
116+
break;
117+
default:
118+
Assert.Equal(except, value.Value.Value);
119+
break;
120+
}
110121
}
111122

112123
private IEdmModel GetEdmModel(string annotation)

0 commit comments

Comments
 (0)