Skip to content

Commit

Permalink
Finish unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CrDoming committed Dec 3, 2024
1 parent b71e280 commit f451d7e
Show file tree
Hide file tree
Showing 10 changed files with 411 additions and 234 deletions.
4 changes: 2 additions & 2 deletions PTI.Rs232Validator.CLI/Commands/SendExtendedRequestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public override int Execute(CommandContext context, Settings settings)
{
case ExtendedCommand.BarcodeDetected:
var responseMessage = billValidator.GetDetectedBarcode().Result;
if (!string.IsNullOrEmpty(responseMessage?.Barcode))
if (responseMessage is { IsValid: true, Barcode.Length: > 0 })
{
commandLogger.LogInfo($"The barcode is: {responseMessage.Barcode}");
}
else if (responseMessage is not null)
else if (responseMessage is { IsValid: true, Barcode.Length: 0 })
{
commandLogger.LogInfo("No barcode was detected since the last power cycle.");
}
Expand Down
22 changes: 11 additions & 11 deletions PTI.Rs232Validator.Cli/Commands/SendTelemetryRequestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.Ping:
{
var responseMessage = billValidator.PingAsync().Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo("Successfully pinged the acceptor.");
}
Expand All @@ -53,11 +53,11 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.GetSerialNumber:
{
var responseMessage = billValidator.GetSerialNumberAsync().Result;
if (!string.IsNullOrEmpty(responseMessage?.SerialNumber))
if (responseMessage is { IsValid: true, SerialNumber.Length: > 0 })
{
commandLogger.LogInfo($"The serial number is: {responseMessage.SerialNumber}");
}
else if (responseMessage?.SerialNumber is not null)
else if (responseMessage is { IsValid: true, SerialNumber.Length: 0 })
{
commandLogger.LogInfo("The was not assigned a serial number.");
}
Expand All @@ -72,7 +72,7 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.GetCashboxMetrics:
{
var responseMessage = billValidator.GetCashboxMetrics().Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo($"The cashbox metrics are as follows — {responseMessage}");
}
Expand All @@ -87,7 +87,7 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.ClearCashboxCount:
{
var responseMessage = billValidator.ClearCashboxCount().Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo("Successfully cleared the cashbox count.");
}
Expand All @@ -102,7 +102,7 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.GetUnitMetrics:
{
var responseMessage = billValidator.GetUnitMetrics().Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo($"The unit metrics are as follows — {responseMessage}");
}
Expand All @@ -117,7 +117,7 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.GetServiceUsageCounters:
{
var responseMessage = billValidator.GetServiceUsageCounters().Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo($"The service usage counters are as follows — {responseMessage}");
}
Expand All @@ -132,7 +132,7 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.GetServiceFlags:
{
var responseMessage = billValidator.GetServiceFlags().Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo($"The service flags are as follows — {responseMessage}");
}
Expand All @@ -155,7 +155,7 @@ public override int Execute(CommandContext context, Settings settings)

var correctableComponent = (CorrectableComponent)index;
var responseMessage = billValidator.ClearServiceFlags(correctableComponent).Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo($"Successfully cleared the service flag for index {index}.");
}
Expand All @@ -170,7 +170,7 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.GetServiceInfo:
{
var responseMessage = billValidator.GetServiceInfo().Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo($"The service info is as follows — {responseMessage}");
}
Expand All @@ -185,7 +185,7 @@ public override int Execute(CommandContext context, Settings settings)
case TelemetryCommand.GetFirmwareMetrics:
{
var responseMessage = billValidator.GetFirmwareMetrics().Result;
if (responseMessage is not null)
if (responseMessage.IsValid)
{
commandLogger.LogInfo($"The firmware metrics are as follows — {responseMessage}");
}
Expand Down
Loading

0 comments on commit f451d7e

Please sign in to comment.