UnitTest1.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using FuRen_Sinopec_IcCardReader;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using Edge.Core.Parser.BinaryParser.Util;
  4. using System.Linq;
  5. namespace FuRen_Sinopec_IcCardReader_Test
  6. {
  7. [TestClass]
  8. public class UnitTest1
  9. {
  10. [TestMethod]
  11. public void Deserialize_TestMethod0()
  12. {
  13. var raw = "FA 00 E0 68 " +
  14. "00 17 " +
  15. "30 " +
  16. "20 19 12 24 23 02 31 00 01 01 01 01 F4 02 00 00 C0 3D";
  17. var rawBytes = raw.ToBytes();
  18. var p = new FuRen_Sinopec_IcCardReader.Parser();
  19. var incoming = p.Deserialize(rawBytes.ToArray()) as PumpGenericInquiryCommand;
  20. Assert.AreEqual(true, incoming != null, "Should have type of message: PumpGenericInquiryCommand");
  21. }
  22. [TestMethod]
  23. public void Deserialize_TestMethod3()
  24. {
  25. var raw = "FA 00 E0 43 " +
  26. "00 17 " +
  27. "30 " +
  28. "20 19 12 24 23 04 08 00 01 01 01 01 F4 02 00 00 85 D1";
  29. var rawBytes = raw.ToBytes();
  30. var p = new FuRen_Sinopec_IcCardReader.Parser();
  31. var incoming = p.Deserialize(rawBytes.ToArray()) as PumpGenericInquiryCommand;
  32. Assert.AreEqual(true, incoming != null, "Should have type of message: PumpGenericInquiryCommand");
  33. }
  34. [TestMethod]
  35. public void Deserialize_TestMethod4()
  36. {
  37. /* handle 0x31 with none sub message*/
  38. var raw = " FA E0 00 4E 00 02 31 00 90 3D";
  39. var rawBytes = raw.ToBytes();
  40. var p = new FuRen_Sinopec_IcCardReader.Parser();
  41. var incoming = p.Deserialize(rawBytes.ToArray()) as PumpStateChangeCommand;
  42. var explain = incoming.ToLogString();
  43. Assert.AreEqual(true, incoming != null, "Should have type of message: PumpStateChangeRequest");
  44. }
  45. [TestMethod]
  46. public void Deserialize_TestMethod5()
  47. {
  48. /* handle 0x31 with only card inserted sub message*/
  49. var raw = "FA E0 00 50 00 21 " +
  50. "31 " +
  51. "01 01" +
  52. "07 10 01 02 04 00 00 26 24 23 99 27 00 00 00 09" +
  53. "FD D0 4F 71";
  54. var rawBytes = raw.ToBytes();
  55. var p = new FuRen_Sinopec_IcCardReader.Parser();
  56. var incoming = p.Deserialize(rawBytes.ToArray()) as PumpStateChangeCommand;
  57. var explain = incoming.ToLogString();
  58. Assert.AreEqual(true, incoming != null, "Should have type of message: PumpStateChangeRequest");
  59. }
  60. [TestMethod]
  61. public void Deserialize_TestMethod6()
  62. {
  63. /* handle 0x31 with only nozzle operating sub message*/
  64. var raw = "FA E0 00 43 00 13 " +
  65. "31 " +
  66. "01 02 07 00 00 07 CD 00 01 21 02 B3 0A 27";
  67. var rawBytes = raw.ToBytes();
  68. var p = new FuRen_Sinopec_IcCardReader.Parser();
  69. var incoming = p.Deserialize(rawBytes.ToArray()) as PumpStateChangeCommand;
  70. var explain = incoming.ToLogString();
  71. Assert.AreEqual(true, incoming != null, "Should have type of message: PumpStateChangeRequest");
  72. }
  73. [TestMethod]
  74. public void Deserialize_TestMethod8()
  75. {
  76. var raw = "FA E0 00 44 00 96 " +
  77. "32 " +
  78. "00 00 58 AF 10 20 19" +
  79. "12 24 23 03 34 01 02 04 00 00 26 24 23 99 27" +
  80. "00 09 F6 03 00 07 CD 00 00 00 00 00 00 00 00" +
  81. "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" +
  82. "00 00 00 00 00 00 00 00 00 00 00 00 00 00 07" +
  83. "10 52 00 01 21 02 B3 00 01 48 E5 E3 00 00 00" +
  84. "00 00 00 00 00 00 00 00 00 00 00 00 58 01";
  85. var rawBytes = raw.ToBytes();
  86. var p = new FuRen_Sinopec_IcCardReader.Parser();
  87. var incoming = p.Deserialize(rawBytes.ToArray()) as PumpNotifyTransactionDoneCommand;
  88. var explain = incoming.ToLogString();
  89. Assert.AreEqual(true, incoming != null, "Should have type of message: PumpNotifyTransactionDoneRequest");
  90. }
  91. [TestMethod]
  92. public void Deserialize_TestMethod11()
  93. {
  94. var raw = "FA E0 00 44 " +
  95. "00 96 " +
  96. "32 00 00 58 AF 10 20 19 12 24 23 03 34 01 02 04 00 00 26 24 23 99 27 00 09 F6 03 00 07 CD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 10 52 00 01 21 02 B3 00 01 48 E5 E3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 01";
  97. var rawBytes = raw.ToBytes();
  98. var p = new FuRen_Sinopec_IcCardReader.Parser();
  99. var incoming = p.Deserialize(rawBytes.ToArray()) as PumpNotifyTransactionDoneCommand;
  100. var explain = incoming.ToLogString();
  101. Assert.AreEqual(true, incoming != null, "Should have type of message: PumpNotifyTransactionDoneRequest");
  102. }
  103. }
  104. }