-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathReturnLongTableTests.cs
More file actions
81 lines (67 loc) · 2.52 KB
/
Copy pathReturnLongTableTests.cs
File metadata and controls
81 lines (67 loc) · 2.52 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
#pragma warning disable CS8602 // Dereference of a possibly null reference.
namespace NpgsqlRestTests;
public static partial class Database
{
public static void ReturnLongTableTests()
{
script.Append("""
create function case_get_long_table1(_records int)
returns table (
int_field int,
text_field text
)
language sql
as
$_$
select
i, i::text
from
generate_series(1, _records) as i;
$_$;
""");
}
}
[Collection("TestFixture")]
public class ReturnLongTableTests(TestFixture test)
{
[Fact]
public async Task Test_case_get_long_table1_return10()
{
using var result = await test.Client.GetAsync("/api/case-get-long-table1/?records=10");
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json");
var array = JsonNode.Parse(response).AsArray();
array.Count.Should().Be(10);
}
[Fact]
public async Task Test_case_get_long_table1_return25()
{
using var result = await test.Client.GetAsync("/api/case-get-long-table1/?records=25");
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json");
var array = JsonNode.Parse(response).AsArray();
array.Count.Should().Be(25);
}
[Fact]
public async Task Test_case_get_long_table1_return75()
{
using var result = await test.Client.GetAsync("/api/case-get-long-table1/?records=75");
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json");
var array = JsonNode.Parse(response).AsArray();
array.Count.Should().Be(75);
}
[Fact]
public async Task Test_case_get_long_table1_return0()
{
using var result = await test.Client.GetAsync("/api/case-get-long-table1/?records=0");
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json");
var array = JsonNode.Parse(response).AsArray();
array.Count.Should().Be(0);
}
}