Skip to content

Commit bb8bc1c

Browse files
committed
fix: minor json comparison fixes
Signed-off-by: Vincent Biret <[email protected]>
1 parent b2ba0ec commit bb8bc1c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using System.Linq;
8+
using System.Text.Json.Nodes;
89
using Microsoft.OData.Edm;
910
using Microsoft.OpenApi.Extensions;
1011
using Microsoft.OpenApi.Models;
@@ -832,7 +833,7 @@ public void CreateEnumTypeSchemaReturnCorrectSchema()
832833

833834
Assert.NotNull(schema.Enum);
834835
Assert.Equal(2, schema.Enum.Count);
835-
Assert.Equal([ "Blue", "White" ], schema.Enum.Select(e => e));
836+
Assert.Equal([ "Blue", "White" ], schema.Enum.Select(e => e.ToString()));
836837

837838
// Act
838839
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
@@ -950,28 +951,28 @@ public void CreatePropertySchemaWithComputedAnnotationReturnsCorrectSchema(OpenA
950951
// Act
951952
var schema = context.CreatePropertySchema(property, new());
952953
Assert.NotNull(schema);
953-
string json = schema.SerializeAsJson(specVersion);
954+
var json = JsonNode.Parse(schema.SerializeAsJson(specVersion));
954955

955956
// Assert
956957
if (specVersion == OpenApiSpecVersion.OpenApi2_0)
957958
{
958-
Assert.Equal(@"{
959+
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
959960
""format"": ""duration"",
960961
""description"": ""The length of the appointment, denoted in ISO8601 format."",
961962
""pattern"": ""^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+([.][0-9]+)?S)?)?$"",
962963
""type"": ""string"",
963964
""readOnly"": true
964-
}".ChangeLineBreaks(), json);
965+
}"), json));
965966
}
966967
else
967968
{
968-
Assert.Equal(@"{
969+
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
969970
""pattern"": ""^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+([.][0-9]+)?S)?)?$"",
970971
""type"": ""string"",
971972
""description"": ""The length of the appointment, denoted in ISO8601 format."",
972973
""format"": ""duration"",
973974
""readOnly"": true
974-
}".ChangeLineBreaks(), json);
975+
}"), json));
975976
}
976977
}
977978
#endregion

0 commit comments

Comments
 (0)