提交 a46354a2 编写于 作者: B Bradley Grainger 提交者: Nick Craver

Fix MySQL tests and disposal (#774)

* Don't create the connection in Dispose: this avoids creating a SQLConnection simply to Dispose it.
* Run MySQL tests against the open MySqlConnection: 'connection' is a protected variable in the TestBase class that is a SQL Server connection, not a MySQL connection.
* Skip broken MySQL tests: as per issue #295, setting "AllowZeroDateTime=True" in the connection string causes an InvalidCastException in SqlMapper.
上级 d3ab338c
......@@ -26,9 +26,9 @@ public class MySQLTests : TestBase
[FactMySql]
public void DapperEnumValue_Mysql()
{
using (var connection = GetMySqlConnection())
using (var conn = GetMySqlConnection())
{
Common.DapperEnumValue(connection);
Common.DapperEnumValue(conn);
}
}
......@@ -77,7 +77,7 @@ public void Issue295_NullableDateTime_MySql_Default()
{
using (var conn = GetMySqlConnection(true, false, false))
{
Common.TestDateTime(connection);
Common.TestDateTime(conn);
}
}
......@@ -86,25 +86,25 @@ public void Issue295_NullableDateTime_MySql_ConvertZeroDatetime()
{
using (var conn = GetMySqlConnection(true, true, false))
{
Common.TestDateTime(connection);
Common.TestDateTime(conn);
}
}
[FactMySql]
[FactMySql(Skip = "See https://github.com/StackExchange/Dapper/issues/295, AllowZeroDateTime=True is not supported")]
public void Issue295_NullableDateTime_MySql_AllowZeroDatetime()
{
using (var conn = GetMySqlConnection(true, false, true))
{
Common.TestDateTime(connection);
Common.TestDateTime(conn);
}
}
[FactMySql]
[FactMySql(Skip = "See https://github.com/StackExchange/Dapper/issues/295, AllowZeroDateTime=True is not supported")]
public void Issue295_NullableDateTime_MySql_ConvertAllowZeroDatetime()
{
using (var conn = GetMySqlConnection(true, true, true))
{
Common.TestDateTime(connection);
Common.TestDateTime(conn);
}
}
......@@ -186,4 +186,4 @@ static FactMySqlAttribute()
}
}
}
#endif
\ No newline at end of file
#endif
......@@ -78,7 +78,7 @@ static TestBase()
public void Dispose()
{
connection?.Dispose();
_connection?.Dispose();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册