Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit dddb8ef

Browse files
authored
test: Add NBSS appointment event test data builder (#18)
1 parent 7a592a1 commit dddb8ef

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

src/ServiceLayer.Mesh/FileTypes/NbssAppointmentEvents/Models/ParsedFile.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ public class ParsedFile
44
{
55
public FileHeaderRecord? FileHeader { get; set; }
66
public FileTrailerRecord? FileTrailer { get; set; }
7-
public required List<string> ColumnHeadings { get; set; } = [];
87
public required List<FileDataRecord> DataRecords { get; set; } = [];
98
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using ServiceLayer.Mesh.FileTypes.NbssAppointmentEvents.Models;
2+
3+
namespace ServiceLayer.Mesh.Tests.FileTypes.NbssAppointmentEvents;
4+
5+
public static class TestDataBuilder
6+
{
7+
public static ParsedFile BuildValidParsedFile(int numberOfRecords = 3)
8+
{
9+
var header = new FileHeaderRecord
10+
{
11+
RecordTypeIdentifier = "NBSSAPPT_HDR",
12+
ExtractId = "00000107",
13+
TransferStartDate = "20250519",
14+
TransferStartTime = "153806",
15+
RecordCount = numberOfRecords.ToString()
16+
};
17+
18+
var trailer = new FileTrailerRecord
19+
{
20+
RecordTypeIdentifier = "NBSSAPPT_END",
21+
ExtractId = "00000107",
22+
TransferEndDate = "20250519",
23+
TransferEndTime = "153957",
24+
RecordCount = numberOfRecords.ToString()
25+
};
26+
27+
var dataRecords = Enumerable.Range(1, numberOfRecords)
28+
.Select(BuildValidFileDataRecord)
29+
.ToList();
30+
31+
return new ParsedFile
32+
{
33+
FileHeader = header,
34+
FileTrailer = trailer,
35+
DataRecords = dataRecords
36+
};
37+
}
38+
39+
public static FileDataRecord BuildValidFileDataRecord(int rowNumber = 1)
40+
{
41+
return new FileDataRecord
42+
{
43+
RowNumber = rowNumber,
44+
Fields =
45+
{
46+
["NBSSAPPT_FLDS"] = "NBSSAPPT_DATA",
47+
["Sequence"] = rowNumber.ToString("D6"),
48+
["BSO"] = "KMK",
49+
["Action"] = "B",
50+
["Clinic Code"] = "BU003",
51+
["Holding Clinic"] = "N",
52+
["Status"] = "B",
53+
["Attended Not Scr"] = "",
54+
["Appointment ID"] = "BU003-67291-RA1-DN-T1130-1",
55+
["NHS Num"] = "9111104716",
56+
["Episode Type"] = "F",
57+
["Episode Start"] = "20250317",
58+
["Batch ID"] = "KMK001334",
59+
["Screen or Asses"] = "S",
60+
["Screen Appt num"] = "1",
61+
["Booked By"] = "H",
62+
["Cancelled By"] = "",
63+
["Appt Date"] = "20250327",
64+
["Appt Time"] = "1130",
65+
["Location"] = "BU",
66+
["Clinic Name"] = "BREAST CARE UNIT",
67+
["Clinic Name (Let)"] = "BREAST CARE UNIT",
68+
["Clinic Address 1"] = "BREAST CARE UNIT",
69+
["Clinic Address 2"] = "MILTON KEYNES HOSPITAL",
70+
["Clinic Address 3"] = "STANDING WAY",
71+
["Clinic Address 4"] = "MILTON KEYNES",
72+
["Clinic Address 5"] = "MK6 5LD",
73+
["Postcode"] = "MK6 5LD",
74+
["Action Timestamp"] = "20250317-132635",
75+
}
76+
};
77+
}
78+
79+
public static FileDataRecord BuildFileDataRecordWithField(string fieldName, string? fieldValue, int rowNumber = 1)
80+
{
81+
var fileDataRecord = BuildValidFileDataRecord(rowNumber);
82+
83+
if (fieldValue == null)
84+
{
85+
fileDataRecord.Fields.Remove(fieldName);
86+
}
87+
else
88+
{
89+
fileDataRecord.Fields[fieldName] = fieldValue;
90+
}
91+
92+
return fileDataRecord;
93+
}
94+
}

0 commit comments

Comments
 (0)