Пример #1
0
        public void XmlToJson_FailXmlShouldBeAnnounce(string xml)
        {
            string expected = "Bad Xml format";
            string actual   = XmlToJson.Convert(xml);

            Assert.Equal(expected, actual);
        }
Пример #2
0
        public void XmlToJson_LongXmlShouldBeConverted()
        {
            string xml      = "<TRANS><HPAY><ID>103</ID><STATUS>3</STATUS><EXTRA><IS3DS>0</IS3DS><AUTH>031183</AUTH></EXTRA><INT_MSG/><MLABEL>501767XXXXXX6700</MLABEL><MTOKEN>project01</MTOKEN></HPAY></TRANS>";
            string expected = "{\"TRANS\":{\"HPAY\":{\"ID\":\"103\",\"STATUS\":\"3\",\"EXTRA\":{\"IS3DS\":\"0\",\"AUTH\":\"031183\"},\"INT_MSG\":null,\"MLABEL\":\"501767XXXXXX6700\",\"MTOKEN\":\"project01\"}}}";
            string actual   = XmlToJson.Convert(xml);

            Assert.Equal(expected, actual);
        }
Пример #3
0
        public void XMLToJSONTests_EnsureOneLineModelConverts()
        {
            string xml          = ReflectionUtilities.GetResourceAsString("UnitTests.Core.ApsimFile.XMLToJSONTests_EnsureOneLineModelConverts.xml");
            string expectedJson = ReflectionUtilities.GetResourceAsString("UnitTests.Core.ApsimFile.XMLToJSONTests_EnsureOneLineModelConverts.json");

            string json = XmlToJson.Convert(xml);

            Assert.AreEqual(expectedJson, json);
        }
Пример #4
0
        public void Can_Convert_Xml_And_Parse_Json()
        {
            var     json       = XmlToJson.Convert(xml);
            var     selector   = "query.results.channel.wind.chill,query.results.channel.wind.speed";
            var     parser     = new JsonObjectParser();
            var     jsonString = parser.Parse(json, selector);
            dynamic result     = JsonConvert.DeserializeObject <ExpandoObject>(jsonString);

            Assert.IsNotNull(result, "result was null");
            Assert.AreEqual("59", result.chill, "chill was not correct.");
            Assert.AreEqual("18", result.speed, "speed was not correct.");
        }
Пример #5
0
        public void XmlToJson_SimpleXmlShouldBeConverted(string xml, string expected)
        {
            string actual = XmlToJson.Convert(xml);

            Assert.Equal(expected, actual);
        }