Skip to content

[BUG] - InputValueExtractor fais on objects with indexes #951

Description

@Unholius

`
private class PocoClassWithIndex
{
public string Name { get; set; }
public object this[string name] => Name;
public int Age { get; set; }
public IEnumerable Fruits; // Field
};

[Fact]
public void ToValueDictionary_Given_InputIsPocoClass_Then_Output_IsAnEquivalentDictionary()
{
    var valueObject = new PocoClassWithIndex
    {
        Name = "John",
        Age = 18,
        Fruits = new List<string> { "Apples, Oranges" }
    };

    var expectedOutput = new Dictionary<string, object>
    {
        ["Name"] = "John",
        ["Age"] = 18,
        ["Fruits"] = new List<string> { "Apples, Oranges" }
    };

    var sut = new InputValueExtractor();
    var result = sut.ToValueDictionary(valueObject);
 
    Assert.Equal(result.Count, expectedOutput.Count);
    foreach (var (key, value) in result)
    {
        Assert.Equal(value, expectedOutput[key]);
    }
}

`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions