Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

72 Zeilen
1.9 KiB

  1. using Xunit;
  2. using Dapper;
  3. namespace DotNetCore.CAP.SqlServer.Test
  4. {
  5. [Collection("sqlserver")]
  6. public class SqlServerStorageTest : DatabaseTestHost
  7. {
  8. [Fact]
  9. public void Database_IsExists()
  10. {
  11. var master = ConnectionUtil.GetMasterConnectionString();
  12. using (var connection = ConnectionUtil.CreateConnection(master))
  13. {
  14. var databaseName = ConnectionUtil.GetDatabaseName();
  15. var sql = $@"
  16. IF EXISTS (SELECT * FROM sysdatabases WHERE name = N'{databaseName}')
  17. SELECT 'True'
  18. ELSE
  19. SELECT 'False'";
  20. var result = connection.QueryFirst<bool>(sql);
  21. Assert.Equal(true, result);
  22. }
  23. }
  24. [Fact]
  25. public void DatabaseTable_Published_IsExists()
  26. {
  27. using (var connection = ConnectionUtil.CreateConnection())
  28. {
  29. var sql = @"
  30. IF OBJECT_ID(N'[Cap].[Published]',N'U') IS NOT NULL
  31. SELECT 'True'
  32. ELSE
  33. SELECT 'False'";
  34. var result = connection.QueryFirst<bool>(sql);
  35. Assert.Equal(true, result);
  36. }
  37. }
  38. [Fact]
  39. public void DatabaseTable_Queue_IsExists()
  40. {
  41. using (var connection = ConnectionUtil.CreateConnection())
  42. {
  43. var sql = @"
  44. IF OBJECT_ID(N'[Cap].[Queue]',N'U') IS NOT NULL
  45. SELECT 'True'
  46. ELSE
  47. SELECT 'False'";
  48. var result = connection.QueryFirst<bool>(sql);
  49. Assert.Equal(true, result);
  50. }
  51. }
  52. [Fact]
  53. public void DatabaseTable_Received_IsExists()
  54. {
  55. using (var connection = ConnectionUtil.CreateConnection())
  56. {
  57. var sql = @"
  58. IF OBJECT_ID(N'[Cap].[Received]',N'U') IS NOT NULL
  59. SELECT 'True'
  60. ELSE
  61. SELECT 'False'";
  62. var result = connection.QueryFirst<bool>(sql);
  63. Assert.Equal(true, result);
  64. }
  65. }
  66. }
  67. }