|
| 1 | +#pragma warning disable CS8602 // Dereference of a possibly null reference. |
| 2 | +namespace NpgsqlRestTests; |
| 3 | + |
| 4 | +public static partial class Database |
| 5 | +{ |
| 6 | + public static void ReturnLongTableTests() |
| 7 | + { |
| 8 | + script.Append(""" |
| 9 | + create function case_get_long_table1(_records int) |
| 10 | + returns table ( |
| 11 | + int_field int, |
| 12 | + text_field text |
| 13 | + ) |
| 14 | + language sql |
| 15 | + as |
| 16 | + $_$ |
| 17 | + select |
| 18 | + i, i::text |
| 19 | + from |
| 20 | + generate_series(1, _records) as i; |
| 21 | + $_$; |
| 22 | + """); |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | + |
| 27 | +[Collection("TestFixture")] |
| 28 | +public class ReturnLongTableTests(TestFixture test) |
| 29 | +{ |
| 30 | + [Fact] |
| 31 | + public async Task Test_case_get_long_table1_return10() |
| 32 | + { |
| 33 | + using var result = await test.Client.GetAsync("/api/case-get-long-table1/?records=10"); |
| 34 | + var response = await result.Content.ReadAsStringAsync(); |
| 35 | + |
| 36 | + result?.StatusCode.Should().Be(HttpStatusCode.OK); |
| 37 | + result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json"); |
| 38 | + |
| 39 | + var array = JsonNode.Parse(response).AsArray(); |
| 40 | + array.Count.Should().Be(10); |
| 41 | + } |
| 42 | + |
| 43 | + [Fact] |
| 44 | + public async Task Test_case_get_long_table1_return25() |
| 45 | + { |
| 46 | + using var result = await test.Client.GetAsync("/api/case-get-long-table1/?records=25"); |
| 47 | + var response = await result.Content.ReadAsStringAsync(); |
| 48 | + |
| 49 | + result?.StatusCode.Should().Be(HttpStatusCode.OK); |
| 50 | + result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json"); |
| 51 | + |
| 52 | + var array = JsonNode.Parse(response).AsArray(); |
| 53 | + array.Count.Should().Be(25); |
| 54 | + } |
| 55 | + |
| 56 | + [Fact] |
| 57 | + public async Task Test_case_get_long_table1_return75() |
| 58 | + { |
| 59 | + using var result = await test.Client.GetAsync("/api/case-get-long-table1/?records=75"); |
| 60 | + var response = await result.Content.ReadAsStringAsync(); |
| 61 | + |
| 62 | + result?.StatusCode.Should().Be(HttpStatusCode.OK); |
| 63 | + result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json"); |
| 64 | + |
| 65 | + var array = JsonNode.Parse(response).AsArray(); |
| 66 | + array.Count.Should().Be(75); |
| 67 | + } |
| 68 | + |
| 69 | + [Fact] |
| 70 | + public async Task Test_case_get_long_table1_return0() |
| 71 | + { |
| 72 | + using var result = await test.Client.GetAsync("/api/case-get-long-table1/?records=0"); |
| 73 | + var response = await result.Content.ReadAsStringAsync(); |
| 74 | + |
| 75 | + result?.StatusCode.Should().Be(HttpStatusCode.OK); |
| 76 | + result?.Content?.Headers?.ContentType?.MediaType.Should().Be("application/json"); |
| 77 | + |
| 78 | + var array = JsonNode.Parse(response).AsArray(); |
| 79 | + array.Count.Should().Be(0); |
| 80 | + } |
| 81 | +} |
0 commit comments