77
88namespace CodeuctivityWebApiTest
99{
10- public class ShouldStartSuccessfull : IClassFixture < WebApplicationFactory < CodeuctivityWebApi . Startup > >
10+ public class IntegrativeTests : IClassFixture < WebApplicationFactory < CodeuctivityWebApi . Startup > >
1111 {
1212 private readonly WebApplicationFactory < CodeuctivityWebApi . Startup > _factory ;
1313
14- public ShouldStartSuccessfull ( WebApplicationFactory < CodeuctivityWebApi . Startup > factory )
14+ public IntegrativeTests ( WebApplicationFactory < CodeuctivityWebApi . Startup > factory )
1515 {
1616 _factory = factory ;
1717 }
@@ -30,8 +30,7 @@ public async Task ShouldAccessEndpointSuccessfull(string route, string contentTy
3030
3131 // Assert
3232 response . EnsureSuccessStatusCode ( ) ;
33- Assert . Equal ( contentType ,
34- response . Content . Headers . ContentType . ToString ( ) ) ;
33+ Assert . Equal ( contentType , response . Content . Headers . ContentType . ToString ( ) ) ;
3534 }
3635
3736 [ Fact ]
@@ -43,17 +42,18 @@ public async Task ShouldValidatePdf()
4342 using var request = new HttpRequestMessage ( new HttpMethod ( "POST" ) , "http://localhost/api/PdfAValidator" ) ;
4443 request . Headers . TryAddWithoutValidation ( "accept" , "*/*" ) ;
4544
46- var multipartContent = new MultipartFormDataContent ( ) ;
47- var file1 = new ByteArrayContent ( File . ReadAllBytes ( "../../../FromLibreOffice.pdf" ) ) ;
45+ using var file1 = new ByteArrayContent ( File . ReadAllBytes ( "../../../FromLibreOffice.pdf" ) ) ;
4846 file1 . Headers . Add ( "Content-Type" , "application/pdf" ) ;
47+ var multipartContent = new MultipartFormDataContent ( ) ;
4948 multipartContent . Add ( file1 , "pdfFile" , Path . GetFileName ( "FromLibreOffice.pdf" ) ) ;
5049 request . Content = multipartContent ;
5150
5251 // Act
53- var response = await client . SendAsync ( request ) ;
52+ var response = await client . SendAsync ( request ) . ConfigureAwait ( false ) ;
5453
5554 // Assert
5655 response . EnsureSuccessStatusCode ( ) ;
56+ Assert . Equal ( "true" , await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ) ;
5757 }
5858 }
5959}
0 commit comments