diff --git a/src/BuslyCLI.Console/Commands/Command/SendCommand.cs b/src/BuslyCLI.Console/Commands/Command/SendCommand.cs index 1094394..15aef63 100644 --- a/src/BuslyCLI.Console/Commands/Command/SendCommand.cs +++ b/src/BuslyCLI.Console/Commands/Command/SendCommand.cs @@ -40,8 +40,7 @@ await rawEndpoint.Dispatch( new TransportTransaction() ); - // TODO: Figure out why this causes connection closed errors with rabbitmq - // await rawEndpoint.ShutDownAndCleanUp(); + await rawEndpoint.ShutDownAndCleanUp(); return 0; } diff --git a/src/BuslyCLI.Console/Commands/Event/PublishCommand.cs b/src/BuslyCLI.Console/Commands/Event/PublishCommand.cs index f0896d8..c8bc3bd 100644 --- a/src/BuslyCLI.Console/Commands/Event/PublishCommand.cs +++ b/src/BuslyCLI.Console/Commands/Event/PublishCommand.cs @@ -45,8 +45,7 @@ await rawEndpoint.Dispatch( new TransportTransaction() ); - // TODO: Figure out why this causes connection closed errors with rabbitmq - // await rawEndpoint.ShutDownAndCleanUp(); + await rawEndpoint.ShutDownAndCleanUp(); return 0; } diff --git a/tests/BuslyCLI.Console.Tests/Commands/Command/SendCommandTests.cs b/tests/BuslyCLI.Console.Tests/Commands/Command/SendCommandTests.cs index b852db7..0ec4285 100644 --- a/tests/BuslyCLI.Console.Tests/Commands/Command/SendCommandTests.cs +++ b/tests/BuslyCLI.Console.Tests/Commands/Command/SendCommandTests.cs @@ -30,7 +30,7 @@ // [TestCase("Error: Option 'destination-endpoint' is defined but no value has been provided.", "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--message-body", "test", "--destination-endpoint")] // public async Task ShouldValidateRequiredOptions(string expectedSubstring, params string[] args) // { -// var result = _sut.Run(args); +// var result = await _sut.RunAsync([args]); // // Assert.That(result.ExitCode, Is.Not.EqualTo(0)); // Assert.That(result.Output, Does.Contain(expectedSubstring), $"Expected output to contain: {expectedSubstring}"); diff --git a/tests/BuslyCLI.Console.Tests/Commands/Transport/CurrentTransportTests.cs b/tests/BuslyCLI.Console.Tests/Commands/Transport/CurrentTransportTests.cs index 43cf0a9..42b7981 100644 --- a/tests/BuslyCLI.Console.Tests/Commands/Transport/CurrentTransportTests.cs +++ b/tests/BuslyCLI.Console.Tests/Commands/Transport/CurrentTransportTests.cs @@ -23,7 +23,7 @@ public void Setup() } [Test] - public void ShouldOutputCurrentTransport() + public async Task ShouldOutputCurrentTransport() { // Arrange var yamlFile = """ @@ -37,7 +37,7 @@ public void ShouldOutputCurrentTransport() using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run("transport", "current", "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "current", "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -48,7 +48,7 @@ public void ShouldOutputCurrentTransport() )); } [Test] - public void ShouldOutputCurrentTransportNotConfigured() + public async Task ShouldOutputCurrentTransportNotConfigured() { // Arrange var yamlFile = """ @@ -62,7 +62,7 @@ public void ShouldOutputCurrentTransportNotConfigured() using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run("transport", "current", "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "current", "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/Commands/Transport/DeleteTransportTests.cs b/tests/BuslyCLI.Console.Tests/Commands/Transport/DeleteTransportTests.cs index 9fb4879..8ab6903 100644 --- a/tests/BuslyCLI.Console.Tests/Commands/Transport/DeleteTransportTests.cs +++ b/tests/BuslyCLI.Console.Tests/Commands/Transport/DeleteTransportTests.cs @@ -23,7 +23,7 @@ public void Setup() } [Test] - public void ShouldBeIdempotentWhenDeletingNonExistingTransport() + public async Task ShouldBeIdempotentWhenDeletingNonExistingTransport() { // Arrange var yamlFile = """ @@ -38,14 +38,14 @@ public void ShouldBeIdempotentWhenDeletingNonExistingTransport() var nonExistingTransport = Guid.NewGuid().ToString(); // Act - var result = _sut.Run("transport", "delete", nonExistingTransport, "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "delete", nonExistingTransport, "--config", configFile.FilePath]); Assert.That(result.ExitCode, Is.EqualTo(0)); Assert.That(result.Output, Is.EqualTo($"Cannot delete transport {nonExistingTransport} since it doesn't exist in the config file.")); } [Test] - public void ShouldDeleteTransport() + public async Task ShouldDeleteTransport() { // Arrange var yamlFile = """ @@ -59,7 +59,7 @@ public void ShouldDeleteTransport() using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run("transport", "delete", "local-learning", "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "delete", "local-learning", "--config", configFile.FilePath]); Assert.That(result.ExitCode, Is.EqualTo(0)); Assert.That(result.Output, Is.EqualTo( diff --git a/tests/BuslyCLI.Console.Tests/Commands/Transport/ListTransportTests.cs b/tests/BuslyCLI.Console.Tests/Commands/Transport/ListTransportTests.cs index cb554b6..e9fcb2e 100644 --- a/tests/BuslyCLI.Console.Tests/Commands/Transport/ListTransportTests.cs +++ b/tests/BuslyCLI.Console.Tests/Commands/Transport/ListTransportTests.cs @@ -23,21 +23,21 @@ public void Setup() } [Test] - public void ShouldOutputAnEmptyGridWhenConfigFileIsEmptyYaml() + public async Task ShouldOutputAnEmptyGridWhenConfigFileIsEmptyYaml() { // Arrange var yamlFile = """ --- """; using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); - var result = _sut.Run("transport", "list", "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "list", "--config", configFile.FilePath]); Assert.That(result.ExitCode, Is.EqualTo(0)); Assert.That(result.Output, Is.EqualTo("CURRENT NAME TRANSPORT-TYPE")); } [Test] - public void ShouldOutputAnEmptyGridWhenTransportArrayIsEmpty() + public async Task ShouldOutputAnEmptyGridWhenTransportArrayIsEmpty() { // Arrange var yamlFile = """ @@ -45,13 +45,13 @@ public void ShouldOutputAnEmptyGridWhenTransportArrayIsEmpty() transports: """; using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); - var result = _sut.Run("transport", "list", "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "list", "--config", configFile.FilePath]); Assert.That(result.ExitCode, Is.EqualTo(0)); Assert.That(result.Output, Is.EqualTo("CURRENT NAME TRANSPORT-TYPE")); } [Test] - public void ShouldOutputASingleTransport() + public async Task ShouldOutputASingleTransport() { // Arrange var yamlFile = """ @@ -65,7 +65,7 @@ public void ShouldOutputASingleTransport() using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run("transport", "list", "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "list", "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/Commands/Transport/SetTransportTests.cs b/tests/BuslyCLI.Console.Tests/Commands/Transport/SetTransportTests.cs index 43c97a7..423382b 100644 --- a/tests/BuslyCLI.Console.Tests/Commands/Transport/SetTransportTests.cs +++ b/tests/BuslyCLI.Console.Tests/Commands/Transport/SetTransportTests.cs @@ -23,7 +23,7 @@ public void Setup() } [Test] - public void ShouldOutputAMessageWhenTransportDoesNotExist() + public async Task ShouldOutputAMessageWhenTransportDoesNotExist() { // Arrange var yamlFile = """ @@ -38,7 +38,7 @@ public void ShouldOutputAMessageWhenTransportDoesNotExist() var nonExistingTransport = $"{Guid.NewGuid():N}"; // Act - var result = _sut.Run("transport", "set", nonExistingTransport, "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "set", nonExistingTransport, "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -50,7 +50,7 @@ No transport exists with the name {nonExistingTransport}. } [Test] - public void ShouldOutputAMessageWhenTransportIsSet() + public async Task ShouldOutputAMessageWhenTransportIsSet() { // Arrange var yamlFile = """ @@ -67,7 +67,7 @@ public void ShouldOutputAMessageWhenTransportIsSet() using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run("transport", "set", "local-learning2", "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "set", "local-learning2", "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -79,7 +79,7 @@ Switched to transport "local-learning2". } [Test] - public void ShouldBeIdempotentWhenSettingTransportToTheAlreadyConfiguredTransport() + public async Task ShouldBeIdempotentWhenSettingTransportToTheAlreadyConfiguredTransport() { // Arrange var yamlFile = """ @@ -93,7 +93,7 @@ public void ShouldBeIdempotentWhenSettingTransportToTheAlreadyConfiguredTranspor using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run("transport", "set", "local-learning", "--config", configFile.FilePath); + var result = await _sut.RunAsync(["transport", "set", "local-learning", "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/EndToEnd/AmazonSQS/SendCommandAmazonSqsEndToEndAmazonSqsTests.cs b/tests/BuslyCLI.Console.Tests/EndToEnd/AmazonSQS/SendCommandAmazonSqsEndToEndAmazonSqsTests.cs index 600ca6b..c0b317c 100644 --- a/tests/BuslyCLI.Console.Tests/EndToEnd/AmazonSQS/SendCommandAmazonSqsEndToEndAmazonSqsTests.cs +++ b/tests/BuslyCLI.Console.Tests/EndToEnd/AmazonSQS/SendCommandAmazonSqsEndToEndAmazonSqsTests.cs @@ -51,14 +51,14 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--destination-endpoint", testEndpoint.EndpointName, "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -93,13 +93,13 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "event", "publish", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Events.OrderCreated", "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/EndToEnd/AzureServiceBus/SendCommandAzureServiceBusEndToEndTests.cs b/tests/BuslyCLI.Console.Tests/EndToEnd/AzureServiceBus/SendCommandAzureServiceBusEndToEndTests.cs index 4bb4a9e..6d4299d 100644 --- a/tests/BuslyCLI.Console.Tests/EndToEnd/AzureServiceBus/SendCommandAzureServiceBusEndToEndTests.cs +++ b/tests/BuslyCLI.Console.Tests/EndToEnd/AzureServiceBus/SendCommandAzureServiceBusEndToEndTests.cs @@ -48,14 +48,14 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--destination-endpoint", testEndpoint.EndpointName, "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -99,13 +99,13 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "event", "publish", "--content-type", "application/json", "--enclosed-message-type", eventType, "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/EndToEnd/AzureStorageQueues/SendCommandAzureStorageQueuesEndToEndTests.cs b/tests/BuslyCLI.Console.Tests/EndToEnd/AzureStorageQueues/SendCommandAzureStorageQueuesEndToEndTests.cs index 95b492c..7d2f35d 100644 --- a/tests/BuslyCLI.Console.Tests/EndToEnd/AzureStorageQueues/SendCommandAzureStorageQueuesEndToEndTests.cs +++ b/tests/BuslyCLI.Console.Tests/EndToEnd/AzureStorageQueues/SendCommandAzureStorageQueuesEndToEndTests.cs @@ -49,14 +49,14 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--destination-endpoint", testEndpoint.EndpointName, "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -89,13 +89,13 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "event", "publish", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Events.OrderCreated", "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/EndToEnd/Learning/SendCommandEndToEndLearningTests.cs b/tests/BuslyCLI.Console.Tests/EndToEnd/Learning/SendCommandEndToEndLearningTests.cs index 646cd66..0452f03 100644 --- a/tests/BuslyCLI.Console.Tests/EndToEnd/Learning/SendCommandEndToEndLearningTests.cs +++ b/tests/BuslyCLI.Console.Tests/EndToEnd/Learning/SendCommandEndToEndLearningTests.cs @@ -49,14 +49,14 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--destination-endpoint", testEndpoint.EndpointName, "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -89,13 +89,13 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "event", "publish", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Events.OrderCreated", "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/EndToEnd/PostgreSql/SendCommandPostgreSqlEndToEndTests.cs b/tests/BuslyCLI.Console.Tests/EndToEnd/PostgreSql/SendCommandPostgreSqlEndToEndTests.cs index c7a2497..043336f 100644 --- a/tests/BuslyCLI.Console.Tests/EndToEnd/PostgreSql/SendCommandPostgreSqlEndToEndTests.cs +++ b/tests/BuslyCLI.Console.Tests/EndToEnd/PostgreSql/SendCommandPostgreSqlEndToEndTests.cs @@ -50,14 +50,14 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--destination-endpoint", testEndpoint.EndpointName, "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -90,13 +90,13 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "event", "publish", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Events.OrderCreated", "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/EndToEnd/RabbitMQ/SendCommandRabbitMqEndToEndTests.cs b/tests/BuslyCLI.Console.Tests/EndToEnd/RabbitMQ/SendCommandRabbitMqEndToEndTests.cs index 418a58c..b6452b7 100644 --- a/tests/BuslyCLI.Console.Tests/EndToEnd/RabbitMQ/SendCommandRabbitMqEndToEndTests.cs +++ b/tests/BuslyCLI.Console.Tests/EndToEnd/RabbitMQ/SendCommandRabbitMqEndToEndTests.cs @@ -51,14 +51,14 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--destination-endpoint", testEndpoint.EndpointName, "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -93,13 +93,13 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "event", "publish", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Events.OrderCreated", "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); diff --git a/tests/BuslyCLI.Console.Tests/EndToEnd/SqlServer/SendCommandSqlServerEndToEndTests.cs b/tests/BuslyCLI.Console.Tests/EndToEnd/SqlServer/SendCommandSqlServerEndToEndTests.cs index 18027d4..bce2d98 100644 --- a/tests/BuslyCLI.Console.Tests/EndToEnd/SqlServer/SendCommandSqlServerEndToEndTests.cs +++ b/tests/BuslyCLI.Console.Tests/EndToEnd/SqlServer/SendCommandSqlServerEndToEndTests.cs @@ -49,14 +49,14 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--destination-endpoint", testEndpoint.EndpointName, "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0)); @@ -89,13 +89,13 @@ await RunWithTestEndpoint(async testEndpoint => using var configFile = new TestableNServiceBusConfigurationFile(yamlFile); // Act - var result = _sut.Run( + var result = await _sut.RunAsync([ "event", "publish", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Events.OrderCreated", "--message-body", json, - "--config", configFile.FilePath); + "--config", configFile.FilePath]); // Assert Assert.That(result.ExitCode, Is.EqualTo(0));