-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathQuotedJsonTests.cs
More file actions
57 lines (51 loc) · 1.63 KB
/
Copy pathQuotedJsonTests.cs
File metadata and controls
57 lines (51 loc) · 1.63 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
namespace NpgsqlRestTests;
public static partial class Database
{
public static void QuotedJsonTests()
{
script.Append(
"""
create function case_quoted_texts()
returns setof text
language sql
as
$$
select * from (values ('aaa'), ('a''a'), ('a"a'), ('a""a')) sub (a)
$$;
create function case_quoted_text_table()
returns table(t text)
language sql
as
$$
select * from (values
('aaa'),
('a''a'),
('a"a'),
('a""a')
) sub (a)
$$;
""");
}
}
[Collection("TestFixture")]
public class QuotedJsonTests(TestFixture test)
{
[Fact]
public async Task Test_case_quoted_texts()
{
using var result = await test.Client.PostAsync("/api/case-quoted-texts/", null);
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json");
response.Should().Be("[\"aaa\",\"a'a\",\"a\\\"a\",\"a\\\"\\\"a\"]");
}
[Fact]
public async Task Test_case_quoted_text_table()
{
using var result = await test.Client.PostAsync("/api/case-quoted-text-table/", null);
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json");
response.Should().Be("[{\"t\":\"aaa\"},{\"t\":\"a'a\"},{\"t\":\"a\\\"a\"},{\"t\":\"a\\\"\\\"a\"}]");
}
}