Skip to content

Commit a1f7534

Browse files
committed
Added integrative test
1 parent 58faf96 commit a1f7534

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
29 KB
Binary file not shown.

PdfAValidatorWebApiTest/ShouldStartSuccessfull.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Mvc.Testing;
22
using System;
3+
using System.IO;
4+
using System.Net.Http;
35
using System.Threading.Tasks;
46
using Xunit;
57

@@ -31,5 +33,27 @@ public async Task ShouldAccessEndpointSuccessfull(string route, string contentTy
3133
Assert.Equal(contentType,
3234
response.Content.Headers.ContentType.ToString());
3335
}
36+
37+
[Fact]
38+
public async Task ShouldValidatePdf()
39+
{
40+
// Arrange
41+
var client = _factory.CreateClient();
42+
43+
using var request = new HttpRequestMessage(new HttpMethod("POST"), "http://localhost/api/PdfAValidator");
44+
request.Headers.TryAddWithoutValidation("accept", "*/*");
45+
46+
var multipartContent = new MultipartFormDataContent();
47+
var file1 = new ByteArrayContent(File.ReadAllBytes("../../../FromLibreOffice.pdf"));
48+
file1.Headers.Add("Content-Type", "application/pdf");
49+
multipartContent.Add(file1, "pdfFile", Path.GetFileName("FromLibreOffice.pdf"));
50+
request.Content = multipartContent;
51+
52+
// Act
53+
var response = await client.SendAsync(request);
54+
55+
// Assert
56+
response.EnsureSuccessStatusCode();
57+
}
3458
}
3559
}

0 commit comments

Comments
 (0)