예제 #1
0
        public void SimpleJson()
        {
            const string json = @"
			{
				""Name"": ""Vasya""
			}"            ;

            var result = new QueryableJson(json);

            result.Should().BeEquivalentTo(new Dictionary <string, string>
            {
                ["Name"] = "Vasya"
            });
        }
예제 #2
0
        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"
            });
        }
예제 #3
0
        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"
            });
        }
예제 #4
0
        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"
            });
        }
예제 #5
0
        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"
            });
        }
예제 #6
0
        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"
            });
        }