📄
lib/tests/DltFileTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System; using System.IO; using System.Linq; using System.Threading.Tasks; using SharpDlt.Payloads; using Shouldly; using Xunit; namespace SharpDlt.Tests; /// <summary>Parses a real world DLT file recorded by a target.</summary> public class DltFileTests { private static string DataPath(string fileName) => Path.Combine(AppContext.BaseDirectory, "Data", fileName); [Fact] public void ReadMessages_Issue24File_ReducesTruncatedNumericArgument() { // The last numeric argument of the payload does not have enough bytes for its // declared type, so it is reduced to the next smaller type, like DLT Viewer does. var messages = DltReader.ReadMessages(DataPath("issue24.dlt")).ToList(); var message = messages.ShouldHaveSingleItem(); message.IsVerbose.ShouldBeTrue(); var arguments = message.VerbosePayload.ShouldNotBeNull().Arguments; arguments.Count.ShouldBe(2); arguments[0].ShouldBe(new DltStringArgument("HIST: SCU_RSTSTAT:", DltStringCoding.Ascii)); arguments[1].ShouldBe(new DltUnsignedArgument(65536, DltIntegerWidth.Bits32)); } [Fact] public async Task ReadMessagesAsync_Issue24File_YieldsTheSameMessages() { var sync = DltReader.ReadMessages(DataPath("issue24.dlt")).ToList(); var async = await DltReader.ReadMessagesAsync(DataPath("issue24.dlt")).ToListAsync(); async.ShouldBe(sync); } }