MCPcopy Create free account
hub / github.com/apecloud/myduckserver / MySQLTest

Class MySQLTest

compatibility/mysql/csharp/MySQLTest.cs:7–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5using System.IO;
6
7public class MySQLTest
8{
9 public class Tests
10 {
11 private MySqlConnection conn;
12 private MySqlCommand cmd;
13 private List<Test> tests = new List<Test>();
14
15 public void Connect(string ip, int port, string user, string password)
16 {
17 string connectionString = $"Server={ip};Port={port};User Id={user};Password={password};";
18 try
19 {
20 conn = new MySqlConnection(connectionString);
21 conn.Open();
22 cmd = conn.CreateCommand();
23 cmd.CommandType = CommandType.Text;
24 }
25 catch (MySqlException e)
26 {
27 throw new Exception($"Error connecting to database: {e.Message}", e);
28 }
29 }
30
31 public void Disconnect()
32 {
33 try
34 {
35 cmd.Dispose();
36 conn.Close();
37 }
38 catch (MySqlException e)
39 {
40 throw new Exception(e.Message);
41 }
42 }
43
44 public void AddTest(string query, string[][] expectedResults)
45 {
46 tests.Add(new Test(query, expectedResults));
47 }
48
49 public bool RunTests()
50 {
51 foreach (var test in tests)
52 {
53 if (!test.Run(cmd))
54 {
55 return false;
56 }
57 }
58 return true;
59 }
60
61 public void ReadTestsFromFile(string filename)
62 {
63 try
64 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected