functional tests

This commit is contained in:
Steve Smith
2017-05-01 06:27:21 -04:00
parent 235b946f4a
commit 8a4edfec19
4 changed files with 112 additions and 18 deletions

View File

@@ -0,0 +1,28 @@
using System.IO;
using Xunit;
using System.Threading.Tasks;
namespace FunctionalTests.Web.Controllers
{
public class CatalogControllerGetImage : BaseWebTest
{
[Fact]
public async Task ReturnsFileContentResultGivenValidId()
{
var testFilePath = Path.Combine(_contentRoot, "pics//1.png");
var expectedFileBytes = File.ReadAllBytes(testFilePath);
var response = await _client.GetAsync("/catalog/pic/1");
response.EnsureSuccessStatusCode();
var streamResponse = await response.Content.ReadAsStreamAsync();
byte[] byteResult;
using (var ms = new MemoryStream())
{
streamResponse.CopyTo(ms);
byteResult = ms.ToArray();
}
Assert.Equal(expectedFileBytes, byteResult);
}
}
}