Skip to content

Commit

Permalink
Remove queue cleanup from When_configured_error_queue_includes_catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmarbach committed Jan 29, 2020
1 parent 5c0c9b1 commit 07319eb
Showing 1 changed file with 17 additions and 47 deletions.
Expand Up @@ -16,53 +16,23 @@ public class When_configured_error_queue_includes_catalog : MultiCatalogAcceptan
[Test]
public async Task Error_should_be_sent_to_table_in_configured_catalog()
{
await PurgeAllQueues().ConfigureAwait(false);

try
{
// makes sure error spy queue is available
await Scenario.Define<Context>()
.WithEndpoint<ErrorSpy>()
.Done(c => c.EndpointsStarted)
.Run();

var ctx = await Scenario.Define<Context>()
.WithEndpoint<Sender>(b =>
{
b.DoNotFailOnErrorMessages();
b.When((bus, c) => bus.SendLocal(new Message()));
})
.WithEndpoint<ErrorSpy>()
.Done(c => c.FailedMessageProcessed)
.Run();

Assert.True(ctx.FailedMessageProcessed, "Message should be moved to error queue in custom schema");
}
finally
{
await PurgeAllQueues().ConfigureAwait(false);
}
}

static Task PurgeAllQueues()
{
return Task.WhenAll(PurgeQueues(SenderConnectionString), PurgeQueues(SpyConnectionString));
}

static async Task PurgeQueues(string connectionString)
{
var errorSpyName = AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(ErrorSpy));

using (var conn = new SqlConnection(connectionString))
{
await conn.OpenAsync().ConfigureAwait(false);
var command = conn.CreateCommand();
command.CommandText = $@"IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[{errorSpyName}]') AND type in (N'U'))
BEGIN
DELETE FROM dbo.{errorSpyName}
END";
await command.ExecuteNonQueryAsync().ConfigureAwait(false);
}
// makes sure error spy queue is available to avoid race on creating the spy queue
await Scenario.Define<Context>()
.WithEndpoint<ErrorSpy>()
.Done(c => c.EndpointsStarted)
.Run();

var ctx = await Scenario.Define<Context>()
.WithEndpoint<Sender>(b =>
{
b.DoNotFailOnErrorMessages();
b.When((bus, c) => bus.SendLocal(new Message()));
})
.WithEndpoint<ErrorSpy>()
.Done(c => c.FailedMessageProcessed)
.Run();

Assert.True(ctx.FailedMessageProcessed, "Message should be moved to error queue in custom schema");
}

public class Context : ScenarioContext
Expand Down

0 comments on commit 07319eb

Please sign in to comment.