Пример #1
0
        public void SelectScalarValue_WithEnumerablePathFromJson_WherePathMapsToPrimitiveEnumerable_Expected_ScalarValue()
        {
            IPath namePath = new JsonPath("PrimitiveRecordset()", "PrimitiveRecordset");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = JsonNavigator.SelectScalar(namePath).ToString().Trim();
            const string expected = "RandomData1";

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void SelectScalarValue_WithEnumerablePathFromJson_Expected_ScalarValue()
        {
            IPath namePath = new JsonPath("Departments().Employees().Name", "Departments.Employees.Name");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = JsonNavigator.SelectScalar(namePath).ToString();
            const string expected = "Joe";

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void SelectScalarValue_WithScalarPathFromJson_Expected_ScalarValue()
        {
            IPath namePath = new JsonPath("Name", "Name");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = JsonNavigator.SelectScalar(namePath).ToString();
            const string expected = "Dev2";

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void SelectScalarValueUsingScalarPathFromJson_Expected_ScalarValue()
        {
            string testData = Given();

            IPath namePath = new JsonPath("Name", "Name");

            JsonNavigator JsonNavigator = new JsonNavigator(testData);

            string actual   = JsonNavigator.SelectScalar(namePath).ToString();
            string expected = "Dev2";

            Assert.AreEqual(expected, actual);
        }
Пример #5
0
        public void SelectScalarValueUsingEnumerablePathFromJson_Expected_ScalarValue()
        {
            string testData = Given();

            IPath namePath = new JsonPath("Departments().Employees().Name", "Departments.Employees.Name");

            JsonNavigator JsonNavigator = new JsonNavigator(testData);

            string actual   = JsonNavigator.SelectScalar(namePath).ToString();
            string expected = "Joe";

            Assert.AreEqual(expected, actual);
        }
Пример #6
0
        public void SelectScalarValue_WithEnumerableSymbolAndSeperatorSymbol_Expected_PrimitiveRecordset()
        {
            IPath namePath = new JsonPath("().", "().");

            var JsonNavigator = new JsonNavigator(testData);

            var          actual   = JsonNavigator.SelectScalar(namePath).ToString();
            const string expected = @"""PrimitiveRecordset"": [
  ""\r\n        RandomData\r\n    "",
  ""\r\n        RandomData1\r\n    ""
]";

            Assert.AreEqual(expected, actual);
        }
Пример #7
0
        public void SelectScalar_WithoutJsonPath_ExpectException()
        {
            var JsonNavigator = new JsonNavigator(testData);

            JsonNavigator.SelectScalar(new XmlPath());
        }
Пример #8
0
        public void SelectScalar_WithNull_ExpectArgumentNullException()
        {
            var JsonNavigator = new JsonNavigator(testData);

            JsonNavigator.SelectScalar(null);
        }
Пример #9
0
        public void SelectScalarValueUsingSeperatorSymbol_Expected_UnchangedPath()
        {
            IPath namePath = new JsonPath(".", ".");

            var JsonNavigator = new JsonNavigator(testData);

            var actual = JsonNavigator.SelectScalar(namePath).ToString();

            var 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);
        }