Beispiel #1
0
 public void XmlNavigator_SelectScalar_WithoutXmlPath_ExpectException()
 {
     using (var JsonNavigator = new XmlNavigator(TestData))
     {
         JsonNavigator.SelectScalar(new JsonPath());
     }
 }
Beispiel #2
0
 public void XmlNavigator_SelectScalarValue_WithNull_Expected_ArgumentNullException()
 {
     using (var xmlNavigator = new XmlNavigator(TestData))
     {
         xmlNavigator.SelectScalar(null);
     }
 }
Beispiel #3
0
        public void SelectScalarValue_WithWrongPathSegment_Expected_NoValue()
        {
            IPath namePath = new XmlPath("Company.Nogo", "Company.Nogo");

            var xmlNavigator = new XmlNavigator(testData);

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

            Assert.AreEqual(string.Empty, actual);
        }
Beispiel #4
0
        public void SelectScalarValue_WithEnumerablePathFromXml_WherePathMapsToANode_Expected_ScalarValue()
        {
            IPath namePath = new XmlPath("Company().InlineRecordSet", "Company.InlineRecordSet");

            var xmlNavigator = new XmlNavigator(testData);

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

            Assert.AreEqual(expected, actual);
        }
Beispiel #5
0
        public void SelectScalarValue_WithEnumerablePathFromXml_WherePathMapsToAnAttribute_Expected_ScalarValue()
        {
            IPath namePath = new XmlPath("Company.Departments().Department.Employees().Person:Name", "Company.Departments.Department.Employees.Person:Name");

            var xmlNavigator = new XmlNavigator(testData);

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

            Assert.AreEqual(expected, actual);
        }
Beispiel #6
0
        public void SelectScalarValue_WithScalarPathFromXmlWithASingleNode_WherePathMapsToANode_Expected_ScalarValue()
        {
            IPath namePath = new XmlPath("Message", "Message");

            var xmlNavigator = new XmlNavigator(testData);

            var          actual   = xmlNavigator.SelectScalar(namePath).ToString();
            const string expected = "Dummy Data";

            Assert.AreEqual(expected, actual);
        }
Beispiel #7
0
        public void SelectScalarValue_WithScalarPathFromXml_WherePathMapsToANode_Expected_ScalarValue()
        {
            IPath namePath = new XmlPath("Company.Motto", "Company.Motto");

            var xmlNavigator = new XmlNavigator(testData);

            var          actual   = xmlNavigator.SelectScalar(namePath).ToString();
            const string expected = "Eat lots of cake";

            Assert.AreEqual(expected, actual);
        }
Beispiel #8
0
        public void SelectScalarValue_WithScalarPathFromXml_WherePathMapsToAnAttribute_Expected_ScalarValue()
        {
            IPath namePath = new XmlPath("Company:Name", "Company:Name");

            var xmlNavigator = new XmlNavigator(testData);

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

            Assert.AreEqual(expected, actual);
        }
Beispiel #9
0
        public void SelectScalarValueUsingScalarPathFromXml_WherePathMapsToAnAttribute_Expected_ScalarValue()
        {
            string testData = Given();

            IPath namePath = new XmlPath("Company:Name", "Company:Name");

            XmlNavigator xmlNavigator = new XmlNavigator(testData);

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

            Assert.AreEqual(expected, actual);
        }
Beispiel #10
0
        public void SelectEnumerableValuesAsRelatedUsingEnumerablePathFromXmlFromFoPrimitiveType()
        {
            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml("<boolean xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">false</boolean>");
            var testData     = Scrubber.Scrub(xmlDocument.InnerXml);
            var xmlMapper    = new XmlMapper();
            var paths        = xmlMapper.Map(testData).ToList();
            var path         = paths.FirstOrDefault();
            var xmlNavigator = new XmlNavigator(testData);
            var dat2         = xmlNavigator.SelectScalar(path);

            Assert.AreEqual("false", dat2);
        }
Beispiel #11
0
        public void XmlNavigator_SelectScalarValue_WithPathSeperator_Expected_ScalarValue()
        {
            IPath namePath = new XmlPath(".", ".");

            using (var xmlNavigator = new XmlNavigator(TestData))
            {
                var          actual   = xmlNavigator.SelectScalar(namePath).ToString();
                const string expected =
                    "<Company Name=\"Dev2\">\r\n" +
                    "  <Motto>Eat lots of cake</Motto>\r\n" +
                    "  <PreviousMotto />\r\n" +
                    "  <Departments TestAttrib=\"testing\">\r\n" +
                    "    <Department Name=\"Dev\">\r\n" +
                    "      <Employees>\r\n" +
                    "        <Person Name=\"Brendon\" Surename=\"Page\" />\r\n" +
                    "        <Person Name=\"Jayd\" Surename=\"Page\" />\r\n" +
                    "      </Employees>\r\n" +
                    "    </Department>\r\n" +
                    "    <Department Name=\"Accounts\">\r\n" +
                    "      <Employees>\r\n" +
                    "        <Person Name=\"Bob\" Surename=\"Soap\" />\r\n" +
                    "        <Person Name=\"Joe\" Surename=\"Pants\" />\r\n" +
                    "      </Employees>\r\n" +
                    "    </Department>\r\n" +
                    "  </Departments>\r\n" +
                    "  <InlineRecordSet>\r\n" +
                    "                RandomData\r\n" +
                    "            </InlineRecordSet>\r\n" +
                    "  <InlineRecordSet>\r\n" +
                    "                RandomData1\r\n" +
                    "            </InlineRecordSet>\r\n" +
                    "  <OuterNestedRecordSet>\r\n" +
                    "    <InnerNestedRecordSet ItemValue=\"val1\" />\r\n" +
                    "    <InnerNestedRecordSet ItemValue=\"val2\" />\r\n" +
                    "  </OuterNestedRecordSet>\r\n" +
                    "  <OuterNestedRecordSet>\r\n" +
                    "    <InnerNestedRecordSet ItemValue=\"val3\" />\r\n" +
                    "    <InnerNestedRecordSet ItemValue=\"val4\" />\r\n" +
                    "  </OuterNestedRecordSet>\r\n</Company>";


                Assert.AreEqual(expected, actual);
            }
        }
Beispiel #12
0
        public void XmlNavigator_SelectScalarValue_WithPathSeperator_Expected_ScalarValue()
        {
            IPath namePath = new XmlPath(".", ".");

            using (var xmlNavigator = new XmlNavigator(TestData))
            {
                var          actual   = xmlNavigator.SelectScalar(namePath).ToString();
                const string expected = @"<Company Name=""Dev2"">
  <Motto>Eat lots of cake</Motto>
  <PreviousMotto />
  <Departments TestAttrib=""testing"">
    <Department Name=""Dev"">
      <Employees>
        <Person Name=""Brendon"" Surename=""Page"" />
        <Person Name=""Jayd"" Surename=""Page"" />
      </Employees>
    </Department>
    <Department Name=""Accounts"">
      <Employees>
        <Person Name=""Bob"" Surename=""Soap"" />
        <Person Name=""Joe"" Surename=""Pants"" />
      </Employees>
    </Department>
  </Departments>
  <InlineRecordSet>
        RandomData
    </InlineRecordSet>
  <InlineRecordSet>
        RandomData1
    </InlineRecordSet>
  <OuterNestedRecordSet>
    <InnerNestedRecordSet ItemValue=""val1"" />
    <InnerNestedRecordSet ItemValue=""val2"" />
  </OuterNestedRecordSet>
  <OuterNestedRecordSet>
    <InnerNestedRecordSet ItemValue=""val3"" />
    <InnerNestedRecordSet ItemValue=""val4"" />
  </OuterNestedRecordSet>
</Company>";

                Assert.AreEqual(expected, actual);
            }
        }
Beispiel #13
0
        public void SelectScalar_WithoutXmlPath_ExpectException()
        {
            var JsonNavigator = new XmlNavigator(testData);

            JsonNavigator.SelectScalar(new JsonPath());
        }
Beispiel #14
0
        public void SelectScalarValue_WithNull_Expected_ArgumentNullException()
        {
            var xmlNavigator = new XmlNavigator(testData);

            xmlNavigator.SelectScalar(null);
        }