@@ -9,34 +9,40 @@ namespace KeeperData.Application.Tests.Unit.Orchestration.Imports.Sam.Mappings;
99
1010public class SamCommonLandMapperTests
1111{
12+ private static readonly Func < string ? , string ? , CancellationToken , Task < ( string ? , string ? , string ? ) > > NoopResolveCountry =
13+ ( _ , _ , _ ) => Task . FromResult < ( string ? , string ? , string ? ) > ( ( null , null , null ) ) ;
14+
15+ private static Func < string ? , string ? , CancellationToken , Task < ( string ? , string ? , string ? ) > > ResolveCountry ( string ? id , string ? code ) =>
16+ ( _ , _ , _ ) => Task . FromResult < ( string ? , string ? , string ? ) > ( ( id , code , null ) ) ;
17+
1218 [ Fact ]
13- public void ToSilver_WithNullInput_ShouldReturnEmptyList ( )
19+ public async Task ToSilver_WithNullInput_ShouldReturnEmptyList ( )
1420 {
1521 // Arrange
1622 List < SamCommonLand > ? rawCommonLands = null ;
1723
1824 // Act
19- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ! ) ;
25+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands ! , NoopResolveCountry , CancellationToken . None ) ;
2026
2127 // Assert
2228 result . Should ( ) . BeEmpty ( ) ;
2329 }
2430
2531 [ Fact ]
26- public void ToSilver_WithEmptyList_ShouldReturnEmptyList ( )
32+ public async Task ToSilver_WithEmptyList_ShouldReturnEmptyList ( )
2733 {
2834 // Arrange
2935 var rawCommonLands = new List < SamCommonLand > ( ) ;
3036
3137 // Act
32- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
38+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands , NoopResolveCountry , CancellationToken . None ) ;
3339
3440 // Assert
3541 result . Should ( ) . BeEmpty ( ) ;
3642 }
3743
3844 [ Fact ]
39- public void ToSilver_WithDefinitionRecordOnly_ShouldCreateSamHoldingDocument ( )
45+ public async Task ToSilver_WithDefinitionRecordOnly_ShouldCreateSamHoldingDocument ( )
4046 {
4147 // Arrange
4248 var now = DateTime . UtcNow ;
@@ -68,7 +74,10 @@ public void ToSilver_WithDefinitionRecordOnly_ShouldCreateSamHoldingDocument()
6874 } ;
6975
7076 // Act
71- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
77+ var result = await SamCommonLandMapper . ToSilver (
78+ rawCommonLands ,
79+ ResolveCountry ( "country-id-1" , "England" ) ,
80+ CancellationToken . None ) ;
7281
7382 // Assert
7483 result . Should ( ) . HaveCount ( 1 ) ;
@@ -88,14 +97,15 @@ public void ToSilver_WithDefinitionRecordOnly_ShouldCreateSamHoldingDocument()
8897 holding . Location . Northing . Should ( ) . Be ( 569204 ) ;
8998 holding . Location . Address . Should ( ) . NotBeNull ( ) ;
9099 holding . Location . Address ! . AddressLine . Should ( ) . Be ( "Land off Road" ) ;
91- holding . Location . Address . AddressLocality . Should ( ) . Be ( "Village" ) ;
92- holding . Location . Address . AddressStreet . Should ( ) . Be ( "District" ) ;
100+ holding . Location . Address . AddressStreet . Should ( ) . Be ( "Village" ) ;
101+ holding . Location . Address . AddressTown . Should ( ) . Be ( "District" ) ;
93102 holding . Location . Address . AddressPostCode . Should ( ) . Be ( "AB12 3CD" ) ;
94103 holding . Location . Address . CountryCode . Should ( ) . Be ( "England" ) ;
104+ holding . Location . Address . CountryIdentifier . Should ( ) . Be ( "country-id-1" ) ;
95105 }
96106
97107 [ Fact ]
98- public void ToSilver_WithDeletedRecord_ShouldMapDeletedStatus ( )
108+ public async Task ToSilver_WithDeletedRecord_ShouldMapDeletedStatus ( )
99109 {
100110 // Arrange
101111 var rawCommonLands = new List < SamCommonLand >
@@ -112,7 +122,7 @@ public void ToSilver_WithDeletedRecord_ShouldMapDeletedStatus()
112122 } ;
113123
114124 // Act
115- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
125+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands , NoopResolveCountry , CancellationToken . None ) ;
116126
117127 // Assert
118128 result . Should ( ) . HaveCount ( 1 ) ;
@@ -121,7 +131,7 @@ public void ToSilver_WithDeletedRecord_ShouldMapDeletedStatus()
121131 }
122132
123133 [ Fact ]
124- public void ToSilver_WithPlaceholderPremisesName_ShouldSetToNull ( )
134+ public async Task ToSilver_WithPlaceholderPremisesName_ShouldSetToNull ( )
125135 {
126136 // Arrange
127137 var rawCommonLands = new List < SamCommonLand >
@@ -136,14 +146,14 @@ public void ToSilver_WithPlaceholderPremisesName_ShouldSetToNull()
136146 } ;
137147
138148 // Act
139- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
149+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands , NoopResolveCountry , CancellationToken . None ) ;
140150
141151 // Assert
142152 result [ 0 ] . LocationName . Should ( ) . BeNull ( ) ;
143153 }
144154
145155 [ Fact ]
146- public void ToSilver_WithEmptyCommonCph_ShouldBeFiltered ( )
156+ public async Task ToSilver_WithEmptyCommonCph_ShouldBeFiltered ( )
147157 {
148158 // Arrange
149159 var rawCommonLands = new List < SamCommonLand >
@@ -163,14 +173,14 @@ public void ToSilver_WithEmptyCommonCph_ShouldBeFiltered()
163173 } ;
164174
165175 // Act
166- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
176+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands , NoopResolveCountry , CancellationToken . None ) ;
167177
168178 // Assert
169179 result . Should ( ) . BeEmpty ( ) ;
170180 }
171181
172182 [ Fact ]
173- public void ToSilver_WithInvalidEastingNorthing_ShouldSetToNull ( )
183+ public async Task ToSilver_WithInvalidEastingNorthing_ShouldSetToNull ( )
174184 {
175185 // Arrange
176186 var rawCommonLands = new List < SamCommonLand >
@@ -187,15 +197,15 @@ public void ToSilver_WithInvalidEastingNorthing_ShouldSetToNull()
187197 } ;
188198
189199 // Act
190- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
200+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands , NoopResolveCountry , CancellationToken . None ) ;
191201
192202 // Assert
193203 result [ 0 ] . Location ! . Easting . Should ( ) . BeNull ( ) ;
194204 result [ 0 ] . Location ! . Northing . Should ( ) . BeNull ( ) ;
195205 }
196206
197207 [ Fact ]
198- public void ToSilver_WithFutureDate_ShouldNormaliseToNull ( )
208+ public async Task ToSilver_WithFutureDate_ShouldNormaliseToNull ( )
199209 {
200210 // Arrange
201211 var rawCommonLands = new List < SamCommonLand >
@@ -216,7 +226,7 @@ public void ToSilver_WithFutureDate_ShouldNormaliseToNull()
216226 } ;
217227
218228 // Act
219- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
229+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands , NoopResolveCountry , CancellationToken . None ) ;
220230
221231 // Assert
222232 result [ 1 ] . AssociatedMainHoldings [ 0 ] . StartDate . Should ( ) . BeNull ( ) ;
@@ -376,7 +386,7 @@ public void ToAssociatedCommonLands_WithVariousDateFormats_ShouldNormaliseCorrec
376386 }
377387
378388 [ Fact ]
379- public void ToSilver_ShouldMapBusinessUsageToSourceFacilitySubBusinessActivityCode ( )
389+ public async Task ToSilver_ShouldMapBusinessUsageToSourceFacilitySubBusinessActivityCode ( )
380390 {
381391 // Arrange
382392 var rawCommonLands = new List < SamCommonLand >
@@ -392,15 +402,15 @@ public void ToSilver_ShouldMapBusinessUsageToSourceFacilitySubBusinessActivityCo
392402 } ;
393403
394404 // Act
395- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
405+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands , NoopResolveCountry , CancellationToken . None ) ;
396406
397407 // Assert
398408 result . Should ( ) . HaveCount ( 1 ) ;
399409 result [ 0 ] . SourceFacilitySubBusinessActivityCode . Should ( ) . Be ( "Common Land" ) ;
400410 }
401411
402412 [ Fact ]
403- public void ToSilver_ShouldMapSiteTypeCodeToCL ( )
413+ public async Task ToSilver_ShouldMapSiteTypeCodeToCL ( )
404414 {
405415 // Arrange
406416 var rawCommonLands = new List < SamCommonLand >
@@ -416,7 +426,7 @@ public void ToSilver_ShouldMapSiteTypeCodeToCL()
416426 } ;
417427
418428 // Act
419- var result = SamCommonLandMapper . ToSilver ( rawCommonLands ) ;
429+ var result = await SamCommonLandMapper . ToSilver ( rawCommonLands , NoopResolveCountry , CancellationToken . None ) ;
420430
421431 // Assert
422432 result . Should ( ) . HaveCount ( 1 ) ;
0 commit comments