forked from NpgsqlRest/NpgsqlRest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetofTableTests.cs
More file actions
39 lines (34 loc) · 960 Bytes
/
Copy pathSetofTableTests.cs
File metadata and controls
39 lines (34 loc) · 960 Bytes
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
namespace NpgsqlRestTests;
public static partial class Database
{
public static void SetofTableTests()
{
script.Append(@"
create table test_table (
id int,
name text not null
);
insert into test_table values (1, 'one'), (2, 'two'), (3, 'three');
create function get_test_table()
returns setof test_table
language sql
as
$$
select * from test_table;
$$;
");
}
}
[Collection("TestFixture")]
public class SetofTableTests(TestFixture test)
{
[Fact]
public async Task Test_get_test_table()
{
using var response = await test.Client.GetAsync("/api/get-test-table");
var content = await response.Content.ReadAsStringAsync();
response?.StatusCode.Should().Be(HttpStatusCode.OK);
response?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json");
content.Should().Be("[{\"id\":1,\"name\":\"one\"},{\"id\":2,\"name\":\"two\"},{\"id\":3,\"name\":\"three\"}]");
}
}