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.
 
 
 

44 lines
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. }