2024-11-13 17:50:52 +08:00

72 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JiShe.CollectBus.Common.Enums;
using JiShe.CollectBus.Common.Extensions;
using JiShe.CollectBus.Common.Models;
using JiShe.CollectBus.MQ.Sender;
using JiShe.CollectBus.Protocol.Contracts.Models;
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<INSender>().Object;
}
[Fact]
public async void AmmeterParameterSend()
{
var listMeter = new List<AmmeterParameter>()
{
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() });
}
}
}