-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6fbbc1
commit 176f9d8
Showing
30 changed files
with
4,850 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using JT905.Protocol.Internal; | ||
using JT905.Protocol.SerialPort; | ||
|
||
namespace JT905.Protocol.Test.SerialPort; | ||
|
||
public class BaseTest | ||
{ | ||
protected JT905Serializer jt905Serializer = new(new DefaultGlobalConfig()); | ||
protected readonly SerialPortSerializer serializer = new(); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/JT905.Protocol.Test/SerialPort/Taximeter_0x0000_Down_Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using JT905.Protocol.Extensions; | ||
using JT905.Protocol.SerialPort; | ||
using JT905.Protocol.SerialPort.Taximeter; | ||
using Xunit; | ||
|
||
namespace JT905.Protocol.Test.SerialPort; | ||
|
||
public class Taximeter_0x0000_Down_Test : BaseTest | ||
{ | ||
[Theory] | ||
[InlineData("55AA000B02000000201111111111112955AA")] | ||
public void Test1(string hex) | ||
{ | ||
var package = new SerialPortPackage | ||
{ | ||
Device = 2, | ||
ManufacturerIdentify = 0, | ||
Body = new Taximeter_0x0000_Down | ||
{ | ||
DateTime = DateTime.Parse("2011-11-11 11:11:11") | ||
} | ||
}; | ||
var data = serializer.Serialize(package); | ||
Assert.Equal(hex, data.ToHexString()); | ||
} | ||
|
||
[Theory] | ||
[InlineData("55AA000B02000000201111111111112955AA")] | ||
public void Test2(string hex) | ||
{ | ||
var package = serializer.Deserialize(hex.ToHexBytes(), IBody.Types.Down); | ||
Assert.NotNull(package); | ||
Assert.Equal(11, package.Length); | ||
Assert.Equal(2, package.Device); | ||
Assert.Equal(0, package.ManufacturerIdentify); | ||
Assert.Equal(0, package.MessageId); | ||
var body = package.Body; | ||
Assert.NotNull(body); | ||
Assert.IsType<Taximeter_0x0000_Down>(body); | ||
var _0X0000_Down = body as Taximeter_0x0000_Down; | ||
Assert.Equal(DateTime.Parse("2011-11-11 11:11:11"), _0X0000_Down.DateTime); | ||
Assert.Equal(0x29, package.CheckCode); | ||
} | ||
} |
Oops, something went wrong.