-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCommentResponseHeadersTests.cs
More file actions
56 lines (48 loc) · 1.84 KB
/
Copy pathCommentResponseHeadersTests.cs
File metadata and controls
56 lines (48 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
namespace NpgsqlRestTests;
public static partial class Database
{
public static void CommentResponseHeadersTests()
{
script.Append(@"
create function hello_world_html() returns text language sql as 'select ''<div>Hello World</div>''';
comment on function hello_world_html() is '
HTTP GET
Content-Type: text/html';
create function comment_response_headers() returns text language sql as 'select ''comment_response_headers''';
comment on function comment_response_headers() is '
HTTP
Content-Type: application/json
CustomHeader: test
MultiValueCustomHeader: test1
MultiValueCustomHeader: test2
cache-control: no-store
';
");
}
}
[Collection("TestFixture")]
public class CommentResponseHeadersTests(TestFixture test)
{
[Fact]
public async Task Test_hello_world_html()
{
using var result = await test.Client.GetAsync("/api/hello-world-html/");
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("text/html");
response.Should().Be("<div>Hello World</div>");
}
[Fact]
public async Task Test_comment_response_headers()
{
using var response = await test.Client.PostAsync("/api/comment-response-headers/", null);
var content = await response.Content.ReadAsStringAsync();
response?.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("comment_response_headers");
response?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json");
// Note: test client does not support custom headers check out headers in the http client, following headers should be present:
// Cache-Control no-store
// CustomHeader test
// MultiValueCustomHeader test1, test2
}
}