Beispiel #1
0
        public void AllValues_ReturnsOneForEveryNestedKey()
        {
            var jObject = JObject.Parse(@"{ ""key"": ""value"", ""array"": [1, true, { ""another"": ""object"" }] }");

            var allValues = JsonDocument.AllValues(jObject);

            allValues.Should().HaveCount(4)
            .And.ContainKeys("key", "array:0", "array:1", "array:2:another");
        }
Beispiel #2
0
        public void AllValues_ReturnsOneForEveryArrayIndex()
        {
            var jArray = JArray.Parse("[1, true, null, \"\"]");

            var allValues = JsonDocument.AllValues(jArray).ToList();

            allValues.Should().HaveCount(4)
            .And.ContainKeys("0", "1", "2", "3");
        }
Beispiel #3
0
        public void AllValues_ReturnsOneForEveryObjectProperty()
        {
            var jObject = JObject.Parse(@"{ ""key"": ""value"", ""other"": 10, ""another"": null }");

            var allValues = JsonDocument.AllValues(jObject).ToList();

            allValues.Should().HaveCount(3)
            .And.ContainKeys("key", "other", "another");
        }
Beispiel #4
0
        public void AllValues_ReturnsSingleValueForJValue()
        {
            var jValue = JValue.Parse("10");

            var allValues = JsonDocument.AllValues(jValue).ToList();

            allValues.Should().HaveCount(1);

            var kv = allValues.Single();

            kv.Key.Should().Be("");
            kv.Value.Value.Should().NotBeNull().And.Be(10);
        }