-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathReturnCharTests.cs
More file actions
92 lines (80 loc) · 2.13 KB
/
Copy pathReturnCharTests.cs
File metadata and controls
92 lines (80 loc) · 2.13 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
namespace NpgsqlRestTests;
public static partial class Database
{
public static void ReturnCharTests()
{
script.Append(@"
create function case_return_char1()
returns char(1)
language plpgsql
as
$$
begin
return 'A';
end;
$$;
create function case_return_char_table1()
returns table(
c1 char(1),
c2 char(2),
c3 char(3)
)
language plpgsql
as
$$
begin
return query
select
'A'::char(1),
'BC'::char(2),
'DEF'::char(3);
end;
$$;
create type char_type as (
c1 char(1),
c2 char(2),
c3 char(3)
);
create function case_return_char_type1()
returns char_type
language plpgsql
as
$$
begin
return ('A'::char(1), 'BC'::char(2), 'DEF'::char(3));
end;
$$;
");
}
}
[Collection("TestFixture")]
public class ReturnCharTests(TestFixture test)
{
[Fact]
public async Task Test_case_return_char1()
{
using var result = await test.Client.PostAsync("/api/case-return-char1/", null);
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("text/plain");
response.Should().Be("A");
}
[Fact]
public async Task Test_case_return_char_table1()
{
using var result = await test.Client.PostAsync("/api/case-return-char-table1/", 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("[{\"c1\":\"A\",\"c2\":\"BC\",\"c3\":\"DEF\"}]");
}
[Fact]
public async Task Test_case_return_char_type1()
{
using var result = await test.Client.PostAsync("/api/case-return-char-type1/", 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("{\"c1\":\"A\",\"c2\":\"BC\",\"c3\":\"DEF\"}");
}
}