public void QueryArrayItems_MatchingPropertyToArray_ReturnsArray() { var input = @" [ { ""key"": ""value"" }, { ""key"": ""other-value"" } ]"; var expected = new[] { new { key = "value" } }; var source = new JsonReader().Query(input, new { key=String.Empty }); var query = source.ArrayItems().Where(obj => obj.key == "value"); var actual = query.ToArray(); Assert.Equal(expected, actual, true); }
public void QueryArrayItems_MatchingPropertyToArray_ReturnsSingleObject() { var input = @" [ { ""key"": ""value"" }, { ""key"": ""other-value"" } ]"; var expected = new [] { new { Other = "otherValue", Key = "value" } }; var source = new JsonReader().Query(input, new { key=String.Empty }); var query = from obj in source.ArrayItems() where obj.key == "value" select new { Other = "otherValue", Key = obj.key }; var actual = query.ToArray(); Assert.Equal(expected, actual, true); }