Created
January 9, 2011 10:36
-
-
Save GraemeF/771591 to your computer and use it in GitHub Desktop.
Failing test for JsonFx deserializing a List<T>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Tests | |
{ | |
using System.Collections.Generic; | |
using System.Linq; | |
using JsonFx.Json; | |
using Should.Fluent; | |
using Xunit; | |
public class JsonFxTests | |
{ | |
[Fact] | |
public void Read__ReadsAList() | |
{ | |
string json = "{\"Bars\":[{\"Baz\":\"Test\"}]}"; | |
// this gives JsonFx.Serialization.DeserializationException: JsonFx.Serialization.DeserializationException : Error converting System.Collections.Generic.List`1[[System.Object]] to System.Collections.Generic.List`1[[Tests.Bar]] | |
var result = new JsonReader().Read<Foo>(json); | |
result.Bars.Single().Baz.Should().Equal("Test"); | |
} | |
} | |
public class Foo | |
{ | |
public List<Bar> Bars { get; set; } | |
} | |
public class Bar | |
{ | |
public string Baz { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JsonFx desirializing can't use List ?
Instead of List, Array is deserialized.