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