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

Method Run

compatibility/mysql/csharp/MySQLTest.cs:100–156  ·  view source on GitHub ↗
(MySqlCommand cmd)

Source from the content-addressed store, hash-verified

98 }
99
100 public bool Run(MySqlCommand cmd)
101 {
102 try
103 {
104 Console.WriteLine("Running test: " + query);
105 cmd.CommandText = query;
106 using (var reader = cmd.ExecuteReader())
107 {
108 if (!reader.HasRows)
109 {
110 if (expectedResults.Length != 0)
111 {
112 Console.Error.WriteLine($"Expected {expectedResults.Length} rows, got 0");
113 return false;
114 }
115 Console.WriteLine("Returns 0 rows");
116 return true;
117 }
118 if (reader.FieldCount != expectedResults[0].Length)
119 {
120 Console.Error.WriteLine($"Expected {expectedResults[0].Length} columns, got {reader.FieldCount}");
121 return false;
122 }
123 int rows = 0;
124 while (reader.Read())
125 {
126 for (int col = 0; col < expectedResults[rows].Length; col++)
127 {
128 string result = reader.GetString(col);
129 if (expectedResults[rows][col] != result)
130 {
131 Console.Error.WriteLine($"Expected:\n'{expectedResults[rows][col]}'");
132 Console.Error.WriteLine($"Result:\n'{result}'\nRest of the results:");
133 while (reader.Read())
134 {
135 Console.Error.WriteLine(reader.GetString(0));
136 }
137 return false;
138 }
139 }
140 rows++;
141 }
142 Console.WriteLine("Returns " + rows + " rows");
143 if (rows != expectedResults.Length)
144 {
145 Console.Error.WriteLine($"Expected {expectedResults.Length} rows");
146 return false;
147 }
148 return true;
149 }
150 }
151 catch (MySqlException e)
152 {
153 Console.Error.WriteLine(e.Message);
154 return false;
155 }
156 }
157 }

Callers 1

RunTestsMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected