Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

46 linhas
1.6 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 _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. }