Exemplo n.º 1
0
        public void mapJsonStringTest()
        {
            Dictionary <object, object> m = new Dictionary <object, object>();

            m.Add("testString", "didididi");
            m.Add("testInt", 100);
            m.Add("testInt2", "100");
            m.Add("testBoolean", "true");
            ParamTestModel model = new ParamTestModel();

            model.setAction("testAction");
            ParamTypeModel typeModel = new ParamTypeModel();

            typeModel.setAlarmStatus("status");
            typeModel.setInstanceClass(10);
            m.Add("testObject", typeModel);

            String d = QSStringUtil.getDictionaryToJson(m);

            Console.WriteLine(d);
            Object o = QSJSONUtil.convertJSONObject(d);

            Assert.IsNotNull(o);
            Dictionary <String, Object> dic = QSJSONUtil.JsonToDictionary(d);

            Assert.AreEqual(dic["testString"], "didididi");
            Assert.AreEqual(Convert.ToInt32(dic["testInt2"]), 100);
        }
Exemplo n.º 2
0
        public void testSignature()
        {
            ParamTestModel instancesInput = new ParamTestModel();

            instancesInput.setAction("TestAction");
            List <String> imgs = new List <String>();

            imgs.Add("test-0001");
            imgs.Add("test-0002");
            instancesInput.setImageID(imgs);

            Dictionary <object, object> queryParam =
                QSParamInvokeUtil.getRequestParams(instancesInput, QSConstant.PARAM_TYPE_QUERY);

            /*https://api.qc.dev/iaas?access_key_id=QYACCESSKEYIDEXAMPLE&image_id.0=test-0001&image_id.1=test-0002&
             * // search_word=serch_word_test&signature_method=HmacSHA256&signature_version=1&
             * // time_stamp=2016-12-02T13%3A07%3A16Z&version=1&signature=r%2FR9TmmnZQWhkEi1gQy5qV9wEPjoJYi9QHSKzliq2eg%3D
             */
            String d   = QSSignatureUtil.formatGmtDate(DateTime.Now);
            String url =
                QSSignatureUtil.getAuth(
                    "QYACCESSKEYIDEXAMPLE",
                    "wudajefiLSJDWIFJLSD",
                    "GET",
                    "objectTest",
                    queryParam,
                    null);

            Assert.AreEqual(url.IndexOf("QS QYACCESSKEYIDEXAMPLE:") >= 0, true);
        }
        public void testParam()
        {
            ParamTestModel instancesInput = new ParamTestModel();
            List <String>  imgs           = new List <String>();

            imgs.Add("test-0001");
            imgs.Add("test-0002");

            instancesInput.setImageID(imgs);
            instancesInput.setAction("serch_word_test");
            Dictionary <Object, Object> queryParam =
                QSParamInvokeUtil.getRequestParams(instancesInput, QSConstant.PARAM_TYPE_QUERY);
            Dictionary <Object, Object> bodyParam =
                QSParamInvokeUtil.getRequestParams(
                    instancesInput, QSConstant.PARAM_TYPE_BODYINPUTSTREAM);

            Assert.AreEqual(queryParam["action"], "serch_word_test");
            Assert.AreEqual(((List <String>)queryParam["image_id"])[1], "test-0002");
            Assert.AreEqual(queryParam.Count, 2);
            Assert.AreEqual(bodyParam.Count, 0);
        }