Skip to content

Commit 5e765b6

Browse files
committed
added more tests
1 parent c7382bf commit 5e765b6

1 file changed

Lines changed: 47 additions & 3 deletions

File tree

Dfe.Academies.TramsDataApi.Tests.Integration/Controllers/V5/EstablishmentsControllerTests.cs

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public async Task SearchEstablishmentsAsync_ShouldReturnAllEstablishments_WhenCl
4747
Assert.Equal(5, establishmentDtos.Count);
4848
foreach (var establishmentDto in establishmentDtos)
4949
{
50-
Assert.NotNull(establishmentDto.ReportCardFullInspection);
50+
Assert.NotNull(establishmentDto.ReportCardFullInspection);
5151
}
5252
}
5353

@@ -107,7 +107,7 @@ public async Task SearchEstablishmentsAsync_ShouldReturnMatchingEstablishments_W
107107
factory.TestClaims = default;
108108

109109
// Act
110-
var result = await establishmentsClient.SearchEstablishmentsWithOfstedReportCardsAsync("Scho", null, null, null, false, default);
110+
var result = await establishmentsClient.SearchEstablishmentsWithOfstedReportCardsAsync("Scho", null, null, null, false, default);
111111

112112
var establishmentDtos = result.ToList();
113113

@@ -187,5 +187,49 @@ public async Task SearchEstablishmentsAsync_ShouldReturnMatchingEstablishments_W
187187
{
188188
Assert.NotNull(establishmentDto.ReportCardFullInspection);
189189
}
190-
}
190+
}
191+
192+
[Theory]
193+
[CustomAutoData(typeof(CustomWebApplicationDbContextFactoryCustomization<Startup>))]
194+
public async Task GetEstablishmentsWithOfstedReportCardsByUrnsAsync_ShouldReturnMatchingEstablishments_WhenURNsAreMatched(
195+
CustomWebApplicationDbContextFactory<Startup> factory,
196+
IEstablishmentsV5Client establishmentsClient)
197+
{
198+
// Arrange
199+
factory.TestClaims = default;
200+
var request = new UrnRequestModel
201+
{
202+
Urns = [22, 33]
203+
};
204+
205+
// Act
206+
var result = await establishmentsClient.GetEstablishmentsWithOfstedReportCardsByUrnsAsync(request, default);
207+
Assert.NotNull(result);
208+
Assert.Equal(2, result.Count);
209+
210+
var establishment = result.SingleOrDefault(x => x.Urn == request.Urns[0].ToString());
211+
Assert.NotNull(establishment);
212+
213+
establishment = result.SingleOrDefault(x => x.Urn == request.Urns[1].ToString());
214+
Assert.NotNull(establishment);
215+
}
216+
217+
[Theory]
218+
[CustomAutoData(typeof(CustomWebApplicationDbContextFactoryCustomization<Startup>))]
219+
public async Task GetEstablishmentsWithOfstedReportCardsByUrnsAsync_ShouldReturnNotFound(
220+
CustomWebApplicationDbContextFactory<Startup> factory,
221+
IEstablishmentsV5Client establishmentsClient)
222+
{
223+
// Arrange
224+
factory.TestClaims = default;
225+
226+
var request = new UrnRequestModel
227+
{
228+
Urns = [10001, 10002] // those URNs do not exist
229+
};
230+
231+
AcademiesApiException exception = await Assert.ThrowsAsync<AcademiesApiException>(async () => await establishmentsClient.GetEstablishmentsWithOfstedReportCardsByUrnsAsync(request, default));
232+
233+
Assert.Equal(404, exception.StatusCode);
234+
}
191235
}

0 commit comments

Comments
 (0)