-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#886 Added the Unit Tests to the MySql, MySqlConnector and SqLite.
- Loading branch information
1 parent
c322dad
commit 2944f7a
Showing
22 changed files
with
853 additions
and
45 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
RepoDb.MySql/RepoDb.MySql.UnitTests/Attributes/MySqlTypeMapAttributeTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MySql.Data.MySqlClient; | ||
using RepoDb.Attributes; | ||
using RepoDb.DbSettings; | ||
using RepoDb.Extensions; | ||
|
||
namespace RepoDb.MySql.UnitTests.Attributes | ||
{ | ||
[TestClass] | ||
public class MySqlTypeMapAttributeTest | ||
{ | ||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
DbSettingMapper.Add<MySqlConnection>(new MySqlDbSetting(), true); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
DbSettingMapper.Clear(); | ||
} | ||
|
||
#region Classes | ||
|
||
private class MySqlDbTypeAttributeTestClass | ||
{ | ||
[MySqlTypeMap(MySqlDbType.Geometry)] | ||
public object ColumnName { get; set; } | ||
} | ||
|
||
#endregion | ||
|
||
[TestMethod] | ||
public void TestMySqlTypeMapAttributeViaEntityViaCreateParameters() | ||
{ | ||
// Act | ||
using (var connection = new MySqlConnection()) | ||
{ | ||
using (var command = connection.CreateCommand()) | ||
{ | ||
DbCommandExtension | ||
.CreateParameters(command, new MySqlDbTypeAttributeTestClass | ||
{ | ||
ColumnName = "Test" | ||
}); | ||
|
||
// Assert | ||
Assert.AreEqual(1, command.Parameters.Count); | ||
|
||
// Assert | ||
var parameter = command.Parameters["@ColumnName"]; | ||
Assert.AreEqual(MySqlDbType.Geometry, parameter.MySqlDbType); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void TestMySqlTypeMapAttributeViaAnonymousViaCreateParameters() | ||
{ | ||
// Act | ||
using (var connection = new MySqlConnection()) | ||
{ | ||
using (var command = connection.CreateCommand()) | ||
{ | ||
DbCommandExtension | ||
.CreateParameters(command, new | ||
{ | ||
ColumnName = "Test" | ||
}, | ||
typeof(MySqlDbTypeAttributeTestClass)); | ||
|
||
// Assert | ||
Assert.AreEqual(1, command.Parameters.Count); | ||
|
||
// Assert | ||
var parameter = command.Parameters["@ColumnName"]; | ||
Assert.AreEqual(MySqlDbType.Geometry, parameter.MySqlDbType); | ||
} | ||
} | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
RepoDb.MySql/RepoDb.MySql.UnitTests/Attributes/Parameter/MySql/MySqlDbTypeAttributeTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MySql.Data.MySqlClient; | ||
using RepoDb.Attributes.Parameter.MySql; | ||
using RepoDb.DbSettings; | ||
using RepoDb.Extensions; | ||
|
||
namespace RepoDb.MySql.UnitTests.Attributes.Parameter.MySql | ||
{ | ||
[TestClass] | ||
public class MySqlDbTypeAttributeTest | ||
{ | ||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
DbSettingMapper.Add<MySqlConnection>(new MySqlDbSetting(), true); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
DbSettingMapper.Clear(); | ||
} | ||
|
||
#region Classes | ||
|
||
private class MySqlDbTypeAttributeTestClass | ||
{ | ||
[MySqlDbType(MySqlDbType.Geometry)] | ||
public object ColumnName { get; set; } | ||
} | ||
|
||
#endregion | ||
|
||
[TestMethod] | ||
public void TestMySqlDbTypeAttributeViaEntityViaCreateParameters() | ||
{ | ||
// Act | ||
using (var connection = new MySqlConnection()) | ||
{ | ||
using (var command = connection.CreateCommand()) | ||
{ | ||
DbCommandExtension | ||
.CreateParameters(command, new MySqlDbTypeAttributeTestClass | ||
{ | ||
ColumnName = "Test" | ||
}); | ||
|
||
// Assert | ||
Assert.AreEqual(1, command.Parameters.Count); | ||
|
||
// Assert | ||
var parameter = command.Parameters["@ColumnName"]; | ||
Assert.AreEqual(MySqlDbType.Geometry, parameter.MySqlDbType); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void TestMySqlDbTypeAttributeViaAnonymousViaCreateParameters() | ||
{ | ||
// Act | ||
using (var connection = new MySqlConnection()) | ||
{ | ||
using (var command = connection.CreateCommand()) | ||
{ | ||
DbCommandExtension | ||
.CreateParameters(command, new | ||
{ | ||
ColumnName = "Test" | ||
}, | ||
typeof(MySqlDbTypeAttributeTestClass)); | ||
|
||
// Assert | ||
Assert.AreEqual(1, command.Parameters.Count); | ||
|
||
// Assert | ||
var parameter = command.Parameters["@ColumnName"]; | ||
Assert.AreEqual(MySqlDbType.Geometry, parameter.MySqlDbType); | ||
} | ||
} | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...onnector/RepoDb.MySqlConnector.UnitTests/Attributes/MySqlConnectorTypeMapAttributeTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MySqlConnector; | ||
using RepoDb.Attributes; | ||
using RepoDb.DbSettings; | ||
using RepoDb.Extensions; | ||
|
||
namespace RepoDb.MySqlConnector.UnitTests.Attributes | ||
{ | ||
[TestClass] | ||
public class MySqlTypeMapAttributeTest | ||
{ | ||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
DbSettingMapper.Add<MySqlConnection>(new MySqlConnectorDbSetting(), true); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
DbSettingMapper.Clear(); | ||
} | ||
|
||
#region Classes | ||
|
||
private class MySqlDbTypeAttributeTestClass | ||
{ | ||
[MySqlConnectorTypeMap(MySqlDbType.Geometry)] | ||
public object ColumnName { get; set; } | ||
} | ||
|
||
#endregion | ||
|
||
[TestMethod] | ||
public void TestMySqlConnectorTypeMapAttributeViaEntityViaCreateParameters() | ||
{ | ||
// Act | ||
using (var connection = new MySqlConnection()) | ||
{ | ||
using (var command = connection.CreateCommand()) | ||
{ | ||
DbCommandExtension | ||
.CreateParameters(command, new MySqlDbTypeAttributeTestClass | ||
{ | ||
ColumnName = "Test" | ||
}); | ||
|
||
// Assert | ||
Assert.AreEqual(1, command.Parameters.Count); | ||
|
||
// Assert | ||
var parameter = command.Parameters["@ColumnName"]; | ||
Assert.AreEqual(MySqlDbType.Geometry, parameter.MySqlDbType); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void TestMySqlConnectorTypeMapAttributeViaAnonymousViaCreateParameters() | ||
{ | ||
// Act | ||
using (var connection = new MySqlConnection()) | ||
{ | ||
using (var command = connection.CreateCommand()) | ||
{ | ||
DbCommandExtension | ||
.CreateParameters(command, new | ||
{ | ||
ColumnName = "Test" | ||
}, | ||
typeof(MySqlDbTypeAttributeTestClass)); | ||
|
||
// Assert | ||
Assert.AreEqual(1, command.Parameters.Count); | ||
|
||
// Assert | ||
var parameter = command.Parameters["@ColumnName"]; | ||
Assert.AreEqual(MySqlDbType.Geometry, parameter.MySqlDbType); | ||
} | ||
} | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
....MySqlConnector.UnitTests/Attributes/Parameter/MySqlConnector/MySqlDbTypeAttributeTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MySqlConnector; | ||
using RepoDb.Attributes.Parameter.MySqlConnector; | ||
using RepoDb.DbSettings; | ||
using RepoDb.Extensions; | ||
|
||
namespace RepoDb.MySqlConnector.UnitTests.Attributes.Parameter.MySqlConnector | ||
{ | ||
[TestClass] | ||
public class MySqlDbTypeAttributeTest | ||
{ | ||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
DbSettingMapper.Add<MySqlConnection>(new MySqlConnectorDbSetting(), true); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
DbSettingMapper.Clear(); | ||
} | ||
|
||
#region Classes | ||
|
||
private class MySqlDbTypeAttributeTestClass | ||
{ | ||
[MySqlDbType(MySqlDbType.Geometry)] | ||
public object ColumnName { get; set; } | ||
} | ||
|
||
#endregion | ||
|
||
[TestMethod] | ||
public void TestMySqlDbTypeAttributeViaEntityViaCreateParameters() | ||
{ | ||
// Act | ||
using (var connection = new MySqlConnection()) | ||
{ | ||
using (var command = connection.CreateCommand()) | ||
{ | ||
DbCommandExtension | ||
.CreateParameters(command, new MySqlDbTypeAttributeTestClass | ||
{ | ||
ColumnName = "Test" | ||
}); | ||
|
||
// Assert | ||
Assert.AreEqual(1, command.Parameters.Count); | ||
|
||
// Assert | ||
var parameter = command.Parameters["@ColumnName"]; | ||
Assert.AreEqual(MySqlDbType.Geometry, parameter.MySqlDbType); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void TestMySqlDbTypeAttributeViaAnonymousViaCreateParameters() | ||
{ | ||
// Act | ||
using (var connection = new MySqlConnection()) | ||
{ | ||
using (var command = connection.CreateCommand()) | ||
{ | ||
DbCommandExtension | ||
.CreateParameters(command, new | ||
{ | ||
ColumnName = "Test" | ||
}, | ||
typeof(MySqlDbTypeAttributeTestClass)); | ||
|
||
// Assert | ||
Assert.AreEqual(1, command.Parameters.Count); | ||
|
||
// Assert | ||
var parameter = command.Parameters["@ColumnName"]; | ||
Assert.AreEqual(MySqlDbType.Geometry, parameter.MySqlDbType); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.