创建工程

把Apis/目录下的代码拷贝进来

HelloWorld
using AepSdk.Apis.Core;using System;using System.Collections.Generic;using System.Diagnostics;using Xunit;namespace CTWingAgent{/// <summary>/// 查询设备列表/// 官方文档给的示例:https://www.ctwing.cn/yykf/126#see/// </summary>public class QueryDeviceList{//查询设备列表public Rootobject DoRequest(string appKey, string appSecret, string MasterKey, string productId, string searchValue = "", string pageNow = "", string pageSize = ""){//API地址string path = "/aep_device_management/devices";//头Dictionary<string, string> headers = new Dictionary<string, string>();headers.Add("MasterKey", MasterKey);//参数Dictionary<string, string> param = new Dictionary<string, string>();param.Add("productId", productId);param.Add("searchValue", searchValue);param.Add("pageNow", pageNow);param.Add("pageSize", pageSize);string version = "20190507012134";string application = appKey;string key = appSecret;string response = AepHttpRequest.SendAepHttpRequest(path, headers, param, null, version, application, key, "GET");Debug.WriteLine("[QueryDeviceList] " + response);Rootobject rootobject = Newtonsoft.Json.JsonConvert.DeserializeObject<Rootobject>(response);return rootobject;}[Fact]public void Test1(){//在 CTWing控制台 > 应用管理 > 打开指定应用string appKey = "**";string appSecret = "**";//在 CTWing控制台 > 产品 > 打开指定产品string MasterKey = "**";string productId = "**";Rootobject result = DoRequest(appKey, appSecret, MasterKey, productId);}//////////复制AepHttpRequest.SendAepHttpRequest返回的JSON字符串结果//////////Visual studio > 编辑 > 选择性粘贴 > 将JSON粘贴为类,即可生成以下数据结构,不需要手动定义/// <summary>/// JSON数据结构/// </summary>public class Rootobject{public int code { get; set; }public string msg { get; set; }public Result result { get; set; }}public class Result{public int pageNum { get; set; }public int pageSize { get; set; }public int total { get; set; }public List[] list { get; set; }}public class List{public string deviceId { get; set; }public string deviceName { get; set; }public string tenantId { get; set; }public int productId { get; set; }public string imei { get; set; }public object imsi { get; set; }public object firmwareVersion { get; set; }public int deviceStatus { get; set; }public int autoObserver { get; set; }public long createTime { get; set; }public string createBy { get; set; }public object updateTime { get; set; }public object updateBy { get; set; }public object netStatus { get; set; }public object onlineAt { get; set; }public object offlineAt { get; set; }}}}
把demo加入,并修改成单元测试的形式
把demo加入
想运行哪个,并适当修改代码,弄成单元测试的形式即可
