-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
56 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NewLife.Log; | ||
using NewLife.MQTT; | ||
using NewLife.Security; | ||
using Xunit; | ||
|
||
namespace XUnitTestClient | ||
namespace XUnitTestClient; | ||
|
||
public class AliyunMqttClientTests | ||
{ | ||
public class AliyunMqttClientTests | ||
[Fact] | ||
public async Task Test3() | ||
{ | ||
[Fact] | ||
public async void Test3() | ||
{ | ||
var client = new AliyunMqttClient("a18RQ72tLHD", "dev1", "6oSl3CjHKM13J50DVVWNF3WbWWJjhAUf"); | ||
client.Log = XTrace.Log; | ||
client.Server = $"tcp://{client.ProductKey}.iot-as-mqtt.cn-shanghai.aliyuncs.com:443"; | ||
var client = new AliyunMqttClient("a18RQ72tLHD", "dev1", "6oSl3CjHKM13J50DVVWNF3WbWWJjhAUf"); | ||
client.Log = XTrace.Log; | ||
client.Server = $"tcp://{client.ProductKey}.iot-as-mqtt.cn-shanghai.aliyuncs.com:443"; | ||
|
||
await client.ConnectAsync(); | ||
await client.SyncTime(); | ||
await client.PostProperty(new | ||
await client.ConnectAsync(); | ||
await client.SyncTime(); | ||
await client.PostProperty(new | ||
{ | ||
// 温度 | ||
Temperature = Rand.Next(-4000, 120_00) / 100d, | ||
// 相对湿度 | ||
RelativeHumidity = Rand.Next(0, 100_00) / 100d, | ||
// 风向 | ||
WindDirection = Rand.Next(0, 360_00) / 100d, | ||
// 氟化物浓度 | ||
Fluoride = Rand.Next(0, 10000_00) / 100d, | ||
// 空气质量指数 | ||
AQI = Rand.Next(0, 500), | ||
// 首要污染物 | ||
PrimaryItem = Rand.NextString(32), | ||
// 地理位置 | ||
GeoLocation = new | ||
{ | ||
// 温度 | ||
Temperature = Rand.Next(-4000, 120_00) / 100d, | ||
// 相对湿度 | ||
RelativeHumidity = Rand.Next(0, 100_00) / 100d, | ||
// 风向 | ||
WindDirection = Rand.Next(0, 360_00) / 100d, | ||
// 氟化物浓度 | ||
Fluoride = Rand.Next(0, 10000_00) / 100d, | ||
// 空气质量指数 | ||
AQI = Rand.Next(0, 500), | ||
// 首要污染物 | ||
PrimaryItem = Rand.NextString(32), | ||
// 地理位置 | ||
GeoLocation = new | ||
{ | ||
Longitude = Rand.Next(-180_00, 180_00) / 100d, | ||
Latitude = Rand.Next(-180_00, 180_00) / 100d, | ||
Altitude = Rand.Next(0, 10000_00) / 100d, | ||
// 1=WGS_84, 2=GCJ_02 | ||
CoordinateSystem = 1, | ||
}, | ||
}); | ||
} | ||
Longitude = Rand.Next(-180_00, 180_00) / 100d, | ||
Latitude = Rand.Next(-180_00, 180_00) / 100d, | ||
Altitude = Rand.Next(0, 10000_00) / 100d, | ||
// 1=WGS_84, 2=GCJ_02 | ||
CoordinateSystem = 1, | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters