11using Alba ;
22using Bogus ;
33using ECER . Clients . RegistryPortal . Server . ICRA ;
4+ using ECER . Clients . RegistryPortal . Server ;
45using Shouldly ;
56using System . Net ;
67using System . Net . Http . Headers ;
@@ -130,6 +131,17 @@ public async Task SaveDraftIcraEligibility_WithInternationalCertificationAndFile
130131
131132 var uploadedFileResponse = ( await fileResponse . ReadAsJsonAsync < ECER . Clients . RegistryPortal . Server . Files . FileResponse > ( ) ) . ShouldNotBeNull ( ) ;
132133
134+ var countriesResponse = await Host . Scenario ( _ =>
135+ {
136+ _ . WithExistingUser ( this . Fixture . AuthenticatedBcscUserIdentity , this . Fixture . AuthenticatedBcscUser ) ;
137+ _ . Get . Url ( "/api/countrylist" ) ;
138+ _ . StatusCodeShouldBeOk ( ) ;
139+ } ) ;
140+
141+ var countries = await countriesResponse . ReadAsJsonAsync < Country [ ] > ( ) ;
142+ countries . ShouldNotBeNull ( ) ;
143+ var countryId = countries . FirstOrDefault ( c => c . IsICRA ) ? . CountryId ?? countries . First ( ) . CountryId ;
144+
133145 var eligibility = new ICRAEligibility
134146 {
135147 Status = ICRAStatus . Draft ,
@@ -141,6 +153,7 @@ public async Task SaveDraftIcraEligibility_WithInternationalCertificationAndFile
141153 CertificateTitle = faker . Company . CatchPhrase ( ) ,
142154 IssueDate = faker . Date . Past ( ) ,
143155 ExpiryDate = faker . Date . Soon ( ) ,
156+ CountryId = countryId ,
144157 NewFiles = new [ ] { uploadedFileResponse . fileId }
145158 }
146159 }
@@ -168,5 +181,6 @@ public async Task SaveDraftIcraEligibility_WithInternationalCertificationAndFile
168181 fetched . InternationalCertifications . ShouldHaveSingleItem ( ) ;
169182 fetched . InternationalCertifications . First ( ) . Files . ShouldHaveSingleItem ( ) ;
170183 fetched . InternationalCertifications . First ( ) . Files . First ( ) . Id ! . ShouldContain ( uploadedFileResponse . fileId ) ;
184+ fetched . InternationalCertifications . First ( ) . CountryId . ShouldBe ( countryId ) ;
171185 }
172186}
0 commit comments