File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
by-language/csharp-npgsql Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -57,15 +57,19 @@ public static async Task<List<string>> SystemQueryExample(NpgsqlConnection conn)
5757 {
5858 Console . WriteLine ( "Running SystemQueryExample" ) ;
5959 var mountains = new List < string > ( ) ;
60- await using ( var cmd = new NpgsqlCommand ( "SELECT mountain FROM sys.summits ORDER BY 1 LIMIT 25" , conn ) )
60+ const string sql = "SELECT mountain, height, coordinates FROM sys.summits ORDER BY height DESC LIMIT 25" ;
61+ await using ( var cmd = new NpgsqlCommand ( sql , conn ) )
6162 await using ( var reader = cmd . ExecuteReader ( ) )
6263 {
6364 while ( await reader . ReadAsync ( ) )
6465 {
65- mountains . Add ( reader . GetString ( 0 ) ) ;
66+ mountains . Add (
67+ reader [ "mountain" ] . ToString ( ) + " - " +
68+ reader [ "height" ] . ToString ( ) + " - " +
69+ reader [ "coordinates" ] . ToString ( ) ) ;
6670 }
6771
68- Console . WriteLine ( $ "Mountains: { string . Join ( ", " , mountains ) } ") ;
72+ Console . WriteLine ( $ "Mountains:\n { string . Join ( "\n " , mountains ) } ") ;
6973 }
7074
7175 Console . WriteLine ( ) ;
Original file line number Diff line number Diff line change 66
77namespace demo . tests
88{
9-
9+
1010 public class DatabaseFixture : IDisposable
1111 {
1212 public NpgsqlConnection Db { get ; private set ; }
@@ -29,10 +29,10 @@ public void Dispose()
2929 }
3030
3131 }
32-
32+
3333 public class DemoProgramTest : IClassFixture < DatabaseFixture >
3434 {
35-
35+
3636 DatabaseFixture fixture ;
3737 DatabaseWorkloads program = new DatabaseWorkloads ( ) ;
3838
@@ -51,7 +51,7 @@ public async Task TestSystemQueryExample()
5151 var mountains = await task . WaitAsync ( TimeSpan . FromSeconds ( 0.5 ) ) ;
5252
5353 // Check results.
54- Assert . Equal ( "Acherkogel " , mountains [ 0 ] ) ;
54+ Assert . Equal ( "Mont Blanc - 4808 - (6.86444,45.8325) " , mountains [ 0 ] ) ;
5555 }
5656
5757 [ Fact ]
@@ -79,6 +79,5 @@ public async Task TestUnnestExample()
7979 // Check results.
8080 Assert . Equal ( 10 , resultCount ) ;
8181 }
82-
8382 }
8483}
You can’t perform that action at this time.
0 commit comments