* Enhance some of the syntax

* Add more beautification
This commit is contained in:
Mikhail Chatillon 2023-10-17 10:00:53 +02:00 коммит произвёл GitHub
Родитель d301be6799
Коммит 7b50230676
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 22 добавлений и 30 удалений

Просмотреть файл

@ -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