diff --git a/JiShe.CollectBus.Test/BusUnitTest.cs b/JiShe.CollectBus.Test/BusUnitTest.cs new file mode 100644 index 0000000..d57c0b8 --- /dev/null +++ b/JiShe.CollectBus.Test/BusUnitTest.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DnsClient.Internal; +using JiShe.CollectBus.Common.Enums; +using JiShe.CollectBus.Common.Extensions; +using JiShe.CollectBus.Common.Models; +using JiShe.CollectBus.Protocol.Contracts.Models; +using JiShe.CollectBus.RabbitMQ.Senders; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Moq; +using Xunit.Abstractions; + +namespace JiShe.CollectBus.Test +{ + public class BusUnitTest + { + private INSender _nSender; + + public BusUnitTest() + { + _nSender = new Mock().Object; + } + + [Fact] + public async void AmmeterParameterSend() + { + var listMeter = new List() + { + new() + { + Pn = 1, + BaudRate = 3, + Port = 2, + ProtocolType = CommunicationProtocolType.DLT6452007, + Address = "312408006642", + Password = "000000", + RateNumber = 4, + IntegerBitNumber = 4, + DecimalBitNumber = 4, + CollectorAddress = "000000000000", + UserCategoryNumber = 0, + UserSubclassNumber = 0 + } + }; + var bytes = HexStringExtensions.BuildAmmeterParameterSetSendCmd(new ReqParameter2() + { + AFN = AFN.设置参数, + FunCode = (int)CMasterStationFunCode.请求1级数据, + A = "322009872", + Seq = new Seq() + { + TpV = TpV.附加信息域中无时间标签, + FIRFIN = FIRFIN.单帧, + CON = CON.需要对该帧进行确认, + PRSEQ = 10, + }, + MSA = 13, + Pn = 0, + Fn = 10 + }, listMeter); + Assert.NotEmpty(bytes); + + await _nSender.SendToIssuedAsync(new MessageIssuedEvent { DeviceNo = "322009872", Message = bytes, Type = IssuedEventType.Data, MessageId = Guid.NewGuid().ToString() }); + } + + } +} diff --git a/JiShe.CollectBus.Test/JiShe.CollectBus.Test.csproj b/JiShe.CollectBus.Test/JiShe.CollectBus.Test.csproj index 0545227..51f7dd2 100644 --- a/JiShe.CollectBus.Test/JiShe.CollectBus.Test.csproj +++ b/JiShe.CollectBus.Test/JiShe.CollectBus.Test.csproj @@ -12,6 +12,7 @@ + diff --git a/JiShe.CollectBus.Test/UnitTest1.cs b/JiShe.CollectBus.Test/UnitTest1.cs deleted file mode 100644 index 8f2538d..0000000 --- a/JiShe.CollectBus.Test/UnitTest1.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestPlatform.TestHost; - -namespace JiShe.CollectBus.Test -{ - public class UnitTest1 - { - private readonly ILogger _logger; - - public UnitTest1(ILogger logger) - { - _logger = logger; - } - - [Fact] - public void Test1() - { - _logger.LogWarning("11111111"); - } - } -} \ No newline at end of file