You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PostgreSqlStorageTest.cs 1.6 KiB

7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 _dbName;
  9. private readonly string _masterDbConnectionString;
  10. private readonly string _dbConnectionString;
  11. public SqlServerStorageTest()
  12. {
  13. _dbName = ConnectionUtil.GetDatabaseName();
  14. _masterDbConnectionString = ConnectionUtil.GetMasterConnectionString();
  15. _dbConnectionString = ConnectionUtil.GetConnectionString();
  16. }
  17. [Fact]
  18. public void Database_IsExists()
  19. {
  20. using (var connection = ConnectionUtil.CreateConnection(_masterDbConnectionString))
  21. {
  22. var databaseName = ConnectionUtil.GetDatabaseName();
  23. var sql = $@"select * from pg_database where datname = '{databaseName}'";
  24. var result = connection.QueryFirstOrDefault<string>(sql);
  25. Assert.NotNull(result);
  26. Assert.True(databaseName.Equals(result, System.StringComparison.CurrentCultureIgnoreCase));
  27. }
  28. }
  29. [Theory]
  30. [InlineData("cap.published")]
  31. [InlineData("cap.received")]
  32. public void DatabaseTable_IsExists(string tableName)
  33. {
  34. using (var connection = ConnectionUtil.CreateConnection(_dbConnectionString))
  35. {
  36. var sql = $"SELECT to_regclass('{tableName}') is not null;";
  37. var result = connection.QueryFirstOrDefault<bool>(sql);
  38. Assert.True(result);
  39. }
  40. }
  41. }
  42. }