-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathReturnIntTests.cs
More file actions
67 lines (59 loc) · 1.69 KB
/
Copy pathReturnIntTests.cs
File metadata and controls
67 lines (59 loc) · 1.69 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
namespace NpgsqlRestTests;
public static partial class Database
{
public static void ReturnIntTests()
{
script.Append(@"
create function case_return_int(_i int)
returns int
language plpgsql
as
$$
begin
raise info '_i = %', _i;
return _i;
end;
$$;
create function case_get_int(_i int)
returns int
language plpgsql
as
$$
begin
raise info '_i = %', _i;
return _i;
end;
$$;
");
}
}
[Collection("TestFixture")]
public class ReturnIntTests(TestFixture test)
{
[Fact]
public async Task Test_case_return_int()
{
using var content = new StringContent("{\"i\":999}", Encoding.UTF8, "application/json");
using var result = await test.Client.PostAsync("/api/case-return-int/", content);
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("text/plain");
response.Should().Be("999");
}
[Fact]
public async Task Test_case_return_int_WrongParameter()
{
using var content = new StringContent("{\"x\":666}", Encoding.UTF8, "application/json");
using var result = await test.Client.PostAsync("/api/case-return-int/", content);
result?.StatusCode.Should().Be(HttpStatusCode.NotFound);
}
[Fact]
public async Task Test_case_get_int()
{
using var result = await test.Client.GetAsync("/api/case-get-int/?i=999");
var response = await result.Content.ReadAsStringAsync();
result?.StatusCode.Should().Be(HttpStatusCode.OK);
result?.Content?.Headers?.ContentType?.MediaType.Should().Be("text/plain");
response.Should().Be("999");
}
}