Skip to content

Commit

Permalink
test explicit scalar attribute type
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude committed May 30, 2024
1 parent 497d520 commit 4b1190c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public void MixedSetDeserialization()
var services = new ServiceCollection();
services.UseCommercetoolsApiSerialization(new SerializationConfiguration() { AttributeTypeMap = new Dictionary<string, Type>()
{
{ "set-mixed", typeof(SetAttribute<decimal>) }
{ "set-mixed", typeof(SetAttribute<decimal>) },
{ "decimal", typeof(DecimalAttribute) },
}});
var serviceProvider = services.BuildServiceProvider();
var serializerService = serviceProvider.GetService<IApiSerializerService>();
Expand All @@ -37,6 +38,7 @@ public void MixedSetDeserialization()
Assert.NotNull(deserialized);
var attributes = deserialized.Attributes;
Assert.IsType<List<decimal>>(attributes.Get("set-mixed").Value);
Assert.IsType<decimal>(attributes.Get("decimal").Value);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{
"name": "set-mixed",
"value": [10, 10.3]
},
{
"name": "decimal",
"value": 10.3
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ private Type GetElementTypeForToken(JsonElement element)
return tokenType;
}

[Obsolete("use GetAttribute(attributeName, element) instead")]
public IAttribute GetAttribute(JsonElement element)
{
var type = GetTypeForToken(element);
Expand Down

0 comments on commit 4b1190c

Please sign in to comment.