From 8d2bb4324c917825f8fc1fb89e949bb3088263f3 Mon Sep 17 00:00:00 2001 From: yedajiang44 <602830483@qq.com> Date: Sat, 20 May 2023 10:02:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=BB=98=E8=AE=A4=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E5=8F=B7=E7=94=9F=E6=88=90=E5=99=A8=E6=9C=AA=E8=87=AA?= =?UTF-8?q?=E5=A2=9E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Internal/JT808MsgSNDistributedTest.cs | 15 ++++++++------- .../Internal/DefaultMsgSNDistributedImpl.cs | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/JT808.Protocol.Test/Internal/JT808MsgSNDistributedTest.cs b/src/JT808.Protocol.Test/Internal/JT808MsgSNDistributedTest.cs index 7f6b216..d658d25 100644 --- a/src/JT808.Protocol.Test/Internal/JT808MsgSNDistributedTest.cs +++ b/src/JT808.Protocol.Test/Internal/JT808MsgSNDistributedTest.cs @@ -1,8 +1,8 @@ -using JT808.Protocol.Interfaces; -using JT808.Protocol.Internal; -using System; +using System; using System.Collections.Generic; using System.Text; +using JT808.Protocol.Interfaces; +using JT808.Protocol.Internal; using Xunit; namespace JT808.Protocol.Test.Internal @@ -13,10 +13,11 @@ namespace JT808.Protocol.Test.Internal public void Test1() { IJT808MsgSNDistributed JT808MsgSNDistributed = new DefaultMsgSNDistributedImpl(); - var a=JT808MsgSNDistributed.Increment("1234"); - Assert.Equal(0, a); - var a1 = JT808MsgSNDistributed.Increment("1234"); - Assert.Equal(1, a1); + for (int i = 0; i < 10; i++) + { + var a = JT808MsgSNDistributed.Increment("1234"); + Assert.Equal(i, a); + } } } } diff --git a/src/JT808.Protocol/Internal/DefaultMsgSNDistributedImpl.cs b/src/JT808.Protocol/Internal/DefaultMsgSNDistributedImpl.cs index f978d77..d4e607c 100644 --- a/src/JT808.Protocol/Internal/DefaultMsgSNDistributedImpl.cs +++ b/src/JT808.Protocol/Internal/DefaultMsgSNDistributedImpl.cs @@ -14,8 +14,8 @@ namespace JT808.Protocol.Internal { if (counterDict.TryGetValue(terminalPhoneNo, out ushort value)) { - ushort newValue = ++value; - counterDict.TryUpdate(terminalPhoneNo, newValue, value); + ushort newValue = value; + counterDict.TryUpdate(terminalPhoneNo, ++newValue, value); return newValue; } else