tbf/NfcC7_DLL.Tests/NfcHanler/NFCHeadServiceTest.cs
Michal Buzik 320cddb177 compatible version to TBF
Refactor `NfcHanler` namespace to `NfcHandler` and enhance code consistency.
2025-10-29 16:05:21 +01:00

88 lines
2.7 KiB
C#

using System;
using JetBrains.Annotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NfcC7_DLL.NfcHandler;
using NfcC7_DLL.NfcHandler.Protocols;
using NfcC7_DLL.NfcHandler.Utils;
using NfcC7_DLL.NfcHandler;
namespace NfcC7_DLL.Tests.NfcHanler;
[TestClass]
[TestSubject(typeof(NfcHeadService))]
public class NfcHeadServiceTest
{
[TestMethod]
public void SetTestingMode_Optohead_C7_ON_LiveMeterTest()
{
SerialPortData serialPortData = new SerialPortData(
"COM5",
"HatCliDemo.exe",
74);
NfcHeadService service = new NfcHeadService(serialPortData);
OptoHeadStatus status = service.SetTestingMode(OptoHeadStatus.OptoHeadC7);
Assert.AreEqual(OptoHeadStatus.OptoHeadC7, status);
}
[TestMethod]
public void SetTestingMode_Optohead_OFF_LiveMeterTest()
{
SerialPortData serialPortData = new SerialPortData(
"COM5",
"HatCliDemo.exe",
74);
NfcHeadService service = new NfcHeadService(serialPortData);
OptoHeadStatus status = service.SetTestingMode(OptoHeadStatus.OptoHeadDisabled);
Assert.AreEqual(OptoHeadStatus.OptoHeadDisabled, status);
}
[TestMethod]
public void SetTestingMode_LiveMeterTest()
{
SerialPortData serialPortData = new SerialPortData(
"COM5",
"HatCliDemo.exe",
74);
NfcHeadService service = new NfcHeadService(serialPortData);
OptoHeadStatus status = service.SetTestingMode(OptoHeadStatus.OptoHeadC2);
Assert.AreEqual(OptoHeadStatus.OptoHeadC2, status);
status = service.SetTestingMode(OptoHeadStatus.OptoHeadC7);
Assert.AreEqual(OptoHeadStatus.OptoHeadC7, status);
status = service.SetTestingMode(OptoHeadStatus.OptoHeadDisabled);
Assert.AreEqual(OptoHeadStatus.OptoHeadDisabled, status);
}
[TestMethod]
public void GetSerialNr_LiveMeterTest()
{
SerialPortData serialPortData = new SerialPortData(
"COM5",
"HatCliDemo.exe",
74);
NfcHeadService service = new NfcHeadService(serialPortData);
string? serialNr = service.GetSerialNr();
Assert.IsFalse(string.IsNullOrEmpty(serialNr));
Console.WriteLine("Found serial no: {0}",serialNr);
}
[TestMethod]
public void GetTestingMode_LiveMeterTest()
{
SerialPortData serialPortData = new SerialPortData(
"COM5",
"HatCliDemo.exe",
74);
NfcHeadService service = new NfcHeadService(serialPortData);
OptoHeadStatus status = service.GetTestingMode();
Assert.IsFalse(OptoHeadStatus.Unknown == status);
}
}