Ejemplo n.º 1
0
        public void TestAnalyseDataItem_服务器返回错误信息()
        {
            string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
                + "<error_rsp>"
                + "  <args>"
                + "    <arg name=\"api_key\"><![CDATA[12003014]]></arg>"
                + "  </args>"
                + "  <code>551</code>"
                + "  <msg><![CDATA[Item service unavailable:获取单个商品失败]]></msg>"
                + "</error_rsp>"
                + "<!--top50.cm1-->";

            AnalyseData analyser = new AnalyseData(defaultAppKey, defaultAppSecret);
            try
            {
                ItemListItem item = analyser.AnalyseDataItem<ItemListItem>(xml);
            }
            catch (ResponseException ex)
            {
                string errorXml = "<error_rsp>"
                    + "<args>"
                        + "<arg name=\"api_key\"><![CDATA[12003014]]></arg>"
                    + "</args>"
                    + "<code>551</code>"
                    + "<msg><![CDATA[Item service unavailable:获取单个商品失败]]></msg>"
                    + "</error_rsp>";
                Assert.AreEqual(errorXml, ex.ErrorXml);
            }
            catch (Exception ex)
            {
                Assert.Fail("应该抛出服务器返回错误信息的异常,而不是" + ex.GetType().ToString() + "异常");
            }
        }
Ejemplo n.º 2
0
        public void TestAnalyseDataItem_服务器返回错误信息()
        {
            string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
                         + "<error_rsp>"
                         + "  <args>"
                         + "    <arg name=\"api_key\"><![CDATA[12003014]]></arg>"
                         + "  </args>"
                         + "  <code>551</code>"
                         + "  <msg><![CDATA[Item service unavailable:获取单个商品失败]]></msg>"
                         + "</error_rsp>"
                         + "<!--top50.cm1-->";

            AnalyseData analyser = new AnalyseData(defaultAppKey, defaultAppSecret);

            try
            {
                ItemListItem item = analyser.AnalyseDataItem <ItemListItem>(xml);
            }
            catch (ResponseException ex)
            {
                string errorXml = "<error_rsp>"
                                  + "<args>"
                                  + "<arg name=\"api_key\"><![CDATA[12003014]]></arg>"
                                  + "</args>"
                                  + "<code>551</code>"
                                  + "<msg><![CDATA[Item service unavailable:获取单个商品失败]]></msg>"
                                  + "</error_rsp>";
                Assert.AreEqual(errorXml, ex.ErrorXml);
            }
            catch (Exception ex)
            {
                Assert.Fail("应该抛出服务器返回错误信息的异常,而不是" + ex.GetType().ToString() + "异常");
            }
        }
Ejemplo n.º 3
0
        public void TestAnalyseDataItem_解析正确的XML文本()
        {
            string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
                + "<rsp>"
                + "  <item>"
                + "    <iid><![CDATA[302a0499bf58d002de05da07f523f3f9]]></iid>"
                + "    <detail_url><![CDATA[http://item.taobao.com/auction/item_detail.jhtml?item_id=302a0499bf58d002de05da07f523f3f9&x_id=0xid]]></detail_url>"
                + "    <title><![CDATA[韩国代购THURSDAY ISLAND专柜正品&mdash;TB3TS05AU粉色短袖T恤]]></title>"
                + "    <nick><![CDATA[fengxiangxia]]></nick>"
                + "    <type><![CDATA[fixed]]></type>"
                + "    <cid><![CDATA[50011150]]></cid>"
                + "    <desc><![CDATA[商品描述]]></desc>"
                + "    <pic_path><![CDATA[http://img06.taobaocdn.com/bao/uploaded/i6/T1h.ljXoUrvJN81.sV_021900.jpg]]></pic_path>"
                + "    <num>6</num>"
                + "    <approve_status><![CDATA[onsale]]></approve_status>"
                + "  </item>"
                + "</rsp>"
                + "<!--top14.cm3-->";

            AnalyseData analyser = new AnalyseData(defaultAppKey, defaultAppSecret);
            ItemListItem item = analyser.AnalyseDataItem<ItemListItem>(xml);
            Assert.AreEqual("302a0499bf58d002de05da07f523f3f9", item.Id);
        }
Ejemplo n.º 4
0
        public void TestAnalyseDataItem_解析正确的XML文本()
        {
            string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
                         + "<rsp>"
                         + "  <item>"
                         + "    <iid><![CDATA[302a0499bf58d002de05da07f523f3f9]]></iid>"
                         + "    <detail_url><![CDATA[http://item.taobao.com/auction/item_detail.jhtml?item_id=302a0499bf58d002de05da07f523f3f9&x_id=0xid]]></detail_url>"
                         + "    <title><![CDATA[韩国代购THURSDAY ISLAND专柜正品&mdash;TB3TS05AU粉色短袖T恤]]></title>"
                         + "    <nick><![CDATA[fengxiangxia]]></nick>"
                         + "    <type><![CDATA[fixed]]></type>"
                         + "    <cid><![CDATA[50011150]]></cid>"
                         + "    <desc><![CDATA[商品描述]]></desc>"
                         + "    <pic_path><![CDATA[http://img06.taobaocdn.com/bao/uploaded/i6/T1h.ljXoUrvJN81.sV_021900.jpg]]></pic_path>"
                         + "    <num>6</num>"
                         + "    <approve_status><![CDATA[onsale]]></approve_status>"
                         + "  </item>"
                         + "</rsp>"
                         + "<!--top14.cm3-->";

            AnalyseData  analyser = new AnalyseData(defaultAppKey, defaultAppSecret);
            ItemListItem item     = analyser.AnalyseDataItem <ItemListItem>(xml);

            Assert.AreEqual("302a0499bf58d002de05da07f523f3f9", item.Id);
        }