- improve Poseidon CLI diagnostics with working-directory, exit-code, stdout/stderr, JSON and NFC/reading validation - accept decimal dot and comma readings, including valid zero readings - add reader-cycle, fake CLI, timeout and Poseidon parsing test coverage - prevent legacy optical-head mode errors from crashing the UI - add automatic MySQL/SQLite Results DB migrations for MeterTestRslt: FlipMode, ExtraDataPath and X1–X9 - add SQLite reference required by the migration helper - update ReadMe_BugFix version history for releases 3.9.2149–3.9.2205
99 lines
3.9 KiB
C#
99 lines
3.9 KiB
C#
using System;
|
|
using System.Threading;
|
|
using Common;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
|
|
using IPerlCommunicationForm = TBF.Rig.TestMethods.iPerlCommunication.iPerlCommunicationFormTestMethod;
|
|
using IPerlConfigStruct = TBF.Rig.TestMethods.iPerlCommunication.iPerlHead.ConfigStruct;
|
|
using IPerlHead = TBF.Rig.TestMethods.iPerlCommunication.iPerlHead.IperlHead;
|
|
using IPerlHeadCfg = TBF.Rig.TestMethods.iPerlCommunication.iPerlHead.IperlHeadCfg;
|
|
using IPerlHeadFactory = TBF.Rig.TestMethods.iPerlCommunication.iPerlHead.Factory;
|
|
using static Sensus.iPerl.NfcHandler.MCI_Protocol;
|
|
|
|
namespace TBFTests.Rig.TestMethods.iPerlCommunication
|
|
{
|
|
/// <summary>
|
|
/// Manual, read-only integration test through the legacy iPerl communication form.
|
|
/// It reads Configuration only; it never writes to the connected meter.
|
|
/// </summary>
|
|
[TestClass]
|
|
[TestCategory("Integration")]
|
|
public class IPerlCommunicationFormIntegrationTest
|
|
{
|
|
// Set the COM port of the currently connected iPerl/ASIC test head.
|
|
// Keep 0 to disable this manual test.
|
|
private const int RealRfidComPort = 3;
|
|
private const int RealOptoComPort = 0;
|
|
private const CommunicationInterface RealCommunicationInterface = CommunicationInterface.RFID;
|
|
|
|
[TestMethod]
|
|
[TestCategory("Manual")]
|
|
public void ReadConfiguration_ThroughIPerlCommunicationForm()
|
|
{
|
|
if (RealRfidComPort <= 0)
|
|
{
|
|
Assert.Inconclusive(
|
|
"Set RealRfidComPort in IPerlCommunicationFormIntegrationTest before running this manual test.");
|
|
}
|
|
|
|
Exception failure = null;
|
|
Thread testThread = new Thread(() =>
|
|
{
|
|
try
|
|
{
|
|
ReadConfiguration();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
failure = exception;
|
|
}
|
|
});
|
|
testThread.SetApartmentState(ApartmentState.STA);
|
|
testThread.IsBackground = true;
|
|
testThread.Start();
|
|
testThread.Join(TimeSpan.FromSeconds(30));
|
|
|
|
Assert.IsFalse(testThread.IsAlive, "iPerl configuration read did not finish within 30 seconds.");
|
|
if (failure != null) throw failure;
|
|
}
|
|
|
|
private static void ReadConfiguration()
|
|
{
|
|
var headCfg = new IPerlHeadCfg(new IPerlHeadFactory())
|
|
{
|
|
Name = "iPerl1",
|
|
RfidComPortNr = RealRfidComPort,
|
|
OptoComPortNr = RealOptoComPort,
|
|
CommunicationInterface = RealCommunicationInterface
|
|
};
|
|
var head = new IPerlHead(headCfg)
|
|
{
|
|
DebugLevel = DebugMode.Normal
|
|
};
|
|
head.StartSession();
|
|
|
|
// The form initializes the same CfgIPerl and request pipeline that
|
|
// production iPerlCommunication uses. No form is shown to the user.
|
|
using (var form = new IPerlCommunicationForm(true))
|
|
{
|
|
byte[] buffer;
|
|
int result = IPerlCommunicationForm.ReadRequestPort(
|
|
head,
|
|
MessageID.Configuration,
|
|
StructName.Configuration,
|
|
0,
|
|
IPerlConfigStruct.Length,
|
|
out buffer);
|
|
|
|
Assert.AreEqual(0, result, "iPerlCommunicationForm could not read the meter Configuration.");
|
|
Assert.IsNotNull(buffer);
|
|
Assert.AreEqual(IPerlConfigStruct.Length, buffer.Length);
|
|
|
|
IPerlConfigStruct configuration = IPerlConfigStruct.FromByteArray(buffer);
|
|
Assert.IsNotNull(configuration);
|
|
Assert.IsFalse(string.IsNullOrWhiteSpace(configuration.GetPcbNrString()));
|
|
}
|
|
}
|
|
}
|
|
}
|