public void SimpleJson() { const string json = @" { ""Name"": ""Vasya"" }" ; var result = new QueryableJson(json); result.Should().BeEquivalentTo(new Dictionary <string, string> { ["Name"] = "Vasya" }); }
public void Select_Works() { const string json = @" { ""Country"": ""Oblivion"" }" ; var result = new QueryableJson(json) .Select(x => QueryableJson.All); result.Should().BeEquivalentTo(new Dictionary <string, string> { ["Country"] = "Oblivion" }); }
public void Where_Works() { const string json = @" { ""Name"": ""Vasya"", ""Sex"": ""undefined"" }" ; var result = new QueryableJson(json) .Where(pair => pair.Value == "undefined"); result.Should().BeEquivalentTo(new Dictionary <string, string> { ["Sex"] = "undefined" }); }
public void Select_Works_WithArray() { const string json = @" { ""IsTrue"": true, ""Useless"": [ ""JavaScript"", ""Front-end"" ] }" ; var result = new QueryableJson(json) .Select(x => QueryableJson.AllFromArrays); result.Should().BeEquivalentTo(new Dictionary <string, string> { ["Useless[0]"] = "JavaScript", ["Useless[1]"] = "Front-end" }); }
public void SelectAndWhere_WorkTogether() { const string json = @" { ""IsTrue"": true, ""Useless"": [ ""JavaScript"", ""Front-end"" ] }" ; var result = new QueryableJson(json) .Select(x => QueryableJson.AllFromArrays) .Where(pair => pair.Key.EndsWith("[1]")); result.Should().BeEquivalentTo(new Dictionary <string, string> { ["Useless[1]"] = "Front-end" }); }
public void Where_Works_WithTwoCalls() { const string json = @" { ""Name"": ""Vasya"", ""Sex"": ""undefined"", ""FullName"": ""Vasya Pumpkin"" }" ; var result = new QueryableJson(json) .Where(pair => pair.Key.Length > 3) .Where(pair => pair.Key.Length < 5); result.Should().BeEquivalentTo(new Dictionary <string, string> { ["Name"] = "Vasya" }); }