Ver código fonte

修复默认流水号生成器未自增问题

tags/v2.6.2
yedajiang44 2 anos atrás
pai
commit
8d2bb4324c
2 arquivos alterados com 10 adições e 9 exclusões
  1. +8
    -7
      src/JT808.Protocol.Test/Internal/JT808MsgSNDistributedTest.cs
  2. +2
    -2
      src/JT808.Protocol/Internal/DefaultMsgSNDistributedImpl.cs

+ 8
- 7
src/JT808.Protocol.Test/Internal/JT808MsgSNDistributedTest.cs Ver arquivo

@@ -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);
}
}
}
}

+ 2
- 2
src/JT808.Protocol/Internal/DefaultMsgSNDistributedImpl.cs Ver arquivo

@@ -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


Carregando…
Cancelar
Salvar