-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBodyParameterNameTests.cs
More file actions
66 lines (57 loc) · 1.94 KB
/
Copy pathBodyParameterNameTests.cs
File metadata and controls
66 lines (57 loc) · 1.94 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
57
58
59
60
61
62
63
64
65
66
namespace NpgsqlRestTests;
public static partial class Database
{
public static void BodyParameterNameTests()
{
script.Append(@"
create function body_param_name_1p(_p text)
returns text language sql as 'select _p';
comment on function body_param_name_1p(text) is '
HTTP
body-param-name p
';
create function body_param_name_2p(_i int, _p text)
returns text language sql as 'select _i::text || '' '' || _p';
comment on function body_param_name_2p(int, text) is '
HTTP
body-param-name _p
';
create function body_param_name_int(_int int)
returns text language sql as 'select _int';
comment on function body_param_name_int(int) is '
HTTP
body-param-name int';
");
}
}
[Collection("TestFixture")]
public class BodyParameterNameTests(TestFixture test)
{
[Fact]
public async Task Test_body_param_name_1p()
{
using var body = new StringContent("test 123", Encoding.UTF8);
using var response = await test.Client.PostAsync("/api/body-param-name-1p/", body);
var content = await response.Content.ReadAsStringAsync();
response?.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("test 123");
}
[Fact]
public async Task Test_body_param_name_2p()
{
using var body = new StringContent("test ABC", Encoding.UTF8);
using var response = await test.Client.PostAsync("/api/body-param-name-2p/?i=123", body);
var content = await response.Content.ReadAsStringAsync();
response?.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("123 test ABC");
}
[Fact]
public async Task Test_body_param_name_int()
{
using var body = new StringContent("123", Encoding.UTF8);
using var response = await test.Client.PostAsync("/api/body-param-name-int", body);
var content = await response.Content.ReadAsStringAsync();
response?.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("123");
}
}