Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

54 wiersze
2.6 KiB

  1. using JTNE.Protocol.MessageBody;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Xunit;
  6. using JTNE.Protocol.Extensions;
  7. namespace JTNE.Protocol.Test.MessageBody
  8. {
  9. public class JTNE_0x02_0x03_PlatformTest
  10. {
  11. [Fact]
  12. public void Test1()
  13. {
  14. JTNE_0x02_0x03_Platform jTNE_0X02_0X03_Platform = new JTNE_0x02_0x03_Platform();
  15. jTNE_0X02_0X03_Platform.DCStatus = 0x02;
  16. jTNE_0X02_0X03_Platform.FuelBatteryCurrent = 111;
  17. jTNE_0X02_0X03_Platform.FuelBatteryVoltage = 2222;
  18. jTNE_0X02_0X03_Platform.FuelConsumptionRate = 3222;
  19. jTNE_0X02_0X03_Platform.HydrogenSystemMaxConcentrations = 6666;
  20. jTNE_0X02_0X03_Platform.HydrogenSystemMaxConcentrationsNo = 0x56;
  21. jTNE_0X02_0X03_Platform.HydrogenSystemMaxPressure = 3336;
  22. jTNE_0X02_0X03_Platform.HydrogenSystemMaxPressureNo = 0x65;
  23. jTNE_0X02_0X03_Platform.HydrogenSystemMaxTemp = 3355;
  24. jTNE_0X02_0X03_Platform.HydrogenSystemMaxTempNo = 0x22;
  25. jTNE_0X02_0X03_Platform.Temperatures = new byte[]
  26. {
  27. 0x01,0x02,0x03
  28. };
  29. var hex = JTNESerializer_Platform.Serialize(jTNE_0X02_0X03_Platform).ToHexString();
  30. Assert.Equal("0308AE006F0C9600030102030D1B221A0A560D086502", hex);
  31. }
  32. [Fact]
  33. public void Test2()
  34. {
  35. var data = "0308AE006F0C9600030102030D1B221A0A560D086502".ToHexBytes();
  36. JTNE_0x02_0x03_Platform jTNE_0X02_0X03_Platform = JTNESerializer_Platform.Deserialize<JTNE_0x02_0x03_Platform>(data);
  37. Assert.Equal(JTNE_0x02_Body_Platform.JTNE_0x02_0x03_Platform, jTNE_0X02_0X03_Platform.TypeCode);
  38. Assert.Equal(0x02, jTNE_0X02_0X03_Platform.DCStatus);
  39. Assert.Equal(111, jTNE_0X02_0X03_Platform.FuelBatteryCurrent);
  40. Assert.Equal(2222, jTNE_0X02_0X03_Platform.FuelBatteryVoltage);
  41. Assert.Equal(3222, jTNE_0X02_0X03_Platform.FuelConsumptionRate);
  42. Assert.Equal(6666, jTNE_0X02_0X03_Platform.HydrogenSystemMaxConcentrations);
  43. Assert.Equal(0x56, jTNE_0X02_0X03_Platform.HydrogenSystemMaxConcentrationsNo);
  44. Assert.Equal(3336, jTNE_0X02_0X03_Platform.HydrogenSystemMaxPressure);
  45. Assert.Equal(0x65, jTNE_0X02_0X03_Platform.HydrogenSystemMaxPressureNo);
  46. Assert.Equal(3355, jTNE_0X02_0X03_Platform.HydrogenSystemMaxTemp);
  47. Assert.Equal(0x22, jTNE_0X02_0X03_Platform.HydrogenSystemMaxTempNo);
  48. Assert.Equal(new byte []{ 0x01, 0x02, 0x03 }, jTNE_0X02_0X03_Platform.Temperatures);
  49. }
  50. }
  51. }