You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.6 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Xunit;
  5. using JT809.Protocol;
  6. using JT809.Protocol.Extensions;
  7. using JT809.Protocol.MessageBody;
  8. using JT809.Protocol.Exceptions;
  9. using JT809.Protocol.SubMessageBody;
  10. using JT809.Protocol.Enums;
  11. namespace JT809.Protocol.Test.JT809SubMessageBody
  12. {
  13. public class JT809_0x1300_0x1301Test
  14. {
  15. private JT809Serializer JT809Serializer = new JT809Serializer();
  16. [Fact]
  17. public void Test1()
  18. {
  19. JT809_0x1300_0x1301 jT809_0x1300_0x1301 = new JT809_0x1300_0x1301
  20. {
  21. ObjectID = "111",
  22. InfoContent = "22ha22",
  23. InfoID = 1234,
  24. ObjectType = JT809_0x1301_ObjectType.当前连接的下级平台
  25. };
  26. var hex = JT809Serializer.Serialize(jT809_0x1300_0x1301).ToHexString();
  27. //"01 31 31 31 00 00 00 00 00 00 00 00 00 00 00 04 D2 00 00 00 06 32 32 68 61 32 32"
  28. Assert.Equal("01313131000000000000000000000004D200000006323268613232", hex);
  29. }
  30. [Fact]
  31. public void Test2()
  32. {
  33. var bytes = "01 31 31 31 00 00 00 00 00 00 00 00 00 00 00 04 D2 00 00 00 06 32 32 68 61 32 32".ToHexBytes();
  34. JT809_0x1300_0x1301 jT809_0x1300_0x1301 = JT809Serializer.Deserialize<JT809_0x1300_0x1301>(bytes);
  35. Assert.Equal("111", jT809_0x1300_0x1301.ObjectID);
  36. Assert.Equal("22ha22", jT809_0x1300_0x1301.InfoContent);
  37. Assert.Equal((uint)1234, jT809_0x1300_0x1301.InfoID);
  38. Assert.Equal(JT809_0x1301_ObjectType.当前连接的下级平台, jT809_0x1300_0x1301.ObjectType);
  39. }
  40. }
  41. }