Skip to content

Commit

Permalink
add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ11teen committed Mar 10, 2023
1 parent 13919ac commit 1c5e8a7
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,34 @@ public void KeyValueTypeDiscriminator_WithInterfaceBaseType_List()
resources[1].Should().BeOfType<KubernetesService>();
}

[Fact]
public void KeyValueTypeDiscriminator_MultipleWithSameKey()
{
var bufferedDeserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.WithTypeDiscriminatingNodeDeserializer(options => {
options.AddKeyValueTypeDiscriminator<KubernetesResource>(
"kind",
new Dictionary<string, Type>()
{
{ "Namespace", typeof(KubernetesNamespace) },
});
options.AddKeyValueTypeDiscriminator<KubernetesResource>(
"kind",
new Dictionary<string, Type>()
{
{ "Service", typeof(KubernetesService) }
});
},
maxDepth: 3,
maxLength: 40)
.Build();

var resources = bufferedDeserializer.Deserialize<List<KubernetesResource>>(ListOfKubernetesYaml);
resources[0].Should().BeOfType<KubernetesNamespace>();
resources[1].Should().BeOfType<KubernetesService>();
}

public const string ListOfKubernetesYaml = @"
- apiVersion: v1
kind: Namespace
Expand Down

0 comments on commit 1c5e8a7

Please sign in to comment.