@@ -145,6 +145,130 @@ await Host.Scenario(_ =>
145145 } ) ;
146146 }
147147
148+ [ Fact ]
149+ public async Task GetIcraEligibilityStatus_BadId_ReturnsBadRequest ( )
150+ {
151+ await Host . Scenario ( _ =>
152+ {
153+ _ . WithExistingUser ( this . Fixture . AuthenticatedBcscUserIdentity , this . Fixture . AuthenticatedBcscUser ) ;
154+ _ . Get . Url ( $ "/api/icra/not-a-guid/status") ;
155+ _ . StatusCodeShouldBe ( HttpStatusCode . BadRequest ) ;
156+ } ) ;
157+ }
158+
159+ [ Fact ]
160+ public async Task GetIcraEligibilityStatus_NotFound_ReturnsNotFound ( )
161+ {
162+ var invalidId = Guid . NewGuid ( ) . ToString ( ) ;
163+ await Host . Scenario ( _ =>
164+ {
165+ _ . WithExistingUser ( this . Fixture . AuthenticatedBcscUserIdentity , this . Fixture . AuthenticatedBcscUser ) ;
166+ _ . Get . Url ( $ "/api/icra/{ invalidId } /status") ;
167+ _ . StatusCodeShouldBe ( HttpStatusCode . NotFound ) ;
168+ } ) ;
169+ }
170+
171+ [ Fact ]
172+ public async Task GetIcraEligibilityStatus_ReturnsExpectedFields ( )
173+ {
174+ var eligibility = new Clients . RegistryPortal . Server . ICRA . ICRAEligibility
175+ {
176+ ApplicantId = this . Fixture . AuthenticatedBcscUser . Id . ToString ( ) ,
177+ Status = Clients . RegistryPortal . Server . ICRA . ICRAStatus . Draft ,
178+ InternationalCertifications = new List < Clients . RegistryPortal . Server . ICRA . InternationalCertification >
179+ {
180+ new Clients . RegistryPortal . Server . ICRA . InternationalCertification
181+ {
182+ CertificateStatus = Clients . RegistryPortal . Server . ICRA . CertificateStatus . Valid ,
183+ CertificateTitle = faker . Company . CatchPhrase ( ) ,
184+ IssueDate = faker . Date . Past ( ) ,
185+ ExpiryDate = faker . Date . Soon ( ) ,
186+ CountryId = this . Fixture . Country . ecer_CountryId ! . Value . ToString ( ) ,
187+ }
188+ }
189+ } ;
190+
191+ var saveResponse = await Host . Scenario ( _ =>
192+ {
193+ _ . WithExistingUser ( this . Fixture . AuthenticatedBcscUserIdentity , this . Fixture . AuthenticatedBcscUser ) ;
194+ _ . Put . Json ( new SaveDraftICRAEligibilityRequest ( eligibility ) ) . ToUrl ( $ "/api/icra/") ;
195+ _ . StatusCodeShouldBeOk ( ) ;
196+ } ) ;
197+
198+ var saved = ( await saveResponse . ReadAsJsonAsync < DraftICRAEligibilityResponse > ( ) ) . ShouldNotBeNull ( ) . Eligibility ;
199+
200+ var statusResponse = await Host . Scenario ( _ =>
201+ {
202+ _ . WithExistingUser ( this . Fixture . AuthenticatedBcscUserIdentity , this . Fixture . AuthenticatedBcscUser ) ;
203+ _ . Get . Url ( $ "/api/icra/{ saved . Id } /status") ;
204+ _ . StatusCodeShouldBeOk ( ) ;
205+ } ) ;
206+
207+ var status = await statusResponse . ReadAsJsonAsync < Clients . RegistryPortal . Server . ICRA . ICRAEligibilityStatus > ( ) ;
208+ status . ShouldNotBeNull ( ) ;
209+ status . Id . ShouldBe ( saved . Id ) ;
210+ status . Status . ShouldBe ( Clients . RegistryPortal . Server . ICRA . ICRAStatus . Draft ) ;
211+ status . InternationalCertifications . ShouldNotBeNull ( ) ;
212+ status . InternationalCertifications . Count ( ) . ShouldBe ( 1 ) ;
213+
214+ // employment references status should be present and empty (none added yet)
215+ status . EmploymentReferencesStatus . ShouldNotBeNull ( ) ;
216+ status . EmploymentReferencesStatus . Count ( ) . ShouldBe ( 0 ) ;
217+
218+ await SetEligibilityToIneligible ( saved . Id ! ) ;
219+ }
220+
221+ [ Fact ]
222+ public async Task GetIcraEligibilityStatus_IncludesEmploymentReferencesStatuses ( )
223+ {
224+ var eligibility = new Clients . RegistryPortal . Server . ICRA . ICRAEligibility
225+ {
226+ ApplicantId = this . Fixture . AuthenticatedBcscUser . Id . ToString ( ) ,
227+ Status = Clients . RegistryPortal . Server . ICRA . ICRAStatus . Draft ,
228+ EmploymentReferences = new [ ]
229+ {
230+ new Clients . RegistryPortal . Server . ICRA . EmploymentReference { FirstName = "John" , LastName = "Doe" , EmailAddress = "[email protected] " } , 231+ new Clients . RegistryPortal . Server . ICRA . EmploymentReference { FirstName = "Jane" , LastName = "Smith" , EmailAddress = "[email protected] " } 232+ } ,
233+ InternationalCertifications = new List < Clients . RegistryPortal . Server . ICRA . InternationalCertification >
234+ {
235+ new Clients . RegistryPortal . Server . ICRA . InternationalCertification
236+ {
237+ CertificateStatus = Clients . RegistryPortal . Server . ICRA . CertificateStatus . Valid ,
238+ CertificateTitle = faker . Company . CatchPhrase ( ) ,
239+ IssueDate = faker . Date . Past ( ) ,
240+ ExpiryDate = faker . Date . Soon ( ) ,
241+ CountryId = this . Fixture . Country . ecer_CountryId ! . Value . ToString ( ) ,
242+ }
243+ }
244+ } ;
245+
246+ var saveResponse = await Host . Scenario ( _ =>
247+ {
248+ _ . WithExistingUser ( this . Fixture . AuthenticatedBcscUserIdentity , this . Fixture . AuthenticatedBcscUser ) ;
249+ _ . Put . Json ( new SaveDraftICRAEligibilityRequest ( eligibility ) ) . ToUrl ( $ "/api/icra/") ;
250+ _ . StatusCodeShouldBeOk ( ) ;
251+ } ) ;
252+
253+ var saved = ( await saveResponse . ReadAsJsonAsync < DraftICRAEligibilityResponse > ( ) ) . ShouldNotBeNull ( ) . Eligibility ;
254+
255+ var statusResponse = await Host . Scenario ( _ =>
256+ {
257+ _ . WithExistingUser ( this . Fixture . AuthenticatedBcscUserIdentity , this . Fixture . AuthenticatedBcscUser ) ;
258+ _ . Get . Url ( $ "/api/icra/{ saved . Id } /status") ;
259+ _ . StatusCodeShouldBeOk ( ) ;
260+ } ) ;
261+
262+ var status = await statusResponse . ReadAsJsonAsync < Clients . RegistryPortal . Server . ICRA . ICRAEligibilityStatus > ( ) ;
263+ status . ShouldNotBeNull ( ) ;
264+ status . EmploymentReferencesStatus . ShouldNotBeNull ( ) ;
265+ status . EmploymentReferencesStatus . Count ( ) . ShouldBe ( 2 ) ;
266+ status . EmploymentReferencesStatus . All ( r => ! string . IsNullOrWhiteSpace ( r . FirstName ) ) . ShouldBeTrue ( ) ;
267+ status . EmploymentReferencesStatus . All ( r => r . Status . HasValue ) . ShouldBeTrue ( ) ;
268+
269+ await SetEligibilityToIneligible ( saved . Id ! ) ;
270+ }
271+
148272 [ Fact ]
149273 public async Task SaveDraftIcraEligibility_WithMismatchedIds_ReturnsBadRequest ( )
150274 {
0 commit comments