public void GetUdpSessionAllTest() { var ch = WebExt.CreateEmbeddedChannel(serviceProvider => { var sessionMgr = serviceProvider.GetRequiredService <JT808SessionManager>(); sessionMgr.TryAdd(new EmbeddedChannel(), new IPEndPoint(IPAddress.Parse("127.0.0.1"), 888), "123456789"); }); ch.WriteInbound(WebExt.CreateGetRequest(JT808NettyConstants.JT808WebApiRouteTable.SessionUdpGetAll)); var result = ch.As <List <JT808UdpSessionInfoDto> >(); Assert.Single(result.Data); Assert.Equal("123456789", result.Data[0].TerminalPhoneNo); Assert.Equal(JT808ResultCode.Ok, result.Code); }
public void GetTcpAtomicCounterTest() { var ch = WebExt.CreateEmbeddedChannel(serviceProvider => { var counterFactory = serviceProvider.GetRequiredService <JT808AtomicCounterServiceFactory>(); var counter = counterFactory.Create(JT808TransportProtocolType.tcp); counter.MsgSuccessIncrement(); counter.MsgSuccessIncrement(); counter.MsgFailIncrement(); }); ch.WriteInbound(WebExt.CreateGetRequest(JT808NettyConstants.JT808WebApiRouteTable.GetTcpAtomicCounter)); var result = ch.As <JT808AtomicCounterDto>(); Assert.Equal(2, result.Data.MsgSuccessCount); Assert.Equal(1, result.Data.MsgFailCount); Assert.Equal(JT808ResultCode.Ok, result.Code); }