github.com/dolthub/go-mysql-server@v0.18.0/_integration/dotnet/MySQLTest.cs (about) 1 using Microsoft.VisualStudio.TestTools.UnitTesting; 2 using MySql.Data.MySqlClient; 3 using System.Threading.Tasks; 4 5 namespace dotnet 6 { 7 [TestClass] 8 public class MySQLTest 9 { 10 [TestMethod] 11 public async Task TestCanConnect() 12 { 13 var connectionString = "server=127.0.0.1;user id=root;password=;port=3306;database=mydb;"; 14 var expected = new string[][]{ 15 new string[]{"Evil Bob", "evilbob@gmail.com"}, 16 new string[]{"Jane Doe", "jane@doe.com"}, 17 new string[]{"John Doe", "john@doe.com"}, 18 new string[]{"John Doe", "johnalt@doe.com"}, 19 }; 20 21 using (var conn = new MySqlConnection(connectionString)) 22 { 23 await conn.OpenAsync(); 24 25 var sql = "SELECT name, email FROM mytable ORDER BY name, email"; 26 var i = 0; 27 28 using (var cmd = new MySqlCommand(sql, conn)) 29 using (var reader = await cmd.ExecuteReaderAsync()) 30 while (await reader.ReadAsync()) { 31 if (i >= expected.Length) { 32 Assert.Fail("more rows than expected"); 33 } 34 35 Assert.AreEqual(expected[i][0], reader.GetString(0)); 36 Assert.AreEqual(expected[i][1], reader.GetString(1)); 37 i++; 38 } 39 } 40 } 41 } 42 }