Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/ServiceStack.Text.Tests/AutoMappingObjectDictionaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,39 @@ public void Can_convert_from_ObjectDictionary_into_AutoQuery_DTO()
Assert.That(request.Meta, Is.EquivalentTo(new Dictionary<string, object> {{"foo", "bar"}}));
}

public class PersonWithIdentities
{
public string Name { get; set; }
public List<OtherName> OtherNames { get;set; }
}

public class OtherName
{
public string Name { get; set; }
}

[Test]
public void Can_Convert_from_ObjectDictionary_Containing_Another_Object_Dictionary()
{
var map = new Dictionary<string, object>
{
{ "name", "Foo" },
{ "otherNames", new List<object>
{
new Dictionary<string, object> { { "name", "Fu" } },
new Dictionary<string, object> { { "name", "Fuey" } }
}
}
};

var fromDict = map.FromObjectDictionary<PersonWithIdentities>();

Assert.AreEqual("Foo", fromDict.Name);
Assert.AreEqual(2, fromDict.OtherNames.Count);
Assert.AreEqual("Fu", fromDict.OtherNames.First().Name);
Assert.AreEqual("Fuey", fromDict.OtherNames.Last().Name);
}

public class Employee
{
public string FirstName { get; set; }
Expand Down