Skip to content

Commit

Permalink
Added integrative test
Browse files Browse the repository at this point in the history
  • Loading branch information
stesee committed Jun 22, 2020
1 parent 58faf96 commit a1f7534
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Binary file added PdfAValidatorWebApiTest/FromLibreOffice.pdf
Binary file not shown.
24 changes: 24 additions & 0 deletions PdfAValidatorWebApiTest/ShouldStartSuccessfull.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Mvc.Testing;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;

Expand Down Expand Up @@ -31,5 +33,27 @@ public async Task ShouldAccessEndpointSuccessfull(string route, string contentTy
Assert.Equal(contentType,
response.Content.Headers.ContentType.ToString());
}

[Fact]
public async Task ShouldValidatePdf()
{
// Arrange
var client = _factory.CreateClient();

using var request = new HttpRequestMessage(new HttpMethod("POST"), "http://localhost/api/PdfAValidator");
request.Headers.TryAddWithoutValidation("accept", "*/*");

var multipartContent = new MultipartFormDataContent();
var file1 = new ByteArrayContent(File.ReadAllBytes("../../../FromLibreOffice.pdf"));
file1.Headers.Add("Content-Type", "application/pdf");
multipartContent.Add(file1, "pdfFile", Path.GetFileName("FromLibreOffice.pdf"));
request.Content = multipartContent;

// Act
var response = await client.SendAsync(request);

// Assert
response.EnsureSuccessStatusCode();
}
}
}

0 comments on commit a1f7534

Please sign in to comment.