Example #1
0
        public void TestUploadFile()
        {
            // 接口请求
            FileUploadRequest request = new FileUploadRequest();
            // 请求参数
            GoodsParam param = new GoodsParam();

            // 属性赋值
            param.goods_name = "iphone6";

            // 设置请求参数
            request.Param = param;

            List <UploadFile> files = new List <UploadFile>();

            files.Add(new UploadFile("headImg", @"D:\1.txt"));
            files.Add(new UploadFile("idcardImg", @"D:\2.txt"));
            request.Files = files;

            // 发送请求,返回结果
            FileUploadResponse response = client.Execute <FileUploadResponse>(request);

            if (response.IsSuccess())
            {
                Assert.IsTrue(response.data != null);
            }
            else
            {
                throw new SystemException(response.msg);
            }
        }
Example #2
0
        public void TestGetGoods2()
        {
            // 接口请求
            GetGoodsRequest request = new GetGoodsRequest();
            // 请求参数
            GoodsParam param = new GoodsParam();

            // 属性赋值
            param.goods_name = "iphone6";

            // 设置请求参数
            request.Param = param;
            // GET请求
            request.RequestMethod = RequestMethod.GET;

            // 发送请求,返回结果
            GetGoodsResponse response = client.Execute <GetGoodsResponse>(request);

            if (response.IsSuccess())
            {
                Assert.IsTrue(response.data is Goods);
                Assert.IsTrue(response.data.goods_name == "苹果iPhoneX");
            }
            else
            {
                throw new SystemException(response.msg);
            }
        }
Example #3
0
        public void TestGetGoodsJwt()
        {
            // 接口请求
            GetGoodsRequest request = new GetGoodsRequest();
            // 请求参数
            GoodsParam param = new GoodsParam();

            // 属性赋值
            param.goods_name = "iphone6";

            // 设置请求参数
            request.Param = param;

            OpenHttp openHttp = new OpenHttp(new OpenConfig());
            string   jwt      = openHttp.Get(@"http://localhost:8080/jwtLogin", null);

            // 发送请求,返回结果
            GetGoodsResponse response = client.Execute <GetGoodsResponse>(request, jwt);

            if (response.IsSuccess())
            {
                Assert.IsTrue(response.data is Goods);
                Assert.IsTrue(response.data.goods_name == "苹果iPhoneX");
            }
            else
            {
                throw new SystemException(response.msg);
            }
        }