Пример #1
0
 public CallHttpClientJob(
     ILoggerFactory loggerFactory,
     JT808HttpClient jT808HttpClient)
 {
     Logger = loggerFactory.CreateLogger <CallHttpClientJob>();
     this.jT808HttpClient = jT808HttpClient;
 }
        public void RemoveSessionByTerminalPhoneNoTest()
        {
            JT808ResultDto <bool> jT808ResultDto = new JT808ResultDto <bool>();

            jT808ResultDto.Data = true;
            jT808ResultDto.Code = 200;
            JT808HttpClient jT808HttpClient = new JT808HttpClient(CreateHttpClient(JT808NettyConstants.JT808WebApiRouteTable.SessionRemoveByTerminalPhoneNo, "123456789", JsonSerializer.Serialize(jT808ResultDto)));
            var             result          = jT808HttpClient.RemoveByTerminalPhoneNo("123456789");

            Assert.Equal(jT808ResultDto.Code, result.Code);
            Assert.Equal(jT808ResultDto.Data, result.Data);
        }
        public void GetTcpAtomicCounterTest()
        {
            JT808ResultDto <JT808AtomicCounterDto> jT808ResultDto = new JT808ResultDto <JT808AtomicCounterDto>();

            jT808ResultDto.Data = new JT808AtomicCounterDto {
                MsgFailCount    = 9,
                MsgSuccessCount = 10
            };
            jT808ResultDto.Code = 200;
            JT808HttpClient jT808HttpClient = new JT808HttpClient(CreateHttpClient(JT808NettyConstants.JT808WebApiRouteTable.GetTcpAtomicCounter, "", JsonSerializer.Serialize(jT808ResultDto)));
            var             result          = jT808HttpClient.GetTcpAtomicCounter();

            Assert.Equal(jT808ResultDto.Code, result.Code);
            Assert.Equal(jT808ResultDto.Data.MsgFailCount, result.Data.MsgFailCount);
            Assert.Equal(jT808ResultDto.Data.MsgSuccessCount, result.Data.MsgSuccessCount);
        }
        public void UnificationSendTest()
        {
            JT808ResultDto <bool> jT808ResultDto = new JT808ResultDto <bool>();

            jT808ResultDto.Data = true;
            jT808ResultDto.Code = 200;
            JT808UnificationSendRequestDto jT808UnificationSendRequestDto = new JT808UnificationSendRequestDto
            {
                TerminalPhoneNo = "123456789",
                Data            = new byte[] { 1, 2, 3, 4 }
            };
            JT808HttpClient jT808HttpClient = new JT808HttpClient(CreateHttpClient(JT808NettyConstants.JT808WebApiRouteTable.UnificationSend, JsonSerializer.Serialize(jT808UnificationSendRequestDto), JsonSerializer.Serialize(jT808ResultDto)));
            var             result          = jT808HttpClient.UnificationSend(jT808UnificationSendRequestDto);

            Assert.Equal(jT808ResultDto.Code, result.Code);
            Assert.Equal(jT808ResultDto.Data, result.Data);
        }
        public void GetTcpSessionAllTest()
        {
            JT808ResultDto <List <JT808TcpSessionInfoDto> > jT808ResultDto = new JT808ResultDto <List <JT808TcpSessionInfoDto> >();

            jT808ResultDto.Data = new List <JT808TcpSessionInfoDto>();
            jT808ResultDto.Code = 200;
            jT808ResultDto.Data.Add(new JT808TcpSessionInfoDto {
                LastActiveTime  = DateTime.Parse("2019-10-29 23:23:23"),
                StartTime       = DateTime.Parse("2019-10-29 23:23:23"),
                RemoteAddressIP = "127.0.0.1:555",
                TerminalPhoneNo = "123456789"
            });
            JT808HttpClient jT808HttpClient = new JT808HttpClient(CreateHttpClient(JT808NettyConstants.JT808WebApiRouteTable.SessionTcpGetAll, "", JsonSerializer.Serialize(jT808ResultDto)));
            var             result          = jT808HttpClient.GetTcpSessionAll();

            Assert.Equal(jT808ResultDto.Code, result.Code);
            Assert.Equal(jT808ResultDto.Data[0].TerminalPhoneNo, result.Data[0].TerminalPhoneNo);
            Assert.Equal(jT808ResultDto.Data[0].StartTime, result.Data[0].StartTime);
            Assert.Equal(jT808ResultDto.Data[0].LastActiveTime, result.Data[0].LastActiveTime);
            Assert.Equal(jT808ResultDto.Data[0].RemoteAddressIP, result.Data[0].RemoteAddressIP);
        }
        public void GetTcpSessionAllLargeTest()
        {
            JT808ResultDto <List <JT808TcpSessionInfoDto> > jT808ResultDto = new JT808ResultDto <List <JT808TcpSessionInfoDto> >();

            jT808ResultDto.Data = new List <JT808TcpSessionInfoDto>();
            jT808ResultDto.Code = 200;
            for (var i = 0; i < 50000; i++)
            {
                jT808ResultDto.Data.Add(new JT808TcpSessionInfoDto
                {
                    LastActiveTime  = DateTime.Parse("2019-10-29 23:23:23"),
                    StartTime       = DateTime.Parse("2019-10-29 23:23:23"),
                    RemoteAddressIP = "127.0.0.1:555",
                    TerminalPhoneNo = (i + 1).ToString()
                });
            }
            JT808HttpClient jT808HttpClient = new JT808HttpClient(CreateHttpClient(JT808NettyConstants.JT808WebApiRouteTable.SessionTcpGetAll, "", JsonSerializer.Serialize(jT808ResultDto)));
            var             result          = jT808HttpClient.GetTcpSessionAll();

            Assert.Equal(jT808ResultDto.Code, result.Code);
            Assert.Equal(50000, result.Data.Count);
        }