Template
31 lines
1.4 KiB
C#
31 lines
1.4 KiB
C#
namespace Strata.ContinuousImprovement.Api.Test.Integration.Tests
|
|
{
|
|
public static class HttpMessageResponseExtensions
|
|
{
|
|
public static void AssertIsValid(this HttpResponseMessage response, bool exportable = false, string version = "1.0")
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(response.IsSuccessStatusCode, Is.True);
|
|
var headers = response.Headers.Where(x => x.Value != null)
|
|
.ToDictionary(k => k.Key, v => v.Value);
|
|
Assert.That(headers, Is.Not.Null.And.Not.Empty);
|
|
Assert.That(headers.ContainsKey("Api-Supported-Versions"), Is.True);
|
|
var apiVersion = headers["Api-Supported-Versions"].ToList();
|
|
Assert.That(apiVersion.Contains(version), Is.True);
|
|
if (exportable)
|
|
{
|
|
var content = response.Content;
|
|
Assert.That(content, Is.Not.Null);
|
|
headers = response.Content.Headers.Where(x => x.Value != null)
|
|
.ToDictionary(k => k.Key, v => v.Value);
|
|
Assert.That(headers.ContainsKey("Content-Type"), Is.True);
|
|
var contentType = headers["Content-Type"].ToList();
|
|
Assert.That(contentType.Contains("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), Is.True);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
}
|