예제 #1
0
        public void SelectEnumerable_WithEnumerableSymbolAndSeperatorSymbol_Expected_PipeDelimited()
        {
            IPath namePath = new JsonPath("().", "().");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = string.Join("|", JsonNavigator.SelectEnumerable(namePath).Select(o => o.ToString().Trim()));
            const string expected = @"""Name"": ""Dev2""|""Motto"": ""Eat lots of cake""|""Departments"": [
  {
    ""Name"": ""Dev"",
    ""Employees"": [
      {
        ""Name"": ""Brendon"",
        ""Surename"": ""Page""
      },
      {
        ""Name"": ""Jayd"",
        ""Surename"": ""Page""
      }
    ]
  },
  {
    ""Name"": ""Accounts"",
    ""Employees"": [
      {
        ""Name"": ""Bob"",
        ""Surename"": ""Soap""
      },
      {
        ""Name"": ""Joe"",
        ""Surename"": ""Pants""
      }
    ]
  }
]|""Contractors"": [
  {
    ""Name"": ""Roofs Inc."",
    ""PhoneNumber"": ""123""
  },
  {
    ""Name"": ""Glass Inc."",
    ""PhoneNumber"": ""1234""
  },
  {
    ""Name"": ""Doors Inc."",
    ""PhoneNumber"": ""1235""
  },
  {
    ""Name"": ""Cakes Inc."",
    ""PhoneNumber"": ""1236""
  }
]|""PrimitiveRecordset"": [
  ""\r\n        RandomData\r\n    "",
  ""\r\n        RandomData1\r\n    ""
]";

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void SelectEnumerableValuesUsingEnumerablePathFromJson_WherePathMapsThroughNestedEnumerables_Expected_EnumerableValue()
        {
            IPath path = new JsonPath("Departments().Employees().Name", "Departments.Employees.Name");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = string.Join("|", JsonNavigator.SelectEnumerable(path).Select(o => o.ToString().Trim()));
            const string expected = "Brendon|Jayd|Bob|Joe";

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void SelectEnumerableValuesUsingScalarPathFromJson_Expected_EnumerableValue()
        {
            IPath path = new JsonPath("Motto", "Motto");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = string.Join("|", JsonNavigator.SelectEnumerable(path).Select(o => o.ToString().Trim()));
            const string expected = "Eat lots of cake";

            Assert.AreEqual(expected, actual);
        }
예제 #4
0
        public void SelectEnumerableValuesUsingEnumerablePathFromJson_Expected_EnumerableValue()
        {
            IPath path = new JsonPath("Departments().Name", "Departments.Name");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = string.Join("|", JsonNavigator.SelectEnumerable(path).Select(o => o.ToString().Trim()));
            const string expected = "Dev|Accounts";

            Assert.AreEqual(expected, actual);
        }
예제 #5
0
        public void SelectEnumerableValuesUsingEnumerablePathFromJson_WherePathMapsToPrimitiveEnumerable_Expected_EnumerableValue()
        {
            IPath path = new JsonPath("PrimitiveRecordset()", "PrimitiveRecordset");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = string.Join("|", JsonNavigator.SelectEnumerable(path).Select(o => o.ToString().Trim()));
            const string expected = "RandomData|RandomData1";

            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void SelectEnumerable_WithoutJsonPath_ExpectArgumentNullException()
        {
            var JsonNavigator = new JsonNavigator(testData);

            JsonNavigator.SelectEnumerable(new XmlPath());
        }
예제 #7
0
        public void SelectEnumerable_WithNull_ExpectArgumentNullException()
        {
            var JsonNavigator = new JsonNavigator(testData);

            JsonNavigator.SelectEnumerable(null);
        }