您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

44 行
1.5 KiB

  1. using Dapper;
  2. using Xunit;
  3. namespace DotNetCore.CAP.PostgreSql.Test
  4. {
  5. [Collection("postgresql")]
  6. public class SqlServerStorageTest : DatabaseTestHost
  7. {
  8. private readonly string _masterDbConnectionString;
  9. private readonly string _dbConnectionString;
  10. public SqlServerStorageTest()
  11. {
  12. _masterDbConnectionString = ConnectionUtil.GetMasterConnectionString();
  13. _dbConnectionString = ConnectionUtil.GetConnectionString();
  14. }
  15. [Fact]
  16. public void Database_IsExists()
  17. {
  18. using (var connection = ConnectionUtil.CreateConnection(_masterDbConnectionString))
  19. {
  20. var databaseName = ConnectionUtil.GetDatabaseName();
  21. var sql = $@"select * from pg_database where datname = '{databaseName}'";
  22. var result = connection.QueryFirstOrDefault<string>(sql);
  23. Assert.NotNull(result);
  24. Assert.True(databaseName.Equals(result, System.StringComparison.CurrentCultureIgnoreCase));
  25. }
  26. }
  27. [Theory]
  28. [InlineData("cap.published")]
  29. [InlineData("cap.received")]
  30. public void DatabaseTable_IsExists(string tableName)
  31. {
  32. using (var connection = ConnectionUtil.CreateConnection(_dbConnectionString))
  33. {
  34. var sql = $"SELECT to_regclass('{tableName}') is not null;";
  35. var result = connection.QueryFirstOrDefault<bool>(sql);
  36. Assert.True(result);
  37. }
  38. }
  39. }
  40. }