|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using Xunit;
- using Dapper;
-
- namespace DotNetCore.CAP.MySql.Test
- {
- [Collection("MySql")]
- public class MySqlStorageTest : DatabaseTestHost
- {
- private readonly string _dbName;
- private readonly string _masterDbConnectionString;
-
-
- public MySqlStorageTest()
- {
- _dbName = ConnectionUtil.GetDatabaseName();
- _masterDbConnectionString = ConnectionUtil.GetMasterConnectionString();
- }
-
- [Fact]
- public void Database_IsExists()
- {
- using (var connection = ConnectionUtil.CreateConnection(_masterDbConnectionString))
- {
- var databaseName = ConnectionUtil.GetDatabaseName();
- var sql = $@"SELECT SCHEMA_NAME FROM SCHEMATA WHERE SCHEMA_NAME = '{databaseName}'";
- var result = connection.QueryFirstOrDefault<string>(sql);
- Assert.NotNull(result);
- Assert.True(databaseName.Equals(result, System.StringComparison.CurrentCultureIgnoreCase));
- }
- }
-
- [Fact]
- public void DatabaseTable_Published_IsExists()
- {
- var tableName = "cap.published";
- using (var connection = ConnectionUtil.CreateConnection(_masterDbConnectionString))
- {
- var sql = $"SELECT TABLE_NAME FROM `TABLES` WHERE TABLE_SCHEMA='{_dbName}' AND TABLE_NAME = '{tableName}'";
- var result = connection.QueryFirstOrDefault<string>(sql);
- Assert.NotNull(result);
- Assert.Equal(tableName, result);
- }
- }
-
- [Fact]
- public void DatabaseTable_Queue_IsExists()
- {
- var tableName = "cap.queue";
- using (var connection = ConnectionUtil.CreateConnection(_masterDbConnectionString))
- {
- var sql = $"SELECT TABLE_NAME FROM `TABLES` WHERE TABLE_SCHEMA='{_dbName}' AND TABLE_NAME = '{tableName}'";
- var result = connection.QueryFirstOrDefault<string>(sql);
- Assert.NotNull(result);
- Assert.Equal(tableName, result);
- }
- }
-
- [Fact]
- public void DatabaseTable_Received_IsExists()
- {
- var tableName = "cap.received";
- using (var connection = ConnectionUtil.CreateConnection(_masterDbConnectionString))
- {
- var sql = $"SELECT TABLE_NAME FROM `TABLES` WHERE TABLE_SCHEMA='{_dbName}' AND TABLE_NAME = '{tableName}'";
- var result = connection.QueryFirstOrDefault<string>(sql);
- Assert.NotNull(result);
- Assert.Equal(tableName, result);
- }
- }
- }
- }
|