-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTimestampTests.cs
More file actions
85 lines (69 loc) · 2.66 KB
/
Copy pathTimestampTests.cs
File metadata and controls
85 lines (69 loc) · 2.66 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
namespace NpgsqlRestTests;
public static partial class Database
{
public static void TimestampTests()
{
script.Append(@"
create function get_timestamp() returns timestamp language sql as
$$
select '2021-01-31 12:34:56.789'::timestamp;
$$;
create function get_timestamp_array() returns timestamp[] language sql as
$$
select array['2021-01-30 12:34:56.789'::timestamp, '2021-01-31 12:34:56.789'::timestamp];
$$;
create function get_timestamp_setof() returns setof timestamp language sql as
$$
select '2021-01-30 12:34:56.789'::timestamp
union
select '2021-01-31 12:34:56.789'::timestamp;
$$;
create function get_timestamp_table() returns table (ts timestamp) language sql as
$$
select '2021-01-30 12:34:56.789'::timestamp
union
select '2021-01-31 12:34:56.789'::timestamp;
$$;
");
}
}
[Collection("TestFixture")]
public class TimestampTests(TestFixture test)
{
[Fact]
public async Task Test_get_timestamp()
{
using var response = await test.Client.GetAsync("/api/get-timestamp");
var content = await response.Content.ReadAsStringAsync();
response.StatusCode.Should().Be(HttpStatusCode.OK);
response.Content.Headers.ContentType?.MediaType.Should().Be("text/plain");
content.Should().Be("2021-01-31 12:34:56.789");
}
[Fact]
public async Task Test_get_timestamp_array()
{
using var response = await test.Client.GetAsync("/api/get-timestamp-array");
var content = await response.Content.ReadAsStringAsync();
response.StatusCode.Should().Be(HttpStatusCode.OK);
response.Content.Headers.ContentType?.MediaType.Should().Be("application/json");
content.Should().Be("[\"2021-01-30T12:34:56.789\",\"2021-01-31T12:34:56.789\"]");
}
[Fact]
public async Task Test_get_timestamp_setof()
{
using var response = await test.Client.GetAsync("/api/get-timestamp-setof");
var content = await response.Content.ReadAsStringAsync();
response.StatusCode.Should().Be(HttpStatusCode.OK);
response.Content.Headers.ContentType?.MediaType.Should().Be("application/json");
content.Should().Be("[\"2021-01-30T12:34:56.789\",\"2021-01-31T12:34:56.789\"]");
}
[Fact]
public async Task Test_get_timestamp_table()
{
using var response = await test.Client.GetAsync("/api/get-timestamp-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("[{\"ts\":\"2021-01-30T12:34:56.789\"},{\"ts\":\"2021-01-31T12:34:56.789\"}]");
}
}