63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
using CardReaderTester.Protocol.Enums;
|
|
using CardReaderTester.Protocol;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Diagnostics;
|
|
|
|
namespace CardReaderTester.Test
|
|
{
|
|
[TestClass]
|
|
public class IndicationRequest_Test
|
|
{
|
|
[TestMethod]
|
|
public void IndicationRequest_Granted_Create()
|
|
{
|
|
IndicationRequest indication = new()
|
|
{
|
|
SenderAddress = 0x00,
|
|
ReceiverAddress = 0x01,
|
|
Indication = RPIndication.GRANTED,
|
|
Time = new(500)
|
|
};
|
|
|
|
Assert.AreEqual(0x00, indication.SenderAddress);
|
|
Assert.AreEqual(0x01, indication.ReceiverAddress);
|
|
Assert.AreEqual(RPIndication.GRANTED, indication.Indication);
|
|
Assert.AreEqual<uint>(500, indication.Time.Value);
|
|
|
|
Debug.WriteLine(BitConverter.ToString(indication.CreateMessage().ToArray()));
|
|
|
|
CollectionAssert.AreEqual(new byte[] { 0x01 ,0x00, 0x00, 0x01, 0xF4 }, indication.CreateMessage());
|
|
|
|
Debug.WriteLine(BitConverter.ToString(RPMessage.CreateFrame(indication)));
|
|
|
|
CollectionAssert.AreEqual(new byte[] { 0x7E,0x04, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0xF4, 0xD0, 0x7F }, RPMessage.CreateFrame(indication));
|
|
|
|
Assert.AreEqual("IndicationRequest: sender:0 receiver:1 indication:GRANTED time:500", indication.LogString());
|
|
}
|
|
|
|
[TestMethod]
|
|
public void IndicationRequest_Granted_Parse()
|
|
{
|
|
byte[] bytes = [0x7E, 0x04, 0x00, 0x01, 0x01, 0x00, 0x00, 0x13, 0x88, 0xDE, 0x7F];
|
|
IRPProtocol? result = RPMessage.ParseMessage(bytes);
|
|
|
|
Assert.IsNotNull(result);
|
|
Assert.IsInstanceOfType<IndicationRequest>(result);
|
|
|
|
IndicationRequest indication = (IndicationRequest)result;
|
|
|
|
Assert.AreEqual(0x00, indication.SenderAddress);
|
|
Assert.AreEqual(0x01, indication.ReceiverAddress);
|
|
|
|
Assert.AreEqual(RPIndication.GRANTED, indication.Indication);
|
|
Assert.AreEqual<uint>(5000, indication.Time.Value);
|
|
|
|
Assert.AreEqual("IndicationRequest: sender:0 receiver:1 indication:GRANTED time:5000", indication.LogString());
|
|
}
|
|
}
|
|
}
|