|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using Dapper;
- using Xunit;
-
- 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));
- }
- }
-
- [Theory]
- [InlineData("cap.published")]
- [InlineData("cap.queue")]
- [InlineData("cap.received")]
- public void DatabaseTable_IsExists(string tableName)
- {
- 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);
- }
- }
- }
- }
|