-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBodyParamsTests.cs
More file actions
55 lines (52 loc) · 1.69 KB
/
Copy pathBodyParamsTests.cs
File metadata and controls
55 lines (52 loc) · 1.69 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
#pragma warning disable CS8602 // Dereference of a possibly null reference.
namespace NpgsqlRestTests;
public static partial class Database
{
public static void BodyParamsTests()
{
script.Append(@"
create function body_params_test1(
_i int,
_t text
)
returns text
language sql as $$select 1 || '-' || _t;$$;
");
}
}
[Collection("TestFixture")]
public class BodyParamsTests(TestFixture test)
{
[Fact]
public async Task Test_body_params_test1()
{
string body = """
{
"i": 666,
"t": "numberofthebeast"
}
""";
using var content = new StringContent(body, Encoding.UTF8, "application/json");
using var response = await test.Client.PostAsync("/api/body-params-test1/", content);
response.StatusCode.Should().Be(HttpStatusCode.OK);
response.Content.Headers.ContentType.MediaType.Should().Be("text/plain");
var result = await response.Content.ReadAsStringAsync();
result.Should().Be("1-numberofthebeast");
}
[Fact]
public async Task Test_body_params_test1_reverse()
{
string body = """
{
"t": "numberofthebeast",
"i": 666
}
""";
using var content = new StringContent(body, Encoding.UTF8, "application/json");
using var response = await test.Client.PostAsync("/api/body-params-test1/", content);
response.StatusCode.Should().Be(HttpStatusCode.OK);
response.Content.Headers.ContentType.MediaType.Should().Be("text/plain");
var result = await response.Content.ReadAsStringAsync();
result.Should().Be("1-numberofthebeast");
}
}