Add some syntax enhancement (#2075)
* Enhance some of the syntax * Add more beautification
This commit is contained in:
Родитель
d301be6799
Коммит
7b50230676
|
@ -8,7 +8,7 @@ namespace LoraKeysManagerFacade
|
|||
|
||||
public class IoTHubDeviceInfo
|
||||
{
|
||||
[JsonProperty("DevAddr")]
|
||||
[JsonProperty(nameof(DevAddr))]
|
||||
public string DevAddrString
|
||||
{
|
||||
get => DevAddr.ToString();
|
||||
|
@ -21,7 +21,7 @@ namespace LoraKeysManagerFacade
|
|||
[JsonIgnore]
|
||||
public DevEui? DevEUI { get; set; }
|
||||
|
||||
[JsonProperty("DevEUI")]
|
||||
[JsonProperty(nameof(DevEUI))]
|
||||
public string DevEuiString
|
||||
{
|
||||
get => DevEUI?.ToString();
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace LoRaWan.NetworkServer
|
|||
|
||||
public class IoTHubDeviceInfo
|
||||
{
|
||||
[JsonProperty("DevAddr")]
|
||||
[JsonProperty(nameof(DevAddr))]
|
||||
public string DevAddrString
|
||||
{
|
||||
get => DevAddr?.ToString();
|
||||
|
@ -17,7 +17,7 @@ namespace LoRaWan.NetworkServer
|
|||
[JsonIgnore]
|
||||
public DevAddr? DevAddr { get; set; }
|
||||
|
||||
[JsonProperty("DevEUI")]
|
||||
[JsonProperty(nameof(DevEUI))]
|
||||
public string DevEuiString
|
||||
{
|
||||
get => DevEUI.ToString();
|
||||
|
@ -31,7 +31,7 @@ namespace LoRaWan.NetworkServer
|
|||
|
||||
public string GatewayId { get; set; }
|
||||
|
||||
[JsonProperty("NwkSKey")]
|
||||
[JsonProperty(nameof(NwkSKey))]
|
||||
public string NwkSKeyString
|
||||
{
|
||||
get => NwkSKey?.ToString();
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace LoRaTools.ADR
|
|||
|
||||
public class LoRaADRTableEntry
|
||||
{
|
||||
[JsonProperty("DevEUI")]
|
||||
[JsonProperty(nameof(DevEui))]
|
||||
public string DevEuiString
|
||||
{
|
||||
get => DevEUI.ToString();
|
||||
|
|
|
@ -19,21 +19,21 @@ namespace LoRaTools.CommonAPI
|
|||
[JsonIgnore]
|
||||
public NetworkSessionKey? NwkSKey { get; set; }
|
||||
|
||||
[JsonProperty("DevAddr")]
|
||||
[JsonProperty(nameof(DevAddr))]
|
||||
public string DevAddrString
|
||||
{
|
||||
get => DevAddr.ToString();
|
||||
set => DevAddr = DevAddr.Parse(value);
|
||||
}
|
||||
|
||||
[JsonProperty("DevEUI")]
|
||||
[JsonProperty(nameof(DevEUI))]
|
||||
public string DevEuiString
|
||||
{
|
||||
get => DevEUI?.ToString();
|
||||
set => DevEUI = value is null ? null : DevEui.Parse(value);
|
||||
}
|
||||
|
||||
[JsonProperty("NwkSKey")]
|
||||
[JsonProperty(nameof(NwkSKey))]
|
||||
public string NwkSKeyString
|
||||
{
|
||||
get => NwkSKey?.ToString();
|
||||
|
|
|
@ -312,10 +312,7 @@ namespace LoRaWan.Tests.Common
|
|||
TestLogger.Log($"Updating IoT Hub twin for concentrator {stationEui}...");
|
||||
var registryManager = GetRegistryManager();
|
||||
var stationDeviceId = GetDeviceId(stationEui);
|
||||
var getDeviceResult = await registryManager.GetTwinAsync(stationDeviceId);
|
||||
if (getDeviceResult == null)
|
||||
throw new InvalidOperationException("Concentrator should exist in IoT Hub");
|
||||
var deviceTwin = await registryManager.GetTwinAsync(stationDeviceId);
|
||||
var deviceTwin = await registryManager.GetTwinAsync(stationDeviceId) ?? throw new InvalidOperationException("Concentrator should exist in IoT Hub");
|
||||
var initialClientThumbprints = ((JArray)deviceTwin.Properties.Desired[BasicsStationConfigurationService.ClientThumbprintPropertyName]).ToObject<string[]>();
|
||||
if (condition(initialClientThumbprints))
|
||||
{
|
||||
|
@ -331,10 +328,7 @@ namespace LoRaWan.Tests.Common
|
|||
TestLogger.Log($"Updating IoT Hub twin for concentrator {stationEui}...");
|
||||
var registryManager = GetRegistryManager();
|
||||
var stationDeviceId = GetDeviceId(stationEui);
|
||||
var getDeviceResult = await registryManager.GetTwinAsync(stationDeviceId);
|
||||
if (getDeviceResult == null)
|
||||
throw new InvalidOperationException("Concentrator should exist in IoT Hub");
|
||||
var deviceTwin = await registryManager.GetTwinAsync(stationDeviceId);
|
||||
var deviceTwin = await registryManager.GetTwinAsync(stationDeviceId) ?? throw new InvalidOperationException("Concentrator should exist in IoT Hub");
|
||||
var cupsJson = ((object)deviceTwin.Properties.Desired[BasicsStationConfigurationService.CupsPropertyName]).ToString();
|
||||
var newCupsInfo = JsonConvert.DeserializeObject<CupsTwinInfo>(cupsJson) with
|
||||
{
|
||||
|
@ -350,10 +344,7 @@ namespace LoRaWan.Tests.Common
|
|||
TestLogger.Log($"Updating IoT Hub twin for fw upgrades of concentrator {stationEui}...");
|
||||
var registryManager = GetRegistryManager();
|
||||
var stationDeviceId = GetDeviceId(stationEui);
|
||||
var getDeviceResult = await registryManager.GetTwinAsync(stationDeviceId);
|
||||
if (getDeviceResult == null)
|
||||
throw new InvalidOperationException("Concentrator should exist in IoT Hub");
|
||||
var deviceTwin = await registryManager.GetTwinAsync(stationDeviceId);
|
||||
var deviceTwin = await registryManager.GetTwinAsync(stationDeviceId) ?? throw new InvalidOperationException("Concentrator should exist in IoT Hub");
|
||||
var cupsJson = ((object)deviceTwin.Properties.Desired[BasicsStationConfigurationService.CupsPropertyName]).ToString();
|
||||
var newCupsInfo = JsonConvert.DeserializeObject<CupsTwinInfo>(cupsJson) with
|
||||
{
|
||||
|
|
|
@ -43,8 +43,7 @@ namespace LoRaWan.Tests.E2E
|
|||
if (disposing)
|
||||
{
|
||||
// Before starting a new test, wait 5 seconds to ensure serial port is not receiving dirty data
|
||||
if (ArduinoDevice != null)
|
||||
ArduinoDevice.WaitForIdleAsync(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult();
|
||||
ArduinoDevice?.WaitForIdleAsync(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
this.isDisposed = true;
|
||||
|
|
|
@ -55,7 +55,9 @@ namespace LoRaWan.Tests.Integration
|
|||
}
|
||||
|
||||
[Theory]
|
||||
#pragma warning disable CA1825 // Avoid zero-length array allocations
|
||||
[MemberData(nameof(Upstream_And_Downstream_Succeeds_For_All_Regions_TheoryData))]
|
||||
#pragma warning restore CA1825 // Avoid zero-length array allocations
|
||||
public async Task When_ABP_Sends_Upstream_Followed_By_DirectMethod_Should_Send_Upstream_And_Downstream(string deviceGatewayID, uint fcntDownFromTwin, uint fcntDelta, Region region)
|
||||
{
|
||||
const uint payloadFcnt = 2; // to avoid relax mode reset
|
||||
|
|
|
@ -97,13 +97,13 @@ namespace LoRaWan.Tests.Unit.NetworkServer
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("{'router':'invalidEui','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(FormatException))]
|
||||
[InlineData("{'router':'aabb:ccff:fe00:1122','cupsUri':'https:/cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(UriFormatException))]
|
||||
[InlineData("{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss:/lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(UriFormatException))]
|
||||
[InlineData("{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':null, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(JsonException))]
|
||||
[InlineData("{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':null,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(JsonException))]
|
||||
[InlineData("{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':123,'keys':[]}", typeof(JsonException))]
|
||||
[InlineData("{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':'1.0.0','keys':['a']}", typeof(JsonException))]
|
||||
[InlineData(/*lang=json*/ "{'router':'invalidEui','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(FormatException))]
|
||||
[InlineData(/*lang=json*/ "{'router':'aabb:ccff:fe00:1122','cupsUri':'https:/cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(UriFormatException))]
|
||||
[InlineData(/*lang=json*/ "{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss:/lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(UriFormatException))]
|
||||
[InlineData(/*lang=json*/ "{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':null, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(JsonException))]
|
||||
[InlineData(/*lang=json*/ "{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':null,'station':'2.0.5','model':'m','package':null,'keys':[]}", typeof(JsonException))]
|
||||
[InlineData(/*lang=json*/ "{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':123,'keys':[]}", typeof(JsonException))]
|
||||
[InlineData(/*lang=json*/ "{'router':'aabb:ccff:fe00:1122','cupsUri':'https://cups:5002', 'tcUri':'wss://lns:5001', 'cupsCredCrc':1, 'tcCredCrc':1,'station':'2.0.5','model':'m','package':'1.0.0','keys':['a']}", typeof(JsonException))]
|
||||
public async Task HandleUpdateInfoAsync_Fails_WithInvalidInput(string input, Type exceptionType)
|
||||
{
|
||||
// setup
|
||||
|
|
Загрузка…
Ссылка в новой задаче