Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

77 lignes
3.3 KiB

  1. using JT808.DotNetty.Core;
  2. using JT808.DotNetty.Core.Interfaces;
  3. using JT808.Protocol;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Net;
  7. using System.Text;
  8. using System.Threading;
  9. using Microsoft.Extensions.DependencyInjection;
  10. using JT808.Protocol.Extensions;
  11. using Microsoft.VisualStudio.TestTools.UnitTesting;
  12. using JT808.Protocol.MessageBody;
  13. using JT808.DotNetty.Abstractions.Dtos;
  14. namespace JT808.DotNetty.Tcp.Test
  15. {
  16. [TestClass]
  17. public class JT808UnificationTcpSendServiceTest: TestBase
  18. {
  19. static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6565);
  20. private IJT808UnificationTcpSendService jT808UnificationTcpSendService;
  21. private IJT808TcpSessionService jT808SessionServiceDefaultImpl;
  22. public JT808UnificationTcpSendServiceTest()
  23. {
  24. JT808SimpleTcpClient SimpleTcpClient1 = new JT808SimpleTcpClient(endPoint);
  25. JT808SimpleTcpClient SimpleTcpClient2 = new JT808SimpleTcpClient(endPoint);
  26. JT808SimpleTcpClient SimpleTcpClient3 = new JT808SimpleTcpClient(endPoint);
  27. JT808SimpleTcpClient SimpleTcpClient4 = new JT808SimpleTcpClient(endPoint);
  28. JT808SimpleTcpClient SimpleTcpClient5 = new JT808SimpleTcpClient(endPoint);
  29. // 心跳会话包
  30. JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001");
  31. SimpleTcpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1));
  32. // 心跳会话包
  33. JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002");
  34. SimpleTcpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2));
  35. // 心跳会话包
  36. JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003");
  37. SimpleTcpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3));
  38. // 心跳会话包
  39. JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004");
  40. SimpleTcpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4));
  41. // 心跳会话包
  42. JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005");
  43. SimpleTcpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5));
  44. Thread.Sleep(300);
  45. }
  46. [TestMethod]
  47. public void Test1()
  48. {
  49. jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808TcpSessionService>();
  50. jT808UnificationTcpSendService = ServiceProvider.GetService<IJT808UnificationTcpSendService>();
  51. jT808SessionServiceDefaultImpl.GetAll();
  52. string no = "123456789001";
  53. // 文本信息包
  54. JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.文本信息下发.Create(no, new JT808_0x8300
  55. {
  56. TextFlag = 5,
  57. TextInfo = "smallchi 518"
  58. });
  59. var data = JT808Serializer.Serialize(jT808Package2);
  60. JT808ResultDto<bool> jt808Result = jT808UnificationTcpSendService.Send(no, data);
  61. Thread.Sleep(1000);
  62. Assert.AreEqual(200, jt808Result.Code);
  63. Assert.IsTrue(jt808Result.Data);
  64. }
  65. }
  66. }