diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7edb0ba076..5e2fa80943 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -58,11 +58,17 @@ jobs:
Linux-nuget-
- name: Build
run: dotnet build --configuration Release
+ - name: Enable Automated Test Artifact Uploads
+ uses: actions/github-script@v9
+ with:
+ script: |
+ core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']);
+ core.exportVariable('ACTIONS_RESULTS_URL', process.env['ACTIONS_RESULTS_URL']);
- name: Core Tests
run: |
- dotnet test tests/Paramore.Brighter.Core.Tests/Paramore.Brighter.Core.Tests.csproj --filter "Fragile!=CI" -c Release --logger GitHubActions --no-restore --no-build --verbosity d
- dotnet test tests/Paramore.Brighter.Extensions.Tests/Paramore.Brighter.Extensions.Tests.csproj -c Release --no-restore --logger GitHubActions --no-build --verbosity d
- dotnet test tests/Paramore.Brighter.Transforms.Adaptors.Tests/Paramore.Brighter.Transforms.Adaptors.Tests.csproj -c Release --no-restore --logger GitHubActions --no-build --verbosity d
+ dotnet test --project tests/Paramore.Brighter.Core.Tests/Paramore.Brighter.Core.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" -c Release --no-restore --no-build --verbosity d
+ dotnet test --project tests/Paramore.Brighter.Extensions.Tests/Paramore.Brighter.Extensions.Tests.csproj -c Release --no-restore --no-build --verbosity d
+ dotnet test --project tests/Paramore.Brighter.Transforms.Adaptors.Tests/Paramore.Brighter.Transforms.Adaptors.Tests.csproj -c Release --no-restore --no-build --verbosity d
- name: Upload packages as artifacts
uses: actions/upload-artifact@v7
@@ -104,7 +110,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: In Memory Transport Tests
- run: dotnet test ./tests/Paramore.Brighter.InMemory.Tests/Paramore.Brighter.InMemory.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.InMemory.Tests/Paramore.Brighter.InMemory.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
hangfire:
runs-on: ubuntu-latest
@@ -122,7 +128,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: Hangfire Tests
- run: dotnet test ./tests/Paramore.Brighter.Hangfire.Tests/Paramore.Brighter.Hangfire.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.Hangfire.Tests/Paramore.Brighter.Hangfire.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
quartz:
runs-on: ubuntu-latest
@@ -140,7 +146,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: Quartz Tests
- run: dotnet test ./tests/Paramore.Brighter.Quartz.Tests/Paramore.Brighter.Quartz.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.Quartz.Tests/Paramore.Brighter.Quartz.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
tickerq:
runs-on: ubuntu-latest
@@ -158,7 +164,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: TickerQ Tests
- run: dotnet test ./tests/Paramore.Brighter.TickerQ.Tests/Paramore.Brighter.TickerQ.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.TickerQ.Tests/Paramore.Brighter.TickerQ.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
redis-ci:
runs-on: ubuntu-latest
@@ -190,7 +196,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: Redis Transport Tests
- run: dotnet test ./tests/Paramore.Brighter.Redis.Tests/Paramore.Brighter.Redis.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.Redis.Tests/Paramore.Brighter.Redis.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
mqtt-ci:
runs-on: ubuntu-latest
@@ -215,7 +221,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: MQTT Transport Tests
- run: dotnet test ./tests/Paramore.Brighter.MQTT.Tests/Paramore.Brighter.MQTT.Tests.csproj --filter "Category=MQTT&Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.MQTT.Tests/Paramore.Brighter.MQTT.Tests.csproj --treenode-filter "/*/*/*/*[Category=MQTT]&[Fragile!=CI]" --configuration Release --blame -v n
rabbitmq-ci:
runs-on: ubuntu-latest
@@ -245,9 +251,9 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: RMQ Async Transport Tests
- run: dotnet test ./tests/Paramore.Brighter.RMQ.Async.Tests/Paramore.Brighter.RMQ.Async.Tests.csproj --filter "Fragile!=CI&Requires!=Docker-mTLS" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.RMQ.Async.Tests/Paramore.Brighter.RMQ.Async.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]&[Requires!=Docker-mTLS]" --configuration Release --blame -v n
- name: RMQ Sync Transport Tests
- run: dotnet test ./tests/Paramore.Brighter.RMQ.Sync.Tests/Paramore.Brighter.RMQ.Sync.Tests.csproj --filter "Fragile!=CI&Requires!=Docker-mTLS" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.RMQ.Sync.Tests/Paramore.Brighter.RMQ.Sync.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]&[Requires!=Docker-mTLS]" --configuration Release --blame -v n
kafka-ci:
runs-on: ubuntu-latest
@@ -322,7 +328,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: Kafka Transport Tests
- run: dotnet test ./tests/Paramore.Brighter.Kafka.Tests/Paramore.Brighter.Kafka.Tests.csproj --filter "Category=Kafka&Category!=Confluent&Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.Kafka.Tests/Paramore.Brighter.Kafka.Tests.csproj --treenode-filter "/*/*/*/*[Category=Kafka]&[Category!=Confluent]&[Fragile!=CI]" --configuration Release --blame -v n
postgres-ci:
runs-on: ubuntu-latest
@@ -353,7 +359,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: Postgres Tests
- run: dotnet test ./tests/Paramore.Brighter.PostgresSQL.Tests/Paramore.Brighter.PostgresSQL.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.PostgresSQL.Tests/Paramore.Brighter.PostgresSQL.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
sqlserver-ci:
runs-on: ubuntu-latest
@@ -379,7 +385,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: MSSQL Tests
- run: dotnet test ./tests/Paramore.Brighter.MSSQL.Tests/Paramore.Brighter.MSSQL.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.MSSQL.Tests/Paramore.Brighter.MSSQL.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
mysql-ci:
runs-on: ubuntu-latest
@@ -414,7 +420,7 @@ jobs:
sleep 1
done
- name: MySQL Tests
- run: dotnet test ./tests/Paramore.Brighter.MySQL.Tests/Paramore.Brighter.MySQL.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.MySQL.Tests/Paramore.Brighter.MySQL.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
dynamo-ci:
runs-on: ubuntu-latest
@@ -439,8 +445,8 @@ jobs:
run: dotnet restore
- name: DynamoDB Tests
run: |
- dotnet test ./tests/Paramore.Brighter.DynamoDB.Tests/Paramore.Brighter.DynamoDB.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
- dotnet test ./tests/Paramore.Brighter.DynamoDB.V4.Tests/Paramore.Brighter.DynamoDB.V4.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ dotnet test --project ./tests/Paramore.Brighter.DynamoDB.Tests/Paramore.Brighter.DynamoDB.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
+ dotnet test --project ./tests/Paramore.Brighter.DynamoDB.V4.Tests/Paramore.Brighter.DynamoDB.V4.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
localstack-ci:
runs-on: ubuntu-latest
@@ -477,8 +483,8 @@ jobs:
Linux-nuget-
- name: AWS Tests
run: |
- dotnet test ./tests/Paramore.Brighter.AWS.Tests/Paramore.Brighter.AWS.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
- dotnet test ./tests/Paramore.Brighter.AWS.V4.Tests/Paramore.Brighter.AWS.V4.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ dotnet test --project ./tests/Paramore.Brighter.AWS.Tests/Paramore.Brighter.AWS.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
+ dotnet test --project ./tests/Paramore.Brighter.AWS.V4.Tests/Paramore.Brighter.AWS.V4.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
aws-ci:
runs-on: ubuntu-latest
@@ -511,8 +517,8 @@ jobs:
aws-region: eu-west-1
- name: AWS SNS, SQS and S3 Tests
run: |
- dotnet test ./tests/Paramore.Brighter.AWS.Tests/Paramore.Brighter.AWS.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
- dotnet test ./tests/Paramore.Brighter.AWS.V4.Tests/Paramore.Brighter.AWS.V4.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ dotnet test --project ./tests/Paramore.Brighter.AWS.Tests/Paramore.Brighter.AWS.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
+ dotnet test --project ./tests/Paramore.Brighter.AWS.V4.Tests/Paramore.Brighter.AWS.V4.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
- name: Cleanup orphaned test resources
if: always()
run: |
@@ -551,8 +557,8 @@ jobs:
aws-region: eu-west-1
- name: Scheduler Tests
run: |
- dotnet test ./tests/Paramore.Brighter.AWSScheduler.Tests/Paramore.Brighter.AWSScheduler.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
- dotnet test ./tests/Paramore.Brighter.AWSScheduler.V4.Tests/Paramore.Brighter.AWSScheduler.V4.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ dotnet test --project ./tests/Paramore.Brighter.AWSScheduler.Tests/Paramore.Brighter.AWSScheduler.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
+ dotnet test --project ./tests/Paramore.Brighter.AWSScheduler.V4.Tests/Paramore.Brighter.AWSScheduler.V4.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
- name: Cleanup orphaned test resources
if: always()
run: |
@@ -576,7 +582,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: Sqlite Tests
- run: dotnet test ./tests/Paramore.Brighter.Sqlite.Tests/Paramore.Brighter.Sqlite.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.Sqlite.Tests/Paramore.Brighter.Sqlite.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
azure-ci:
runs-on: ubuntu-latest
@@ -598,7 +604,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: Azure Tests
- run: dotnet test ./tests/Paramore.Brighter.AzureServiceBus.Tests/Paramore.Brighter.AzureServiceBus.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.AzureServiceBus.Tests/Paramore.Brighter.AzureServiceBus.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
mongodb-ci:
runs-on: ubuntu-latest
@@ -630,7 +636,7 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: MongoDB Tests
- run: dotnet test ./tests/Paramore.Brighter.MongoDb.Tests/Paramore.Brighter.MongoDb.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.MongoDb.Tests/Paramore.Brighter.MongoDb.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
gcp-ci:
runs-on: ubuntu-latest
@@ -667,7 +673,7 @@ jobs:
run: dotnet restore
- name: GCP Tests
- run: dotnet test ./tests/Paramore.Brighter.Gcp.Tests/Paramore.Brighter.Gcp.Tests.csproj --filter "Category!=Spanner&Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --logger GitHubActions --blame -v n
+ run: dotnet test --project ./tests/Paramore.Brighter.Gcp.Tests/Paramore.Brighter.Gcp.Tests.csproj --treenode-filter "/*/*/*/*[Category!=Spanner]&[Fragile!=CI]" --configuration Release --blame -v n
# TODO: Rafael Andrade is working on how to run RocketMQ on GHA
# rocketmq-ci:
@@ -731,4 +737,4 @@ jobs:
# run: dotnet restore
#
# - name: RocketMQ Tests
-# run: dotnet test ./tests/Paramore.Brighter.RocketMQ.Tests/Paramore.Brighter.RocketMQ.Tests.csproj --filter "Fragile!=CI" --configuration Release --logger "console;verbosity=normal" --blame -v n
+# run: dotnet test --project ./tests/Paramore.Brighter.RocketMQ.Tests/Paramore.Brighter.RocketMQ.Tests.csproj --treenode-filter "/*/*/*/*[Fragile!=CI]" --configuration Release --blame -v n
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 749ad4b279..a5ba6af373 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -86,6 +86,7 @@
+
@@ -140,15 +141,8 @@
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
-
@@ -194,4 +188,4 @@
runtime; build; native; contentfiles; analyzers
-
\ No newline at end of file
+
diff --git a/global.json b/global.json
new file mode 100644
index 0000000000..3140116df3
--- /dev/null
+++ b/global.json
@@ -0,0 +1,5 @@
+{
+ "test": {
+ "runner": "Microsoft.Testing.Platform"
+ }
+}
diff --git a/samples/TaskQueue/AWSTaskQueue/GreetingsSender/Program.cs b/samples/TaskQueue/AWSTaskQueue/GreetingsSender/Program.cs
index 1e41161000..2de4adae1c 100644
--- a/samples/TaskQueue/AWSTaskQueue/GreetingsSender/Program.cs
+++ b/samples/TaskQueue/AWSTaskQueue/GreetingsSender/Program.cs
@@ -63,7 +63,7 @@ static async Task Main(string[] args)
}
});
- var producerRegistry = new SnsProducerRegistryFactory(
+ var producerRegistry = await new SnsProducerRegistryFactory(
awsConnection,
[
new SnsPublication
@@ -79,7 +79,7 @@ static async Task Main(string[] args)
}
}
]
- ).Create();
+ ).CreateAsync();
serviceCollection
.AddBrighter()
diff --git a/src/Paramore.Brighter.MessagingGateway.AWSSQS.V4/SqsMessageConsumer.cs b/src/Paramore.Brighter.MessagingGateway.AWSSQS.V4/SqsMessageConsumer.cs
index 5fa6a6b3db..10c079fafb 100644
--- a/src/Paramore.Brighter.MessagingGateway.AWSSQS.V4/SqsMessageConsumer.cs
+++ b/src/Paramore.Brighter.MessagingGateway.AWSSQS.V4/SqsMessageConsumer.cs
@@ -435,12 +435,12 @@ public async ValueTask DisposeAsync()
if (_deadLetterProducer?.IsValueCreated == true && _deadLetterProducer.Value is IAsyncDisposable deadLetterAsync)
await deadLetterAsync.DisposeAsync();
else if (_deadLetterProducer?.IsValueCreated == true)
- _deadLetterProducer.Value?.Dispose();
+ await _deadLetterProducer.Value!.DisposeAsync();
if (_invalidMessageProducer?.IsValueCreated == true && _invalidMessageProducer.Value is IAsyncDisposable invalidAsync)
await invalidAsync.DisposeAsync();
else if (_invalidMessageProducer?.IsValueCreated == true)
- _invalidMessageProducer.Value?.Dispose();
+ await _invalidMessageProducer.Value!.DisposeAsync();
GC.SuppressFinalize(this);
}
diff --git a/src/Paramore.Brighter.MessagingGateway.AWSSQS/SqsMessageConsumer.cs b/src/Paramore.Brighter.MessagingGateway.AWSSQS/SqsMessageConsumer.cs
index 04dd0e7d83..1100b8a2f3 100644
--- a/src/Paramore.Brighter.MessagingGateway.AWSSQS/SqsMessageConsumer.cs
+++ b/src/Paramore.Brighter.MessagingGateway.AWSSQS/SqsMessageConsumer.cs
@@ -442,12 +442,12 @@ public async ValueTask DisposeAsync()
if (_deadLetterProducer?.IsValueCreated == true && _deadLetterProducer.Value is IAsyncDisposable deadLetterAsync)
await deadLetterAsync.DisposeAsync();
else if (_deadLetterProducer?.IsValueCreated == true)
- _deadLetterProducer.Value?.Dispose();
+ await _deadLetterProducer.Value!.DisposeAsync();
if (_invalidMessageProducer?.IsValueCreated == true && _invalidMessageProducer.Value is IAsyncDisposable invalidAsync)
await invalidAsync.DisposeAsync();
else if (_invalidMessageProducer?.IsValueCreated == true)
- _invalidMessageProducer.Value?.Dispose();
+ await _invalidMessageProducer.Value!.DisposeAsync();
GC.SuppressFinalize(this);
}
diff --git a/src/Paramore.Brighter/PipelineBuilder.cs b/src/Paramore.Brighter/PipelineBuilder.cs
index 2d0eab5e65..4d52c8ec9f 100644
--- a/src/Paramore.Brighter/PipelineBuilder.cs
+++ b/src/Paramore.Brighter/PipelineBuilder.cs
@@ -45,9 +45,10 @@ public partial class PipelineBuilder : IAmAPipelineBuilder,
private readonly InboxConfiguration? _inboxConfiguration;
private readonly IAmAHandlerFactoryAsync? _asyncHandlerFactory;
private readonly List _instanceScopes = new List();
- //GLOBAL! cache of handler attributes - won't change post-startup so avoid re-calculation. Method to clear cache below (if a broken test brought you here)
- private static readonly ConcurrentDictionary> s_preAttributesMemento = new ConcurrentDictionary>();
- private static readonly ConcurrentDictionary> s_postAttributesMemento = new ConcurrentDictionary>();
+ //GLOBAL cache of handler attributes — derived from reflection so immutable post-startup.
+ //Values are materialized into IReadOnlyList<> so concurrent reads are thread-safe.
+ private static readonly ConcurrentDictionary> s_preAttributesMemento = new ConcurrentDictionary>();
+ private static readonly ConcurrentDictionary> s_postAttributesMemento = new ConcurrentDictionary>();
///
/// Used to build a pipeline of handlers from the target handler and the attributes on that
@@ -272,32 +273,48 @@ private IHandleRequests BuildPipeline(RequestHandler implici
implicitHandler.Context = requestContext;
- if (!s_preAttributesMemento.TryGetValue(implicitHandler.Name.ToString(),
- out IOrderedEnumerable? preAttributes))
+ IReadOnlyList? preAttributes = null;
+ var shouldCachePreAttributes = _inboxConfiguration == null;
+
+ if (shouldCachePreAttributes)
+ {
+ s_preAttributesMemento.TryGetValue(implicitHandler.Name.ToString(),
+ out preAttributes);
+ }
+
+ if (preAttributes is null)
{
- preAttributes =
+ var orderedPreAttributes =
implicitHandler.FindHandlerMethod()
.GetOtherHandlersInPipeline()
.Where(attribute => attribute.Timing == HandlerTiming.Before)
.OrderByDescending(attribute => attribute.Step);
- AddGlobalInboxAttributes(ref preAttributes, implicitHandler);
+ AddGlobalInboxAttributes(ref orderedPreAttributes, implicitHandler);
- s_preAttributesMemento.TryAdd(implicitHandler.Name.ToString(), preAttributes);
+ preAttributes = orderedPreAttributes.ToList().AsReadOnly();
+ if (shouldCachePreAttributes)
+ {
+ s_preAttributesMemento.TryAdd(implicitHandler.Name.ToString(), preAttributes);
+ }
}
var firstInPipeline = PushOntoPipeline(preAttributes, implicitHandler, requestContext, instanceScope);
if (!s_postAttributesMemento.TryGetValue(implicitHandler.Name.ToString(),
- out IOrderedEnumerable? postAttributes))
+ out IReadOnlyList? postAttributes))
{
postAttributes =
implicitHandler.FindHandlerMethod()
.GetOtherHandlersInPipeline()
.Where(attribute => attribute.Timing == HandlerTiming.After)
- .OrderByDescending(attribute => attribute.Step);
+ .OrderByDescending(attribute => attribute.Step)
+ .ToList()
+ .AsReadOnly();
+
+ s_postAttributesMemento.TryAdd(implicitHandler.Name.ToString(), postAttributes);
}
AppendToPipeline(postAttributes, implicitHandler, requestContext, instanceScope);
@@ -315,29 +332,45 @@ private IHandleRequestsAsync BuildAsyncPipeline(RequestHandlerAsync? preAttributes))
+ IReadOnlyList? preAttributes = null;
+ var shouldCachePreAttributes = _inboxConfiguration == null;
+
+ if (shouldCachePreAttributes)
+ {
+ s_preAttributesMemento.TryGetValue(implicitHandler.Name.ToString(), out preAttributes);
+ }
+
+ if (preAttributes is null)
{
- preAttributes =
+ var orderedPreAttributes =
implicitHandler.FindHandlerMethod()
.GetOtherHandlersInPipeline()
.Where(attribute => attribute.Timing == HandlerTiming.Before)
.OrderByDescending(attribute => attribute.Step);
- AddGlobalInboxAttributesAsync(ref preAttributes, implicitHandler);
+ AddGlobalInboxAttributesAsync(ref orderedPreAttributes, implicitHandler);
- s_preAttributesMemento.TryAdd(implicitHandler.Name.ToString(), preAttributes);
+ preAttributes = orderedPreAttributes.ToList().AsReadOnly();
+ if (shouldCachePreAttributes)
+ {
+ s_preAttributesMemento.TryAdd(implicitHandler.Name.ToString(), preAttributes);
+ }
}
var firstInPipeline = PushOntoAsyncPipeline(preAttributes, implicitHandler, requestContext, instanceScope, continueOnCapturedContext);
- if (!s_postAttributesMemento.TryGetValue(implicitHandler.Name.ToString(), out IOrderedEnumerable? postAttributes))
+ if (!s_postAttributesMemento.TryGetValue(implicitHandler.Name.ToString(), out IReadOnlyList? postAttributes))
{
postAttributes =
implicitHandler.FindHandlerMethod()
.GetOtherHandlersInPipeline()
.Where(attribute => attribute.Timing == HandlerTiming.After)
- .OrderByDescending(attribute => attribute.Step);
+ .OrderByDescending(attribute => attribute.Step)
+ .ToList()
+ .AsReadOnly();
+
+ s_postAttributesMemento.TryAdd(implicitHandler.Name.ToString(), postAttributes);
}
AppendToAsyncPipeline(postAttributes, implicitHandler, requestContext, instanceScope);
diff --git a/src/Paramore.Brighter/RequestHandler.cs b/src/Paramore.Brighter/RequestHandler.cs
index c4a1ed0804..420ed5bce1 100644
--- a/src/Paramore.Brighter/RequestHandler.cs
+++ b/src/Paramore.Brighter/RequestHandler.cs
@@ -73,6 +73,9 @@ public abstract partial class RequestHandler(InstrumentationOptions in
/// The successor.
public void SetSuccessor(IHandleRequests successor)
{
+ if (this == successor)
+ return;
+
_successor = successor;
}
diff --git a/src/Paramore.Brighter/TransformPipelineBuilder.cs b/src/Paramore.Brighter/TransformPipelineBuilder.cs
index 3329b35205..bdf1683e4a 100644
--- a/src/Paramore.Brighter/TransformPipelineBuilder.cs
+++ b/src/Paramore.Brighter/TransformPipelineBuilder.cs
@@ -53,12 +53,13 @@ public partial class TransformPipelineBuilder
private readonly IAmAMessageTransformerFactory _messageTransformerFactory;
private readonly InstrumentationOptions _instrumentationOptions;
- //GLOBAL! Cache of message mapper transform attributes. This will not be recalculated post start up. Method to clear cache below (if a broken test brought you here).
- private static readonly ConcurrentDictionary> s_wrapTransformsMemento =
- new ConcurrentDictionary>();
+ //GLOBAL cache of message mapper transform attributes — derived from reflection so immutable post-startup.
+ //Values are materialized into IReadOnlyList<> so concurrent reads are thread-safe.
+ private static readonly ConcurrentDictionary> s_wrapTransformsMemento =
+ new ConcurrentDictionary>();
- private static readonly ConcurrentDictionary> s_unWrapTransformsMemento =
- new ConcurrentDictionary>();
+ private static readonly ConcurrentDictionary> s_unWrapTransformsMemento =
+ new ConcurrentDictionary>();
///
/// Creates an instance of a transform pipeline builder.
@@ -220,6 +221,9 @@ private IEnumerable BuildTransformPipeline(IEnum
return new TransformPipelineDescription(mapperType, isDefault, wrapTransforms, unwrapTransforms);
}
+ ///
+ /// Clears any cached transform pipeline definitions.
+ ///
public static void ClearPipelineCache()
{
s_wrapTransformsMemento.Clear();
@@ -233,14 +237,16 @@ private IAmAMessageMapper FindMessageMapper() where TRequest
return messageMapper;
}
- private IOrderedEnumerable FindWrapTransforms(IAmAMessageMapper messageMapper) where T : class, IRequest
+ private IReadOnlyList FindWrapTransforms(IAmAMessageMapper messageMapper) where T : class, IRequest
{
var key = messageMapper.GetType().Name;
- if (!s_wrapTransformsMemento.TryGetValue(key, out IOrderedEnumerable? transformAttributes))
+ if (!s_wrapTransformsMemento.TryGetValue(key, out IReadOnlyList? transformAttributes))
{
transformAttributes = FindMapToMessage(messageMapper)
.GetOtherWrapsInPipeline()
- .OrderByDescending(attribute => attribute.Step);
+ .OrderByDescending(attribute => attribute.Step)
+ .ToList()
+ .AsReadOnly();
s_wrapTransformsMemento.TryAdd(key, transformAttributes);
}
@@ -248,14 +254,16 @@ private IOrderedEnumerable FindWrapTransforms(IAmAMessageM
return transformAttributes;
}
- private IOrderedEnumerable FindUnwrapTransforms(IAmAMessageMapper messageMapper) where T : class, IRequest
+ private IReadOnlyList FindUnwrapTransforms(IAmAMessageMapper messageMapper) where T : class, IRequest
{
var key = messageMapper.GetType().Name;
- if (!s_unWrapTransformsMemento.TryGetValue(key, out IOrderedEnumerable? transformAttributes))
+ if (!s_unWrapTransformsMemento.TryGetValue(key, out IReadOnlyList? transformAttributes))
{
transformAttributes = FindMapToRequest(messageMapper)
.GetOtherUnwrapsInPipeline()
- .OrderByDescending(attribute => attribute.Step);
+ .OrderByDescending(attribute => attribute.Step)
+ .ToList()
+ .AsReadOnly();
s_unWrapTransformsMemento.TryAdd(key, transformAttributes);
}
diff --git a/src/Paramore.Brighter/TransformPipelineBuilderAsync.cs b/src/Paramore.Brighter/TransformPipelineBuilderAsync.cs
index 1934bd203e..dca503a5eb 100644
--- a/src/Paramore.Brighter/TransformPipelineBuilderAsync.cs
+++ b/src/Paramore.Brighter/TransformPipelineBuilderAsync.cs
@@ -53,12 +53,13 @@ public partial class TransformPipelineBuilderAsync
private readonly IAmAMessageTransformerFactoryAsync _messageTransformerFactoryAsync;
private readonly InstrumentationOptions _instrumentationOptions;
- //GLOBAL! Cache of message mapper transform attributes. This will not be recalculated post start up. Method to clear cache below (if a broken test brought you here).
- private static readonly ConcurrentDictionary> s_wrapTransformsMemento =
- new ConcurrentDictionary>();
+ //GLOBAL cache of message mapper transform attributes — derived from reflection so immutable post-startup.
+ //Values are materialized into IReadOnlyList<> so concurrent reads are thread-safe.
+ private static readonly ConcurrentDictionary> s_wrapTransformsMemento =
+ new ConcurrentDictionary>();
- private static readonly ConcurrentDictionary> s_unWrapTransformsMemento =
- new ConcurrentDictionary>();
+ private static readonly ConcurrentDictionary> s_unWrapTransformsMemento =
+ new ConcurrentDictionary>();
///
/// Creates an instance of a transform pipeline builder.
@@ -183,6 +184,9 @@ private IEnumerable BuildTransformPipeline(
return transforms;
}
+ ///
+ /// Clears any cached async transform pipeline definitions.
+ ///
public static void ClearPipelineCache()
{
s_wrapTransformsMemento.Clear();
@@ -196,20 +200,38 @@ private IAmAMessageMapperAsync FindMessageMapper() where TRe
return messageMapper;
}
- private IOrderedEnumerable FindWrapTransforms(IAmAMessageMapperAsync messageMapper) where T : class, IRequest
+ private IReadOnlyList FindWrapTransforms(IAmAMessageMapperAsync messageMapper) where T : class, IRequest
{
var key = messageMapper.GetType().Name;
- return s_wrapTransformsMemento.GetOrAdd(key, s => FindMapToMessage(messageMapper)
- .GetOtherWrapsInPipeline()
- .OrderByDescending(attribute => attribute.Step));
+ if (!s_wrapTransformsMemento.TryGetValue(key, out IReadOnlyList? transformAttributes))
+ {
+ transformAttributes = FindMapToMessage(messageMapper)
+ .GetOtherWrapsInPipeline()
+ .OrderByDescending(attribute => attribute.Step)
+ .ToList()
+ .AsReadOnly();
+
+ s_wrapTransformsMemento.TryAdd(key, transformAttributes);
+ }
+
+ return transformAttributes;
}
- private IOrderedEnumerable FindUnwrapTransforms(IAmAMessageMapperAsync messageMapper) where T : class, IRequest
+ private IReadOnlyList FindUnwrapTransforms(IAmAMessageMapperAsync messageMapper) where T : class, IRequest
{
var key = messageMapper.GetType().Name;
- return s_unWrapTransformsMemento.GetOrAdd(key, s => FindMapToRequest(messageMapper)
- .GetOtherUnwrapsInPipeline()
- .OrderByDescending(attribute => attribute.Step));
+ if (!s_unWrapTransformsMemento.TryGetValue(key, out IReadOnlyList? transformAttributes))
+ {
+ transformAttributes = FindMapToRequest(messageMapper)
+ .GetOtherUnwrapsInPipeline()
+ .OrderByDescending(attribute => attribute.Step)
+ .ToList()
+ .AsReadOnly();
+
+ s_unWrapTransformsMemento.TryAdd(key, transformAttributes);
+ }
+
+ return transformAttributes;
}
private MethodInfo FindMapToMessage(IAmAMessageMapperAsync messageMapper) where TRequest : class, IRequest
diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props
index b7c2d28040..cf830843ec 100644
--- a/tests/Directory.Build.props
+++ b/tests/Directory.Build.props
@@ -1,10 +1,14 @@
false
+ enable
net9.0;net10.0
net9.0
true
false
false
+
+
+
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
index d7e7bd9022..d5119c0365 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
@@ -6,23 +6,23 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTestsAsync : IAsyncDisposable
{
- private readonly SnsMessageProducer _messageProducer;
- private readonly SqsMessageConsumer _consumer;
- private readonly string _topicName;
- private readonly ChannelFactory _channelFactory;
+ private SnsMessageProducer _messageProducer;
+ private SqsMessageConsumer _consumer;
+ private string _topicName;
+ private ChannelFactory _channelFactory;
private readonly ContentType _contentType = new(MediaTypeNames.Text.Plain);
private const int BufferSize = 3;
private const int MessageCount = 4;
- public SqsBufferedConsumerTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var awsConnection = GatewayFactory.CreateFactory();
@@ -34,7 +34,7 @@ public SqsBufferedConsumerTestsAsync()
//we need the channel to create the queues and notifications
var routingKey = new RoutingKey(_topicName);
- var channel = _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
+ var channel = await _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
subscriptionName: new SubscriptionName(channelName),
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
@@ -45,9 +45,9 @@ public SqsBufferedConsumerTestsAsync()
type: SqsType.Fifo,
deduplicationScope: DeduplicationScope.MessageGroup,
fifoThroughputLimit: FifoThroughputLimit.PerMessageGroupId,
- tags: new Dictionary { { "Environment", "Test" } }),
+ tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- makeChannels: OnMissingChannel.Create)).GetAwaiter().GetResult();
+ makeChannels: OnMissingChannel.Create));
//we want to access via a consumer, to receive multiple messages - we don't want to expose on channel
//just for the tests, so create a new consumer from the properties
@@ -59,7 +59,7 @@ public SqsBufferedConsumerTestsAsync()
});
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages_async()
{
var routingKey = new RoutingKey(_topicName);
@@ -121,10 +121,10 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
//retrieve messages
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
@@ -138,7 +138,7 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
await Task.Delay(1000);
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
public async ValueTask DisposeAsync()
@@ -148,10 +148,11 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().GetAwaiter().GetResult();
- _channelFactory.DeleteQueueAsync().GetAwaiter().GetResult();
- _messageProducer.DisposeAsync().GetAwaiter().GetResult();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
index 631db07251..ddf39df1d8 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -65,7 +64,7 @@ public AwsAssumeInfrastructureTestsAsync()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName(true));
}
- [Fact]
+ [Test]
public async Task When_infastructure_exists_can_assume()
{
//arrange
@@ -75,17 +74,18 @@ public async Task When_infastructure_exists_can_assume()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
index 9dd1659119..5b864dd047 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -71,7 +70,7 @@ public AwsValidateInfrastructureTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -81,18 +80,19 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
index 88efb6bceb..ef47cbedac 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
@@ -7,21 +7,21 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByArnTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByArnTestsAsync : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerAsync _consumer;
- private readonly SnsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByArnTestsAsync()
+ private Message _message;
+ private IAmAMessageConsumerAsync _consumer;
+ private SnsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
const string replyTo = "http:\\queueUrl";
@@ -37,9 +37,9 @@ public AwsValidateInfrastructureByArnTestsAsync()
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
routingKey: routingKey,
- queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
+ queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- messagePumpType: MessagePumpType.Proactor,
+ messagePumpType: MessagePumpType.Proactor,
makeChannels: OnMissingChannel.Create);
_message = new Message(
@@ -51,9 +51,9 @@ public AwsValidateInfrastructureByArnTestsAsync()
var awsConnection = GatewayFactory.CreateFactory();
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
- var topicArn = FindTopicArn(awsConnection, routingKey.ToValidSNSTopicName(true)).Result;
+ var topicArn = await FindTopicArn(awsConnection, routingKey.ToValidSNSTopicName(true));
var routingKeyArn = new RoutingKey(topicArn);
subscription.MakeChannels = OnMissingChannel.Validate;
@@ -74,7 +74,7 @@ public AwsValidateInfrastructureByArnTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -84,7 +84,7 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
@@ -96,13 +96,14 @@ private static async Task FindTopicArn(AWSMessagingGatewayConnection con
return topicResponse.TopicArn;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
index 97e94fafad..5d1309051e 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendAsyncTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -72,7 +71,7 @@ public SqsMessageProducerSendAsyncTests()
});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer_async()
{
// arrange
@@ -87,34 +86,35 @@ public async Task When_posting_a_message_via_the_producer_async()
await _channel.AcknowledgeAsync(message);
// should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_topicName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_topicName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
// allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
// {"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
- Assert.Equal(_messageGroupId, message.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, message.Header.Bag);
- Assert.Equal(_deduplicationId, message.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(message.Header.PartitionKey).IsEqualTo(_messageGroupId);
+ await Assert.That(message.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(message.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(_deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_assume_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
index 630c07f4f1..b4ba083269 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
@@ -4,18 +4,18 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTestsAsync : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly IAmAMessageConsumerAsync _consumer;
+ private ChannelFactory _channelFactory;
+ private IAmAMessageConsumerAsync _consumer;
- public AwsAssumeQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -27,9 +27,9 @@ public AwsAssumeQueuesTestsAsync()
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
routingKey: routingKey,
- queueAttributes: new SqsAttributes( type:SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
+ queueAttributes: new SqsAttributes( type:SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- messagePumpType: MessagePumpType.Proactor,
+ messagePumpType: MessagePumpType.Proactor,
makeChannels: OnMissingChannel.Assume);
var awsConnection = GatewayFactory.CreateFactory();
@@ -42,16 +42,16 @@ public AwsAssumeQueuesTestsAsync()
MakeChannels = OnMissingChannel.Create, TopicAttributes = topicAttributes
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
//We need to create the topic at least, to check the queues
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_assume_throws_async()
{
//we will try to get the queue url, and fail because it does not exist
@@ -59,9 +59,10 @@ await Assert.ThrowsAsync(async () =>
await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(1000)));
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
index 25099f5f78..f76148edfe 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
@@ -4,19 +4,19 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateQueuesTestsAsync : IAsyncDisposable
{
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly SqsSubscription _subscription;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private SqsSubscription _subscription;
private ChannelFactory? _channelFactory;
- public AwsValidateQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -41,10 +41,10 @@ public AwsValidateQueuesTestsAsync()
{
MakeChannels = OnMissingChannel.Create, TopicAttributes = topicAttributes
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_verify_throws_async()
{
// We have no queues so we should throw
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
index c559589bbf..0900f07ea6 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
@@ -5,12 +5,11 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -48,7 +47,7 @@ public SqsRawMessageDeliveryTestsAsync()
});
}
- [Fact]
+ [Test]
public async Task When_raw_message_delivery_disabled_async()
{
// Arrange
@@ -76,24 +75,25 @@ public async Task When_raw_message_delivery_disabled_async()
await _channel.AcknowledgeAsync(messageReceived);
// Assert
- Assert.Equal(messageToSend.Id, messageReceived.Id);
- Assert.Equal(messageToSend.Header.Topic.ToValidSNSTopicName(true), messageReceived.Header.Topic);
- Assert.Equal(messageToSend.Header.MessageType, messageReceived.Header.MessageType);
- Assert.Equal(messageToSend.Header.CorrelationId, messageReceived.Header.CorrelationId);
- Assert.Equal(messageToSend.Header.ReplyTo, messageReceived.Header.ReplyTo);
- Assert.Equal(messageToSend.Header.ContentType, messageReceived.Header.ContentType);
- Assert.Contains(customHeaderItem.Key, messageReceived.Header.Bag);
- Assert.Equal(customHeaderItem.Value, messageReceived.Header.Bag[customHeaderItem.Key]);
- Assert.Equal(messageToSend.Body.Value, messageReceived.Body.Value);
- Assert.Equal(messageGroupId, messageReceived.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, messageReceived.Header.Bag);
- Assert.Equal(deduplicationId, messageReceived.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(messageReceived.Id).IsEqualTo(messageToSend.Id);
+ await Assert.That(messageReceived.Header.Topic).IsEqualTo(messageToSend.Header.Topic.ToValidSNSTopicName(true));
+ await Assert.That(messageReceived.Header.MessageType).IsEqualTo(messageToSend.Header.MessageType);
+ await Assert.That(messageReceived.Header.CorrelationId).IsEqualTo(messageToSend.Header.CorrelationId);
+ await Assert.That(messageReceived.Header.ReplyTo).IsEqualTo(messageToSend.Header.ReplyTo);
+ await Assert.That(messageReceived.Header.ContentType).IsEqualTo(messageToSend.Header.ContentType);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(customHeaderItem.Key);
+ await Assert.That(messageReceived.Header.Bag[customHeaderItem.Key]).IsEqualTo(customHeaderItem.Value);
+ await Assert.That(messageReceived.Body.Value).IsEqualTo(messageToSend.Body.Value);
+ await Assert.That(messageReceived.Header.PartitionKey).IsEqualTo(messageGroupId);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(messageReceived.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
index f3e7d21b1d..1854cf3b45 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageConsumerRejectTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageConsumerRejectTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -62,7 +61,7 @@ public SqsMessageConsumerRejectTestsAsync()
});
}
- [Fact]
+ [Test]
public async Task When_rejecting_a_message_should_delete_from_queue_async()
{
//Arrange
@@ -75,13 +74,14 @@ public async Task When_rejecting_a_message_should_delete_from_queue_async()
//Assert - message should be deleted, not requeued
message = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_a_message_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_a_message_async.cs
index c516305d2b..cd4fe305f5 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_a_message_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_a_message_async.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTestsAsync : IAsyncDisposable
{
private readonly IAmAMessageProducerAsync _sender;
private Message _requeuedMessage;
@@ -63,7 +62,7 @@ public SqsMessageProducerRequeueTestsAsync()
_channel = _channelFactory.CreateAsyncChannel(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_a_message_async()
{
await _sender.SendAsync(_message);
@@ -74,13 +73,14 @@ public async Task When_requeueing_a_message_async()
await _channel.AcknowledgeAsync(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
index d6ae720c1f..91b9fa1d8d 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
@@ -10,22 +10,22 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTestsAsync : IAsyncDisposable
{
- private readonly SnsMessageProducer _sender;
- private readonly IAmAChannelAsync _channel;
- private readonly ChannelFactory _channelFactory;
- private readonly Message _message;
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly ChannelName _deadLetterChannel;
-
- public SqsMessageProducerDlqTestsAsync()
+ private SnsMessageProducer _sender;
+ private IAmAChannelAsync _channel;
+ private ChannelFactory _channelFactory;
+ private Message _message;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private ChannelName _deadLetterChannel;
+
+ [Before(Test)]
+ public async Task Setup()
{
MyCommand myCommand = new MyCommand { Value = "Test" };
const string replyTo = "http:\\queueUrl";
@@ -67,13 +67,13 @@ public SqsMessageProducerDlqTestsAsync()
TopicAttributes = topicAttributes
});
- _sender.ConfirmTopicExistsAsync(topicName).Wait();
+ await _sender.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(_awsConnection);
- _channel = _channelFactory.CreateAsyncChannel(subscription);
+ _channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_redrives_to_the_queue_async()
{
await _sender.SendAsync(_message);
@@ -89,7 +89,7 @@ public async Task When_requeueing_redrives_to_the_queue_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync();
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
private async Task GetDLQCountAsync()
@@ -112,10 +112,11 @@ private async Task GetDLQCountAsync()
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
index c836c905a3..edd597e9b7 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
@@ -12,13 +12,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTestsAsync : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -128,7 +127,7 @@ public async Task GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- [Fact(Skip = "Failing async tests caused by task scheduler issues")]
+ [Test, Skip("Failing async tests caused by task scheduler issues")]
public async Task When_throwing_defer_action_respect_redrive_async()
{
await _sender.SendAsync(_message);
@@ -144,13 +143,14 @@ public async Task When_throwing_defer_action_respect_redrive_async()
await Task.Delay(5000);
var dlqCount = await GetDLQCountAsync(_dlqChannelName + ".fifo");
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_topic_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
index d3bafd27aa..69e010bb65 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
@@ -1,12 +1,11 @@
-using System;
+using System;
using System.Threading.Tasks;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTestsAsync
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -22,7 +21,7 @@ public AwsValidateMissingTopicTestsAsync()
// Because we don't use channel factory to create the infrastructure - it won't exist
}
- [Fact]
+ [Test]
public async Task When_topic_missing_verify_throws_async()
{
// arrange
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
index 19e68cf488..5e6298e9ce 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly SqsMessageConsumer _consumer;
@@ -63,7 +62,7 @@ public SqsBufferedConsumerTests()
});
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages()
{
var routingKey = new RoutingKey(_topicName);
@@ -110,11 +109,11 @@ public async Task When_a_message_consumer_reads_multiple_messages()
);
//send MESSAGE_COUNT messages
- _messageProducer.Send(messageOne);
- _messageProducer.Send(messageTwo);
- _messageProducer.Send(messageThree);
- _messageProducer.Send(messageFour);
- _messageProducer.Send(messageFive);
+ await _messageProducer.SendAsync(messageOne);
+ await _messageProducer.SendAsync(messageTwo);
+ await _messageProducer.SendAsync(messageThree);
+ await _messageProducer.SendAsync(messageFour);
+ await _messageProducer.SendAsync(messageFive);
int iteration = 0;
@@ -126,18 +125,18 @@ public async Task When_a_message_consumer_reads_multiple_messages()
var outstandingMessageCount = MessageCount - messagesReceivedCount;
//retrieve messages
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(10000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
{
messagesReceived.Add(message);
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
messagesReceivedCount = messagesReceived.Count;
@@ -146,15 +145,16 @@ public async Task When_a_message_consumer_reads_multiple_messages()
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_assume.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_assume.cs
index 57b5a45b1f..8149e2353c 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_assume.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_assume.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -81,27 +80,28 @@ public AwsAssumeInfrastructureTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName(true));
}
- [Fact]
- public void When_infastructure_exists_can_assume()
+ [Test]
+ public async Task When_infastructure_exists_can_assume()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(5000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify.cs
index b12f15f2b1..f39f84699e 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -78,11 +77,11 @@ public AwsValidateInfrastructureTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -90,19 +89,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_arn.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_arn.cs
index c465a6d068..656b817dfd 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_arn.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_arn.cs
@@ -7,22 +7,22 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("CI", "Fragile")]
-public class AwsValidateInfrastructureByArnTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("CI", "Fragile")]
+public class AwsValidateInfrastructureByArnTests : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerSync _consumer;
- private readonly SnsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByArnTests()
+ private Message _message;
+ private IAmAMessageConsumerSync _consumer;
+ private SnsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
const string replyTo = "http:\\queueUrl";
var contentType = new ContentType(MediaTypeNames.Text.Plain);
@@ -39,9 +39,9 @@ public AwsValidateInfrastructureByArnTests()
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
routingKey: routingKey,
- queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
+ queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- messagePumpType: MessagePumpType.Reactor,
+ messagePumpType: MessagePumpType.Reactor,
makeChannels: OnMissingChannel.Create);
_message = new Message(
@@ -58,7 +58,7 @@ public AwsValidateInfrastructureByArnTests()
_channelFactory = new ChannelFactory(awsConnection);
var channel = _channelFactory.CreateSyncChannel(subscription);
- var topicArn = FindTopicArn(awsConnection, routingKey.ToValidSNSTopicName(true));
+ var topicArn = await FindTopicArn(awsConnection, routingKey.ToValidSNSTopicName(true));
var routingKeyArn = new RoutingKey(topicArn);
//Now change the subscription to validate, just check what we made
@@ -79,11 +79,11 @@ public AwsValidateInfrastructureByArnTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -91,19 +91,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
@@ -114,10 +115,10 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- private static string FindTopicArn(AWSMessagingGatewayConnection connection, string topicName)
+ private static async Task FindTopicArn(AWSMessagingGatewayConnection connection, string topicName)
{
using var snsClient = new AWSClientFactory(connection).CreateSnsClient();
- var topicResponse = snsClient.FindTopicAsync(topicName).GetAwaiter().GetResult();
+ var topicResponse = await snsClient.FindTopicAsync(topicName);
return topicResponse.TopicArn;
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_convention.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_convention.cs
index e47ccf65da..41613fb01f 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_convention.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_convention.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByConventionTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByConventionTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -78,11 +77,11 @@ public AwsValidateInfrastructureByConventionTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -90,19 +89,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infrastructure_exists_can_verify_by_convention.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infrastructure_exists_can_verify_by_convention.cs
index 0a09863dba..9434d2b816 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infrastructure_exists_can_verify_by_convention.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infrastructure_exists_can_verify_by_convention.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByConventionTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByConventionTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -72,28 +71,29 @@ public AwsValidateInfrastructureByConventionTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
var messages = _consumer.Receive(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
(_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
index d1c3df252e..4621d888b5 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -76,12 +75,12 @@ public SqsMessageProducerSendTests()
});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer()
{
//arrange
_message.Header.Subject = "test subject";
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -91,34 +90,35 @@ public async Task When_posting_a_message_via_the_producer()
_channel.Acknowledge(message);
//should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_topicName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_topicName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
//allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
//{"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
- Assert.Equal(_messageGroupId, message.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, message.Header.Bag);
- Assert.Equal(_deduplicationId, message.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(message.Header.PartitionKey).IsEqualTo(_messageGroupId);
+ await Assert.That(message.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(message.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(_deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_assume_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_assume_throws.cs
index b7525578f3..563de221f5 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_assume_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_assume_throws.cs
@@ -4,18 +4,18 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTests : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly SqsMessageConsumer _consumer;
+ private ChannelFactory _channelFactory;
+ private SqsMessageConsumer _consumer;
- public AwsAssumeQueuesTests()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -30,7 +30,7 @@ public AwsAssumeQueuesTests()
messagePumpType: MessagePumpType.Reactor,
queueAttributes: new SqsAttributes(
type: SqsType.Fifo,
- tags: new Dictionary { { "Environment", "Test" } }),
+ tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
makeChannels: OnMissingChannel.Assume);
@@ -38,14 +38,14 @@ public AwsAssumeQueuesTests()
//create the topic, we want the queue to be the issue
//We need to create the topic at least, to check the queues
-
+
var producer = new SnsMessageProducer(awsConnection,
new SnsPublication
{
MakeChannels = OnMissingChannel.Create, TopicAttributes = topicAttributes
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(awsConnection);
var channel = _channelFactory.CreateSyncChannel(subscription);
@@ -54,16 +54,17 @@ public AwsAssumeQueuesTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
- public void When_queues_missing_assume_throws()
+ [Test]
+ public async Task When_queues_missing_assume_throws()
{
//we will try to get the queue url, and fail because it does not exist
- Assert.Throws(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000)));
+ await Assert.That(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000))).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_verify_throws.cs
index 44115e6047..3f19c61ed1 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_verify_throws.cs
@@ -4,19 +4,19 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateQueuesTests : IAsyncDisposable
{
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly SqsSubscription _subscription;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private SqsSubscription _subscription;
private ChannelFactory? _channelFactory;
- public AwsValidateQueuesTests()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -28,9 +28,9 @@ public AwsValidateQueuesTests()
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
routingKey: routingKey,
- queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
+ queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- messagePumpType: MessagePumpType.Reactor,
+ messagePumpType: MessagePumpType.Reactor,
makeChannels: OnMissingChannel.Validate);
_awsConnection = GatewayFactory.CreateFactory();
@@ -41,22 +41,23 @@ public AwsValidateQueuesTests()
{
MakeChannels = OnMissingChannel.Create, TopicAttributes = topicAttributes
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
}
- [Fact]
- public void When_queues_missing_verify_throws()
+ [Test]
+ public async Task When_queues_missing_verify_throws()
{
//We have no queues so we should throw
//We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
- Assert.Throws(() => _channelFactory.CreateSyncChannel(_subscription));
+ await Assert.That(() => _channelFactory.CreateSyncChannel(_subscription)).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
if (_channelFactory != null)
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_raw_message_delivery_disabled.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_raw_message_delivery_disabled.cs
index 410f5a437d..0b49989406 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_raw_message_delivery_disabled.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_raw_message_delivery_disabled.cs
@@ -5,12 +5,11 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class SqsRawMessageDeliveryTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsRawMessageDeliveryTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -51,8 +50,8 @@ public SqsRawMessageDeliveryTests()
});
}
- [Fact]
- public void When_raw_message_delivery_disabled()
+ [Test]
+ public async Task When_raw_message_delivery_disabled()
{
//arrange
var messageGroupId = $"MessageGroupId{Guid.NewGuid():N}";
@@ -72,32 +71,33 @@ public void When_raw_message_delivery_disabled()
var messageToSent = new Message(messageHeader, new MessageBody("test content one"));
//act
- _messageProducer.Send(messageToSent);
+ await _messageProducer.SendAsync(messageToSent);
var messageReceived = _channel.Receive(TimeSpan.FromMilliseconds(10000));
_channel.Acknowledge(messageReceived);
//assert
- Assert.Equal(messageToSent.Id, messageReceived.Id);
- Assert.Equal(messageToSent.Header.Topic.ToValidSNSTopicName(true), messageReceived.Header.Topic);
- Assert.Equal(messageToSent.Header.MessageType, messageReceived.Header.MessageType);
- Assert.Equal(messageToSent.Header.CorrelationId, messageReceived.Header.CorrelationId);
- Assert.Equal(messageToSent.Header.ReplyTo, messageReceived.Header.ReplyTo);
- Assert.Equal(messageToSent.Header.ContentType, messageReceived.Header.ContentType);
- Assert.Contains(customHeaderItem.Key, messageReceived.Header.Bag);
- Assert.Equal(customHeaderItem.Value, messageReceived.Header.Bag[customHeaderItem.Key]);
- Assert.Equal(messageToSent.Body.Value, messageReceived.Body.Value);
-
- Assert.Equal(messageGroupId, messageReceived.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, messageReceived.Header.Bag);
- Assert.Equal(deduplicationId, messageReceived.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(messageReceived.Id).IsEqualTo(messageToSent.Id);
+ await Assert.That(messageReceived.Header.Topic).IsEqualTo(messageToSent.Header.Topic.ToValidSNSTopicName(true));
+ await Assert.That(messageReceived.Header.MessageType).IsEqualTo(messageToSent.Header.MessageType);
+ await Assert.That(messageReceived.Header.CorrelationId).IsEqualTo(messageToSent.Header.CorrelationId);
+ await Assert.That(messageReceived.Header.ReplyTo).IsEqualTo(messageToSent.Header.ReplyTo);
+ await Assert.That(messageReceived.Header.ContentType).IsEqualTo(messageToSent.Header.ContentType);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(customHeaderItem.Key);
+ await Assert.That(messageReceived.Header.Bag[customHeaderItem.Key]).IsEqualTo(customHeaderItem.Value);
+ await Assert.That(messageReceived.Body.Value).IsEqualTo(messageToSent.Body.Value);
+
+ await Assert.That(messageReceived.Header.PartitionKey).IsEqualTo(messageGroupId);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(messageReceived.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
index bcf44df4ca..2b3e118919 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTests : IDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTests
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -64,11 +63,11 @@ public SqsMessageConsumerRejectTests()
});
}
- [Fact]
- public void When_rejecting_a_message_should_delete_from_queue()
+ [Test]
+ public async Task When_rejecting_a_message_should_delete_from_queue()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -77,13 +76,14 @@ public void When_rejecting_a_message_should_delete_from_queue()
//Assert - message should be deleted, not requeued
message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_a_message.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_a_message.cs
index a6d7951941..eab67a2cad 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_a_message.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_a_message.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTests : IAsyncDisposable
{
private readonly IAmAMessageProducerSync _sender;
private Message? _requeuedMessage;
@@ -62,8 +61,8 @@ public SqsMessageProducerRequeueTests()
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_a_message()
+ [Test]
+ public async Task When_requeueing_a_message()
{
_sender.Send(_message);
_receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
@@ -74,13 +73,14 @@ public void When_requeueing_a_message()
//clear the queue
_channel.Acknowledge(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
index 91746f1868..8bc073cb1c 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
@@ -9,23 +9,23 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTests : IAsyncDisposable
{
- private readonly SnsMessageProducer _sender;
- private readonly IAmAChannelSync _channel;
- private readonly ChannelFactory _channelFactory;
- private readonly Message _message;
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly string _dlqChannelName;
-
- public SqsMessageProducerDlqTests()
+ private SnsMessageProducer _sender;
+ private IAmAChannelSync _channel;
+ private ChannelFactory _channelFactory;
+ private Message _message;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private string _dlqChannelName;
+
+ [Before(Test)]
+ public async Task Setup()
{
MyCommand myCommand = new MyCommand { Value = "Test" };
const string replyTo = "http:\\queueUrl";
@@ -70,17 +70,17 @@ public SqsMessageProducerDlqTests()
TopicAttributes = topicAttributes
});
- _sender.ConfirmTopicExistsAsync(topicName).Wait();
+ await _sender.ConfirmTopicExistsAsync(topicName);
//We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_redrives_to_the_queue()
+ [Test]
+ public async Task When_requeueing_redrives_to_the_queue()
{
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
var receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
_channel.Requeue(receivedMessage);
@@ -94,19 +94,19 @@ public void When_requeueing_redrives_to_the_queue()
Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName + ".fifo"));
+ await Assert.That(await GetDLQCount(_dlqChannelName + ".fifo")).IsEqualTo(1);
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageAttributeNames = ["All", "ApproximateReceiveCount"]
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -117,10 +117,11 @@ private int GetDLQCount(string queueName)
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
index 5fbcef0856..891255d14a 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
@@ -11,14 +11,13 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTests : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -118,17 +117,17 @@ public SnsReDrivePolicySDlqTests()
};
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageSystemAttributeNames = ["ApproximateReceiveCount"],
MessageAttributeNames = ["All"]
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -140,11 +139,11 @@ private int GetDLQCount(string queueName)
}
- [Fact]
+ [Test]
public async Task When_throwing_defer_action_respect_redrive()
{
//put something on an SNS topic, which will be delivered to our SQS queue
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
//start a message pump, let it process messages
var task = Task.Factory.StartNew(() => _messagePump.Run(), TaskCreationOptions.LongRunning);
@@ -160,13 +159,14 @@ public async Task When_throwing_defer_action_respect_redrive()
await Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName + ".fifo"));
+ await Assert.That(await GetDLQCount(_dlqChannelName + ".fifo")).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_topic_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_topic_missing_verify_throws.cs
index 5df84731b3..7ec67b2a11 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_topic_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Fifo/Reactor/When_topic_missing_verify_throws.cs
@@ -1,11 +1,10 @@
-using System;
+using System;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTests
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -21,8 +20,8 @@ public AwsValidateMissingTopicTests()
//Because we don't use channel factory to create the infrastructure -it won't exist
}
- [Fact]
- public void When_topic_missing_verify_throws()
+ [Test]
+ public async Task When_topic_missing_verify_throws()
{
//arrange
var producer = new SnsMessageProducer(_awsConnection,
@@ -35,9 +34,12 @@ public void When_topic_missing_verify_throws()
var messageGroupId = $"MessageGroup{Guid.NewGuid():N}";
//act && assert
- Assert.Throws(() => producer.Send(new Message(
- new MessageHeader("", _routingKey, MessageType.MT_EVENT,
- type: new CloudEventsType("plain/text"), partitionKey: messageGroupId),
- new MessageBody("Test"))));
+ Assert.ThrowsExactly(() =>
+ {
+ producer.Send(new Message(
+ new MessageHeader("", _routingKey, MessageType.MT_EVENT,
+ type: new CloudEventsType("plain/text"), partitionKey: messageGroupId),
+ new MessageBody("Test")));
+ });
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
index f7041d127c..adeac8c9de 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
@@ -6,24 +6,24 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTestsAsync : IAsyncDisposable
{
- private readonly SnsMessageProducer _messageProducer;
- private readonly SqsMessageConsumer _consumer;
- private readonly string _topicName;
- private readonly ChannelFactory _channelFactory;
+ private SnsMessageProducer _messageProducer;
+ private SqsMessageConsumer _consumer;
+ private string _topicName;
+ private ChannelFactory _channelFactory;
private readonly ContentType _contentType = new(MediaTypeNames.Text.Plain);
private const int BufferSize = 3;
private const int MessageCount = 4;
- public SqsBufferedConsumerTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var awsConnection = GatewayFactory.CreateFactory();
@@ -34,7 +34,7 @@ public SqsBufferedConsumerTestsAsync()
//we need the channel to create the queues and notifications
var routingKey = new RoutingKey(_topicName);
- var channel = _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
+ var channel = await _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
subscriptionName: new SubscriptionName(channelName),
channelName: new ChannelName(channelName),
routingKey: routingKey,
@@ -42,7 +42,7 @@ public SqsBufferedConsumerTestsAsync()
messagePumpType: MessagePumpType.Proactor,
makeChannels: OnMissingChannel.Create,
queueAttributes: new SqsAttributes(tags: new Dictionary { { "Environment", "Test" } }),
- topicAttributes: new SnsAttributes(tags: [new Tag { Key = "Environment", Value = "Test" }]))).GetAwaiter().GetResult();
+ topicAttributes: new SnsAttributes(tags: [new Tag { Key = "Environment", Value = "Test" }])));
//we want to access via a consumer, to receive multiple messages - we don't want to expose on channel
//just for the tests, so create a new consumer from the properties
@@ -51,7 +51,7 @@ public SqsBufferedConsumerTestsAsync()
new SnsPublication { MakeChannels = OnMissingChannel.Create });
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages_async()
{
var routingKey = new RoutingKey(_topicName);
@@ -97,10 +97,10 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
//retrieve messages
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
@@ -115,7 +115,7 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
public async ValueTask DisposeAsync()
@@ -125,10 +125,11 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().GetAwaiter().GetResult();
- _channelFactory.DeleteQueueAsync().GetAwaiter().GetResult();
- _messageProducer.DisposeAsync().GetAwaiter().GetResult();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_creating_a_topic_with_custom_tags_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_creating_a_topic_with_custom_tags_async.cs
index 5a1cafba9d..e268ccbea5 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_creating_a_topic_with_custom_tags_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_creating_a_topic_with_custom_tags_async.cs
@@ -10,12 +10,11 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerCreateTopicWithTagsAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerCreateTopicWithTagsAsyncTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -64,7 +63,7 @@ public SqsMessageProducerCreateTopicWithTagsAsyncTests()
});
}
- [Fact]
+ [Test]
public async Task When_creating_a_topic_with_custom_tags_async()
{
//arrange
@@ -77,15 +76,16 @@ public async Task When_creating_a_topic_with_custom_tags_async()
new ListTagsForResourceRequest { ResourceArn = topicArn });
//assert
- Assert.Contains(tagsResponse.Tags, t => t.Key == "Source" && t.Value == "Brighter");
- Assert.Contains(tagsResponse.Tags, t => t.Key == "Environment" && t.Value == "Test");
+ await Assert.That(tagsResponse.Tags).Contains(t => t.Key == "Source" && t.Value == "Brighter");
+ await Assert.That(tagsResponse.Tags).Contains(t => t.Key == "Environment" && t.Value == "Test");
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_customising_aws_client_config_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_customising_aws_client_config_async.cs
index f5e616ea86..d88987e352 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_customising_aws_client_config_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_customising_aws_client_config_async.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class CustomisingAwsClientConfigTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class CustomisingAwsClientConfigTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -67,7 +66,7 @@ public CustomisingAwsClientConfigTestsAsync()
);
}
- [Fact]
+ [Test]
public async Task When_customising_aws_client_config()
{
//arrange
@@ -78,22 +77,23 @@ public async Task When_customising_aws_client_config()
var message = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
//clear the queue
- Assert.NotEqual(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
await _channel.AcknowledgeAsync(message);
//publish_and_subscribe_should_use_custom_http_client_factory
- Assert.Contains("async_pub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["async_pub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("async_pub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["async_pub"]) > (0)).IsTrue();
- Assert.Contains("async_pub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["async_pub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("async_pub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["async_pub"]) > (0)).IsTrue();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infastructure_exists_can_assume_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infastructure_exists_can_assume_async.cs
index 1dde7e9866..f0e39cccf4 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infastructure_exists_can_assume_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infastructure_exists_can_assume_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeInfrastructureTestsAsync : IAsyncDisposable
{ private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
private readonly SnsMessageProducer _messageProducer;
@@ -68,7 +67,7 @@ public AwsAssumeInfrastructureTestsAsync()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
+ [Test]
public async Task When_infastructure_exists_can_assume()
{
//arrange
@@ -78,17 +77,18 @@ public async Task When_infastructure_exists_can_assume()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
index 3213747301..f386746e5c 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor
{
- [Trait("Category", "AWS")]
- public class AwsValidateInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+ [Category("AWS")]
+ public class AwsValidateInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -69,7 +68,7 @@ public AwsValidateInfrastructureTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -79,18 +78,19 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
index 2ff22482e1..b8e9184603 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
@@ -9,22 +9,22 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByArnTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByArnTestsAsync : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerAsync _consumer;
- private readonly SnsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByArnTestsAsync()
+ private Message _message;
+ private IAmAMessageConsumerAsync _consumer;
+ private SnsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
string correlationId = Id.Random();
@@ -53,11 +53,11 @@ public AwsValidateInfrastructureByArnTestsAsync()
var awsConnection = GatewayFactory.CreateFactory(credentials, region);
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
- var topicArn = FindTopicArn(awsConnection, routingKey.Value).Result;
+ var topicArn = await FindTopicArn(awsConnection, routingKey.Value);
var routingKeyArn = new RoutingKey(topicArn);
-
+
subscription.MakeChannels = OnMissingChannel.Validate;
subscription.RoutingKey = routingKeyArn;
subscription.FindTopicBy = TopicFindBy.Arn;
@@ -75,7 +75,7 @@ public AwsValidateInfrastructureByArnTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -85,7 +85,7 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
@@ -97,13 +97,14 @@ private static async Task FindTopicArn(AWSMessagingGatewayConnection con
return topicResponse.TopicArn;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_convention_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_convention_async.cs
index 8f75a4f3b6..4bb4132692 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_convention_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_convention_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByConventionTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByConventionTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -69,7 +68,7 @@ public AwsValidateInfrastructureByConventionTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -79,18 +78,19 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_resources_are_tagged_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_resources_are_tagged_async.cs
index a071c847be..3b1d6930df 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_resources_are_tagged_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_resources_are_tagged_async.cs
@@ -10,12 +10,11 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerResourcesAreTaggedAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerResourcesAreTaggedAsyncTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -70,7 +69,7 @@ public SqsMessageProducerResourcesAreTaggedAsyncTests()
});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_resources_are_tagged_async()
{
//arrange
@@ -89,18 +88,19 @@ public async Task When_posting_a_message_resources_are_tagged_async()
new ListQueueTagsRequest { QueueUrl = queueUrlResponse.QueueUrl });
//assert - topic has Environment=Test tag
- Assert.Contains(topicTagsResponse.Tags, t => t.Key == "Environment" && t.Value == "Test");
+ await Assert.That(topicTagsResponse.Tags).Contains(t => t.Key == "Environment" && t.Value == "Test");
//assert - queue has Environment=Test tag
- Assert.True(queueTagsResponse.Tags.ContainsKey("Environment"));
- Assert.Equal("Test", queueTagsResponse.Tags["Environment"]);
+ await Assert.That(queueTagsResponse.Tags.ContainsKey("Environment")).IsTrue();
+ await Assert.That(queueTagsResponse.Tags["Environment"]).IsEqualTo("Test");
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
index 8b937341b1..2ecf8ae200 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendAsyncTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -64,7 +63,7 @@ public SqsMessageProducerSendAsyncTests()
});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer_async()
{
// arrange
@@ -79,30 +78,31 @@ public async Task When_posting_a_message_via_the_producer_async()
await _channel.AcknowledgeAsync(message);
// should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_topicName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_topicName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
// allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
// {"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_assume_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_assume_throws_async.cs
index 46e1d89348..bffb58e362 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_assume_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_assume_throws_async.cs
@@ -4,19 +4,19 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTestsAsync : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly IAmAMessageConsumerAsync _consumer;
+ private ChannelFactory _channelFactory;
+ private IAmAMessageConsumerAsync _consumer;
- public AwsAssumeQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -27,7 +27,7 @@ public AwsAssumeQueuesTestsAsync()
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
routingKey: routingKey,
- messagePumpType: MessagePumpType.Proactor,
+ messagePumpType: MessagePumpType.Proactor,
makeChannels: OnMissingChannel.Assume,
queueAttributes: new SqsAttributes(tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: new SnsAttributes(tags: [new Tag { Key = "Environment", Value = "Test" }]));
@@ -42,16 +42,16 @@ public AwsAssumeQueuesTestsAsync()
MakeChannels = OnMissingChannel.Create
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
-
+ await producer.ConfirmTopicExistsAsync(topicName);
+
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
-
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
+
//We need to create the topic at least, to check the queues
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_assume_throws_async()
{
//we will try to get the queue url, and fail because it does not exist
@@ -59,9 +59,10 @@ await Assert.ThrowsAsync(async () =>
await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(1000)));
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_verify_throws_async.cs
index 0390163238..0191f4311f 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_verify_throws_async.cs
@@ -4,20 +4,20 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateQueuesTestsAsync : IAsyncDisposable
{
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly SqsSubscription _subscription;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private SqsSubscription _subscription;
private ChannelFactory? _channelFactory;
- public AwsValidateQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -41,10 +41,10 @@ public AwsValidateQueuesTestsAsync()
{
MakeChannels = OnMissingChannel.Create
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_verify_throws_async()
{
// We have no queues so we should throw
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_raw_message_delivery_disabled_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_raw_message_delivery_disabled_async.cs
index fab7c0236c..9146b49aa9 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_raw_message_delivery_disabled_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_raw_message_delivery_disabled_async.cs
@@ -5,13 +5,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -49,7 +48,7 @@ public SqsRawMessageDeliveryTestsAsync()
});
}
- [Fact]
+ [Test]
public async Task When_raw_message_delivery_disabled_async()
{
// Arrange
@@ -74,21 +73,22 @@ public async Task When_raw_message_delivery_disabled_async()
await _channel.AcknowledgeAsync(messageReceived);
// Assert
- Assert.Equal(messageToSend.Id, messageReceived.Id);
- Assert.Equal(messageToSend.Header.Topic, messageReceived.Header.Topic);
- Assert.Equal(messageToSend.Header.MessageType, messageReceived.Header.MessageType);
- Assert.Equal(messageToSend.Header.CorrelationId, messageReceived.Header.CorrelationId);
- Assert.Equal(messageToSend.Header.ReplyTo, messageReceived.Header.ReplyTo);
- Assert.Equal(messageToSend.Header.ContentType, messageReceived.Header.ContentType);
- Assert.Contains(customHeaderItem.Key, messageReceived.Header.Bag);
- Assert.Equal(customHeaderItem.Value, messageReceived.Header.Bag[customHeaderItem.Key]);
- Assert.Equal(messageToSend.Body.Value, messageReceived.Body.Value);
+ await Assert.That(messageReceived.Id).IsEqualTo(messageToSend.Id);
+ await Assert.That(messageReceived.Header.Topic).IsEqualTo(messageToSend.Header.Topic);
+ await Assert.That(messageReceived.Header.MessageType).IsEqualTo(messageToSend.Header.MessageType);
+ await Assert.That(messageReceived.Header.CorrelationId).IsEqualTo(messageToSend.Header.CorrelationId);
+ await Assert.That(messageReceived.Header.ReplyTo).IsEqualTo(messageToSend.Header.ReplyTo);
+ await Assert.That(messageReceived.Header.ContentType).IsEqualTo(messageToSend.Header.ContentType);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(customHeaderItem.Key);
+ await Assert.That(messageReceived.Header.Bag[customHeaderItem.Key]).IsEqualTo(customHeaderItem.Value);
+ await Assert.That(messageReceived.Body.Value).IsEqualTo(messageToSend.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
index 55570033eb..24bfa751cd 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
@@ -6,15 +6,14 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -56,7 +55,7 @@ public SqsMessageConsumerRejectTestsAsync()
_messageProducer = new SnsMessageProducer(awsConnection, new SnsPublication { MakeChannels = OnMissingChannel.Create });
}
- [Fact]
+ [Test]
public async Task When_rejecting_a_message_should_delete_from_queue_async()
{
//Arrange
@@ -69,13 +68,14 @@ public async Task When_rejecting_a_message_should_delete_from_queue_async()
//Assert - message should be deleted, not requeued
message = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_a_message_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_a_message_async.cs
index 0d0070b61e..4988b9060a 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_a_message_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_a_message_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTestsAsync : IAsyncDisposable
{
private readonly IAmAMessageProducerAsync _sender;
private Message? _requeuedMessage;
@@ -59,7 +58,7 @@ public SqsMessageProducerRequeueTestsAsync()
_channel = _channelFactory.CreateAsyncChannel(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_a_message_async()
{
await _sender.SendAsync(_message);
@@ -70,13 +69,14 @@ public async Task When_requeueing_a_message_async()
await _channel.AcknowledgeAsync(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
index c26dcb8b68..59f7f2fa74 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
@@ -10,23 +10,23 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTestsAsync : IAsyncDisposable
{
- private readonly SnsMessageProducer _sender;
- private readonly IAmAChannelAsync _channel;
- private readonly ChannelFactory _channelFactory;
- private readonly Message _message;
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly ChannelName _deadLetterChannel;
-
- public SqsMessageProducerDlqTestsAsync()
+ private SnsMessageProducer _sender;
+ private IAmAChannelAsync _channel;
+ private ChannelFactory _channelFactory;
+ private Message _message;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private ChannelName _deadLetterChannel;
+
+ [Before(Test)]
+ public async Task Setup()
{
MyCommand myCommand = new MyCommand { Value = "Test" };
string correlationId = Guid.NewGuid().ToString();
@@ -61,13 +61,13 @@ public SqsMessageProducerDlqTestsAsync()
_sender = new SnsMessageProducer(_awsConnection, new SnsPublication { Topic = routingKey, MakeChannels = OnMissingChannel.Create });
- _sender.ConfirmTopicExistsAsync(topicName).Wait();
+ await _sender.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(_awsConnection);
- _channel = _channelFactory.CreateAsyncChannel(subscription);
+ _channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_redrives_to_the_queue_async()
{
await _sender.SendAsync(_message);
@@ -83,7 +83,7 @@ public async Task When_requeueing_redrives_to_the_queue_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync();
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
private async Task GetDLQCountAsync()
@@ -106,10 +106,11 @@ private async Task GetDLQCountAsync()
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
index 9498d534bc..7e5509947a 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
@@ -13,13 +13,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTestsAsync : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -126,7 +125,7 @@ public async Task GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- [Fact(Skip = "Failing async tests caused by task scheduler issues")]
+ [Test, Skip("Failing async tests caused by task scheduler issues")]
public async Task When_throwing_defer_action_respect_redrive_async()
{
await _sender.SendAsync(_message);
@@ -142,13 +141,14 @@ public async Task When_throwing_defer_action_respect_redrive_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync(_dlqChannelName);
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_topic_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_topic_missing_verify_throws_async.cs
index 51495125c1..e182eced42 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_topic_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Proactor/When_topic_missing_verify_throws_async.cs
@@ -1,12 +1,11 @@
-using System;
+using System;
using System.Threading.Tasks;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTestsAsync
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -22,7 +21,7 @@ public AwsValidateMissingTopicTestsAsync()
// Because we don't use channel factory to create the infrastructure - it won't exist
}
- [Fact]
+ [Test]
public async Task When_topic_missing_verify_throws_async()
{
// arrange
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
index 868817ad84..9b76128c28 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly SqsMessageConsumer _consumer;
@@ -55,7 +54,7 @@ public SqsBufferedConsumerTests()
});
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages()
{
var routingKey = new RoutingKey(_topicName);
@@ -85,10 +84,10 @@ public async Task When_a_message_consumer_reads_multiple_messages()
);
//send MESSAGE_COUNT messages
- _messageProducer.Send(messageOne);
- _messageProducer.Send(messageTwo);
- _messageProducer.Send(messageThree);
- _messageProducer.Send(messageFour);
+ await _messageProducer.SendAsync(messageOne);
+ await _messageProducer.SendAsync(messageTwo);
+ await _messageProducer.SendAsync(messageThree);
+ await _messageProducer.SendAsync(messageFour);
int iteration = 0;
@@ -100,18 +99,18 @@ public async Task When_a_message_consumer_reads_multiple_messages()
var outstandingMessageCount = MessageCount - messagesReceivedCount;
//retrieve messages
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(10000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
{
messagesReceived.Add(message);
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
messagesReceivedCount = messagesReceived.Count;
@@ -121,16 +120,17 @@ public async Task When_a_message_consumer_reads_multiple_messages()
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_customising_aws_client_config.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_customising_aws_client_config.cs
index 1d9e282fbc..3db77c3aa7 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_customising_aws_client_config.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_customising_aws_client_config.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class CustomisingAwsClientConfigTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class CustomisingAwsClientConfigTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -63,11 +62,11 @@ public CustomisingAwsClientConfigTests()
MakeChannels = OnMissingChannel.Create });
}
- [Fact]
+ [Test]
public async Task When_customising_aws_client_config()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -77,18 +76,19 @@ public async Task When_customising_aws_client_config()
_channel.Acknowledge(message);
//publish_and_subscribe_should_use_custom_http_client_factory
- Assert.Contains("sync_sub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["sync_sub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("sync_sub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["sync_sub"]) > (0)).IsTrue();
- Assert.Contains("sync_pub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["sync_pub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("sync_pub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["sync_pub"]) > (0)).IsTrue();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_assume.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_assume.cs
index 72304c61a9..e5cba91353 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_assume.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_assume.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -65,27 +64,28 @@ public AwsAssumeInfrastructureTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
- public void When_infastructure_exists_can_assume()
+ [Test]
+ public async Task When_infastructure_exists_can_assume()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(5000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify.cs
index 180f2fb00b..7b6ae188b3 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -71,11 +70,11 @@ public AwsValidateInfrastructureTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -83,19 +82,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_arn.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_arn.cs
index eb01114833..ecdf5f6a38 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_arn.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_arn.cs
@@ -9,22 +9,22 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByArnTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByArnTests : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerAsync _consumer;
- private readonly SnsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByArnTests()
+ private Message _message;
+ private IAmAMessageConsumerAsync _consumer;
+ private SnsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
string correlationId = Guid.NewGuid().ToString();
@@ -56,9 +56,9 @@ public AwsValidateInfrastructureByArnTests()
//This doesn't look that different from our create tests - this is because we create using the channel factory in
//our AWS transport, not the consumer (as it's a more likely to use infrastructure declared elsewhere)
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
- var topicArn = FindTopicArn(awsConnection, routingKey.Value);
+ var topicArn = await FindTopicArn(awsConnection, routingKey.Value);
var routingKeyArn = new RoutingKey(topicArn);
//Now change the subscription to validate, just check what we made
@@ -79,7 +79,7 @@ public AwsValidateInfrastructureByArnTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
@@ -91,20 +91,21 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.NotEqual(MessageType.MT_NONE, message.Header.MessageType);
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
@@ -115,10 +116,10 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- private static string FindTopicArn(AWSMessagingGatewayConnection connection, string topicName)
+ private static async Task FindTopicArn(AWSMessagingGatewayConnection connection, string topicName)
{
using var snsClient = new AWSClientFactory(connection).CreateSnsClient();
- var topicResponse = snsClient.FindTopicAsync(topicName).GetAwaiter().GetResult();
+ var topicResponse = await snsClient.FindTopicAsync(topicName);
return topicResponse.TopicArn;
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_convention.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_convention.cs
index 69c3669b13..6e1077fbf1 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_convention.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_convention.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByConventionTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByConventionTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -69,11 +68,11 @@ public AwsValidateInfrastructureByConventionTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -81,19 +80,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
index 1ae3276b2d..e9b9b515cc 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -62,12 +61,12 @@ public SqsMessageProducerSendTests()
new SnsPublication{Topic = new RoutingKey(_topicName), MakeChannels = OnMissingChannel.Create});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer()
{
//arrange
_message.Header.Subject = "test subject";
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -77,30 +76,31 @@ public async Task When_posting_a_message_via_the_producer()
_channel.Acknowledge(message);
//should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_topicName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_topicName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
//allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
//{"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_assume_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_assume_throws.cs
index ca98234a85..d8e6c30453 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_assume_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_assume_throws.cs
@@ -4,24 +4,24 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTests : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly SqsMessageConsumer _consumer;
+ private ChannelFactory _channelFactory;
+ private SqsMessageConsumer _consumer;
- public AwsAssumeQueuesTests()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
var routingKey = new RoutingKey(topicName);
-
+
var subscription = new SqsSubscription(
subscriptionName: new SubscriptionName(channelName),
channelName: new ChannelName(channelName),
@@ -31,36 +31,37 @@ public AwsAssumeQueuesTests()
makeChannels: OnMissingChannel.Assume,
queueAttributes: new SqsAttributes(tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: new SnsAttributes(tags: [new Tag { Key = "Environment", Value = "Test" }]));
-
+
var awsConnection = GatewayFactory.CreateFactory();
-
+
//create the topic, we want the queue to be the issue
//We need to create the topic at least, to check the queues
- var producer = new SnsMessageProducer(awsConnection,
+ var producer = new SnsMessageProducer(awsConnection,
new SnsPublication
{
- MakeChannels = OnMissingChannel.Create
+ MakeChannels = OnMissingChannel.Create
});
-
- producer.ConfirmTopicExistsAsync(topicName).Wait();
-
+
+ await producer.ConfirmTopicExistsAsync(topicName);
+
_channelFactory = new ChannelFactory(awsConnection);
var channel = _channelFactory.CreateSyncChannel(subscription);
-
+
//We need to create the topic at least, to check the queues
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
- public void When_queues_missing_assume_throws()
+ [Test]
+ public async Task When_queues_missing_assume_throws()
{
//we will try to get the queue url, and fail because it does not exist
- Assert.Throws(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000)));
+ await Assert.That(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000))).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_verify_throws.cs
index 8793261de3..f684654695 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_verify_throws.cs
@@ -4,25 +4,25 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateQueuesTests : IAsyncDisposable
{
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly SqsSubscription _subscription;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private SqsSubscription _subscription;
private ChannelFactory? _channelFactory;
- public AwsValidateQueuesTests()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
var routingKey = new RoutingKey(topicName);
-
+
_subscription = new SqsSubscription(
subscriptionName: new SubscriptionName(channelName),
channelName: new ChannelName(channelName),
@@ -32,32 +32,33 @@ public AwsValidateQueuesTests()
makeChannels: OnMissingChannel.Validate,
queueAttributes: new SqsAttributes(tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: new SnsAttributes(tags: [new Tag { Key = "Environment", Value = "Test" }]));
-
+
_awsConnection = GatewayFactory.CreateFactory();
-
+
//We need to create the topic at least, to check the queues
- var producer = new SnsMessageProducer(_awsConnection,
+ var producer = new SnsMessageProducer(_awsConnection,
new SnsPublication
{
- MakeChannels = OnMissingChannel.Create
+ MakeChannels = OnMissingChannel.Create
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
-
+ await producer.ConfirmTopicExistsAsync(topicName);
+
}
- [Fact]
- public void When_queues_missing_verify_throws()
+ [Test]
+ public async Task When_queues_missing_verify_throws()
{
//We have no queues so we should throw
//We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
- Assert.Throws(() => _channelFactory.CreateSyncChannel(_subscription));
+ await Assert.That(() => _channelFactory.CreateSyncChannel(_subscription)).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
if (_channelFactory != null)
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_raw_message_delivery_disabled.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_raw_message_delivery_disabled.cs
index 043a6650da..72e3fbfd92 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_raw_message_delivery_disabled.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_raw_message_delivery_disabled.cs
@@ -5,13 +5,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class SqsRawMessageDeliveryTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsRawMessageDeliveryTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -48,8 +47,8 @@ public SqsRawMessageDeliveryTests()
});
}
- [Fact]
- public void When_raw_message_delivery_disabled()
+ [Test]
+ public async Task When_raw_message_delivery_disabled()
{
//arrange
var messageHeader = new MessageHeader(
@@ -66,28 +65,29 @@ public void When_raw_message_delivery_disabled()
var messageToSent = new Message(messageHeader, new MessageBody("test content one"));
//act
- _messageProducer.Send(messageToSent);
+ await _messageProducer.SendAsync(messageToSent);
var messageReceived = _channel.Receive(TimeSpan.FromMilliseconds(10000));
_channel.Acknowledge(messageReceived);
//assert
- Assert.Equal(messageToSent.Id, messageReceived.Id);
- Assert.Equal(messageToSent.Header.Topic, messageReceived.Header.Topic);
- Assert.Equal(messageToSent.Header.MessageType, messageReceived.Header.MessageType);
- Assert.Equal(messageToSent.Header.CorrelationId, messageReceived.Header.CorrelationId);
- Assert.Equal(messageToSent.Header.ReplyTo, messageReceived.Header.ReplyTo);
- Assert.Equal(messageToSent.Header.ContentType, messageReceived.Header.ContentType);
- Assert.Contains(customHeaderItem.Key, messageReceived.Header.Bag);
- Assert.Equal(customHeaderItem.Value, messageReceived.Header.Bag[customHeaderItem.Key]);
- Assert.Equal(messageToSent.Body.Value, messageReceived.Body.Value);
+ await Assert.That(messageReceived.Id).IsEqualTo(messageToSent.Id);
+ await Assert.That(messageReceived.Header.Topic).IsEqualTo(messageToSent.Header.Topic);
+ await Assert.That(messageReceived.Header.MessageType).IsEqualTo(messageToSent.Header.MessageType);
+ await Assert.That(messageReceived.Header.CorrelationId).IsEqualTo(messageToSent.Header.CorrelationId);
+ await Assert.That(messageReceived.Header.ReplyTo).IsEqualTo(messageToSent.Header.ReplyTo);
+ await Assert.That(messageReceived.Header.ContentType).IsEqualTo(messageToSent.Header.ContentType);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(customHeaderItem.Key);
+ await Assert.That(messageReceived.Header.Bag[customHeaderItem.Key]).IsEqualTo(customHeaderItem.Value);
+ await Assert.That(messageReceived.Body.Value).IsEqualTo(messageToSent.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_rejecting_a_message_should_delete_from_queue.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
index d917a0e962..f3e95c63b0 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
@@ -8,13 +8,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTests : IDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTests
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -58,11 +57,11 @@ public SqsMessageConsumerRejectTests()
_messageProducer = new SnsMessageProducer(awsConnection, new SnsPublication{MakeChannels = OnMissingChannel.Create});
}
- [Fact]
- public void When_rejecting_a_message_should_delete_from_queue()
+ [Test]
+ public async Task When_rejecting_a_message_should_delete_from_queue()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -71,13 +70,14 @@ public void When_rejecting_a_message_should_delete_from_queue()
//Assert - message should be deleted, not requeued
message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_requeueing_a_message.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_requeueing_a_message.cs
index 32764d9ec3..13d1010cf5 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_requeueing_a_message.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_requeueing_a_message.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTests : IAsyncDisposable
{
private readonly IAmAMessageProducerSync _sender;
private Message? _requeuedMessage;
@@ -61,8 +60,8 @@ public SqsMessageProducerRequeueTests()
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_a_message()
+ [Test]
+ public async Task When_requeueing_a_message()
{
_sender.Send(_message);
_receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
@@ -73,13 +72,14 @@ public void When_requeueing_a_message()
//clear the queue
_channel.Acknowledge(_requeuedMessage );
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_requeueing_redrives_to_the_dlq.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_requeueing_redrives_to_the_dlq.cs
index d60073bb71..31dd674faf 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_requeueing_redrives_to_the_dlq.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_requeueing_redrives_to_the_dlq.cs
@@ -10,23 +10,23 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTests : IAsyncDisposable
{
- private readonly SnsMessageProducer _sender;
- private readonly IAmAChannelSync _channel;
- private readonly ChannelFactory _channelFactory;
- private readonly Message _message;
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly string _dlqChannelName;
-
- public SqsMessageProducerDlqTests()
+ private SnsMessageProducer _sender;
+ private IAmAChannelSync _channel;
+ private ChannelFactory _channelFactory;
+ private Message _message;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private string _dlqChannelName;
+
+ [Before(Test)]
+ public async Task Setup()
{
MyCommand myCommand = new MyCommand { Value = "Test" };
string correlationId = Guid.NewGuid().ToString();
@@ -60,17 +60,17 @@ public SqsMessageProducerDlqTests()
_sender = new SnsMessageProducer(_awsConnection, new SnsPublication { MakeChannels = OnMissingChannel.Create });
- _sender.ConfirmTopicExistsAsync(topicName).Wait();
+ await _sender.ConfirmTopicExistsAsync(topicName);
//We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_redrives_to_the_queue()
+ [Test]
+ public async Task When_requeueing_redrives_to_the_queue()
{
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
var receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
_channel.Requeue(receivedMessage);
@@ -84,19 +84,19 @@ public void When_requeueing_redrives_to_the_queue()
Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName));
+ await Assert.That(await GetDLQCount(_dlqChannelName)).IsEqualTo(1);
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageAttributeNames = new List { "All", "ApproximateReceiveCount" }
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -107,10 +107,11 @@ private int GetDLQCount(string queueName)
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_throwing_defer_action_respect_redrive.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_throwing_defer_action_respect_redrive.cs
index 45d5998bf9..69a260bd3d 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_throwing_defer_action_respect_redrive.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_throwing_defer_action_respect_redrive.cs
@@ -13,13 +13,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTests : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -117,17 +116,17 @@ public SnsReDrivePolicySDlqTests()
};
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
- using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageSystemAttributeNames = ["ApproximateReceiveCount"],
MessageAttributeNames = new List { "All" }
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -139,11 +138,11 @@ private int GetDLQCount(string queueName)
}
- [Fact]
+ [Test]
public async Task When_throwing_defer_action_respect_redrive()
{
//put something on an SNS topic, which will be delivered to our SQS queue
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
//start a message pump, let it process messages
var task = Task.Factory.StartNew(() => _messagePump.Run(), TaskCreationOptions.LongRunning);
@@ -159,13 +158,14 @@ public async Task When_throwing_defer_action_respect_redrive()
await Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName));
+ await Assert.That(await GetDLQCount(_dlqChannelName)).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_topic_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_topic_missing_verify_throws.cs
index cefa94068d..0e1920fd45 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_topic_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sns/Standard/Reactor/When_topic_missing_verify_throws.cs
@@ -1,11 +1,10 @@
-using System;
+using System;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTests
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -21,8 +20,8 @@ public AwsValidateMissingTopicTests()
//Because we don't use channel factory to create the infrastructure -it won't exist
}
- [Fact]
- public void When_topic_missing_verify_throws()
+ [Test]
+ public async Task When_topic_missing_verify_throws()
{
//arrange
var producer = new SnsMessageProducer(_awsConnection,
@@ -32,8 +31,11 @@ public void When_topic_missing_verify_throws()
});
//act && assert
- Assert.Throws(() => producer.Send(new Message(
- new MessageHeader("", _routingKey, MessageType.MT_EVENT, type: new CloudEventsType("plain/text")),
- new MessageBody("Test"))));
+ Assert.ThrowsExactly(() =>
+ {
+ producer.Send(new Message(
+ new MessageHeader("", _routingKey, MessageType.MT_EVENT, type: new CloudEventsType("plain/text")),
+ new MessageBody("Test")));
+ });
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
index c82cd1b508..4cc0337cb2 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
@@ -6,23 +6,23 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTestsAsync : IAsyncDisposable
{
- private readonly SqsMessageProducer _messageProducer;
- private readonly SqsMessageConsumer _consumer;
- private readonly string _queueName;
- private readonly ChannelFactory _channelFactory;
+ private SqsMessageProducer _messageProducer;
+ private SqsMessageConsumer _consumer;
+ private string _queueName;
+ private ChannelFactory _channelFactory;
private readonly ContentType _contentType = new(MediaTypeNames.Text.Plain);
private const int BufferSize = 3;
private const int MessageCount = 4;
- public SqsBufferedConsumerTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var awsConnection = GatewayFactory.CreateFactory();
@@ -38,8 +38,8 @@ public SqsBufferedConsumerTestsAsync()
deduplicationScope: DeduplicationScope.MessageGroup,
fifoThroughputLimit: FifoThroughputLimit.PerMessageGroupId,
tags: new Dictionary { { "Environment", "Test" } });
-
- var channel = _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
+
+ var channel = await _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
subscriptionName: new SubscriptionName(_queueName),
channelName: channelName,
channelType: ChannelType.PointToPoint,
@@ -47,8 +47,7 @@ public SqsBufferedConsumerTestsAsync()
bufferSize: BufferSize,
queueAttributes: queueAttributes,
messagePumpType: MessagePumpType.Proactor,
- makeChannels: OnMissingChannel.Create))
- .GetAwaiter().GetResult();
+ makeChannels: OnMissingChannel.Create));
//we want to access via a consumer, to receive multiple messages - we don't want to expose on channel
//just for the tests, so create a new consumer from the properties
@@ -58,7 +57,7 @@ public SqsBufferedConsumerTestsAsync()
new SqsPublication(channelName: channelName, queueAttributes: queueAttributes, makeChannels: OnMissingChannel.Create));
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages_async()
{
var routingKey = new RoutingKey(_queueName);
@@ -120,10 +119,10 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
//retrieve messages
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
@@ -137,7 +136,7 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
await Task.Delay(1000);
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
public async ValueTask DisposeAsync()
@@ -147,10 +146,11 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().GetAwaiter().GetResult();
- _channelFactory.DeleteQueueAsync().GetAwaiter().GetResult();
- _messageProducer.DisposeAsync().GetAwaiter().GetResult();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
index 3d5fdab046..167fd414e6 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AwsAssumeInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AwsAssumeInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -71,7 +70,7 @@ public AwsAssumeInfrastructureTestsAsync()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName(true));
}
- [Fact]
+ [Test]
public async Task When_infastructure_exists_can_assume()
{
//arrange
@@ -81,17 +80,18 @@ public async Task When_infastructure_exists_can_assume()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
index 5e910cf263..179b0df72f 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AwsValidateInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AwsValidateInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -67,7 +66,7 @@ public AwsValidateInfrastructureTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -77,18 +76,19 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infrastructure_exists_can_verify_by_url_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infrastructure_exists_can_verify_by_url_async.cs
index 12f883ebf6..7f16051660 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infrastructure_exists_can_verify_by_url_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_infrastructure_exists_can_verify_by_url_async.cs
@@ -7,22 +7,22 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AwsValidateInfrastructureByUrlTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AwsValidateInfrastructureByUrlTestsAsync : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerAsync _consumer;
- private readonly SqsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByUrlTestsAsync()
+ private Message _message;
+ private IAmAMessageConsumerAsync _consumer;
+ private SqsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
const string replyTo = "http:\\queueUrl";
@@ -53,9 +53,9 @@ public AwsValidateInfrastructureByUrlTestsAsync()
var awsConnection = GatewayFactory.CreateFactory();
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
- var queueUrl = FindQueueUrl(awsConnection, routingKey.ToValidSQSQueueName(true)).Result;
+ var queueUrl = await FindQueueUrl(awsConnection, routingKey.ToValidSQSQueueName(true));
subscription.MakeChannels = OnMissingChannel.Validate;
@@ -72,7 +72,7 @@ public AwsValidateInfrastructureByUrlTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -82,7 +82,7 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
@@ -94,13 +94,14 @@ private static async Task FindQueueUrl(AWSMessagingGatewayConnection con
return topicResponse.QueueUrl;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
index 0ba4f344e5..37cc0378cf 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.Extensions;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendAsyncTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -72,7 +71,7 @@ public SqsMessageProducerSendAsyncTests()
new SqsPublication(channelName: channelName, queueAttributes: queueAttributes, makeChannels: OnMissingChannel.Create));
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer_async()
{
// arrange
@@ -87,34 +86,35 @@ public async Task When_posting_a_message_via_the_producer_async()
await _channel.AcknowledgeAsync(message);
// should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_queueName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_queueName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
// allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
// {"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
- Assert.Equal(_messageGroupId, message.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, message.Header.Bag);
- Assert.Equal(_deduplicationId, message.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(message.Header.PartitionKey).IsEqualTo(_messageGroupId);
+ await Assert.That(message.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(message.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(_deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_queues_missing_assume_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
index d2a10185e7..a3ec40015c 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
@@ -4,13 +4,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTestsAsync : IAsyncDisposable
{
private readonly ChannelFactory _channelFactory;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -39,7 +38,7 @@ public AwsAssumeQueuesTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_assume_throws_async()
{
//we will try to get the queue url, and fail because it does not exist
@@ -47,9 +46,10 @@ await Assert.ThrowsAsync(async () =>
await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(1000)));
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_queues_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
index ce80e26df5..60de2a9244 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
@@ -4,12 +4,11 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateQueuesTestsAsync : IAsyncDisposable
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -34,7 +33,7 @@ public AwsValidateQueuesTestsAsync()
_awsConnection = GatewayFactory.CreateFactory();
}
- [Fact]
+ [Test]
public async Task When_queues_missing_verify_throws_async()
{
// We have no queues so we should throw
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
index 1fa31a414b..75048b7f93 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
@@ -5,13 +5,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable
{
private readonly SqsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -55,7 +54,7 @@ public SqsRawMessageDeliveryTestsAsync()
);
}
- [Fact]
+ [Test]
public async Task When_raw_message_delivery_disabled_async()
{
// Arrange
@@ -83,24 +82,25 @@ public async Task When_raw_message_delivery_disabled_async()
await _channel.AcknowledgeAsync(messageReceived);
// Assert
- Assert.Equal(messageToSend.Id, messageReceived.Id);
- Assert.Equal(messageToSend.Header.Topic.ToValidSNSTopicName(true), messageReceived.Header.Topic);
- Assert.Equal(messageToSend.Header.MessageType, messageReceived.Header.MessageType);
- Assert.Equal(messageToSend.Header.CorrelationId, messageReceived.Header.CorrelationId);
- Assert.Equal(messageToSend.Header.ReplyTo, messageReceived.Header.ReplyTo);
- Assert.StartsWith(messageToSend.Header.ContentType?.ToString(), messageReceived.Header.ContentType?.ToString());
- Assert.Contains(customHeaderItem.Key, messageReceived.Header.Bag);
- Assert.Equal(customHeaderItem.Value, messageReceived.Header.Bag[customHeaderItem.Key]);
- Assert.Equal(messageToSend.Body.Value, messageReceived.Body.Value);
- Assert.Equal(messageGroupId, messageReceived.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, messageReceived.Header.Bag);
- Assert.Equal(deduplicationId, messageReceived.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(messageReceived.Id).IsEqualTo(messageToSend.Id);
+ await Assert.That(messageReceived.Header.Topic).IsEqualTo(messageToSend.Header.Topic.ToValidSNSTopicName(true));
+ await Assert.That(messageReceived.Header.MessageType).IsEqualTo(messageToSend.Header.MessageType);
+ await Assert.That(messageReceived.Header.CorrelationId).IsEqualTo(messageToSend.Header.CorrelationId);
+ await Assert.That(messageReceived.Header.ReplyTo).IsEqualTo(messageToSend.Header.ReplyTo);
+ await Assert.That(messageReceived.Header.ContentType?.ToString()).StartsWith(messageToSend.Header.ContentType?.ToString());
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(customHeaderItem.Key);
+ await Assert.That(messageReceived.Header.Bag[customHeaderItem.Key]).IsEqualTo(customHeaderItem.Value);
+ await Assert.That(messageReceived.Body.Value).IsEqualTo(messageToSend.Body.Value);
+ await Assert.That(messageReceived.Header.PartitionKey).IsEqualTo(messageGroupId);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(messageReceived.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
index 06bd88cead..4d4a164b37 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -63,7 +62,7 @@ public SqsMessageConsumerRejectTestsAsync()
);
}
- [Fact]
+ [Test]
public async Task When_rejecting_a_message_should_delete_from_queue_async()
{
//Arrange
@@ -76,13 +75,14 @@ public async Task When_rejecting_a_message_should_delete_from_queue_async()
//Assert - message should be deleted, not requeued
message = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq_async.cs
index 9a78e07c24..6cc13724c2 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq_async.cs
@@ -30,13 +30,12 @@ THE SOFTWARE. */
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerFifoDeliveryErrorDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerFifoDeliveryErrorDlqTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -107,7 +106,7 @@ public SqsMessageConsumerFifoDeliveryErrorDlqTestsAsync()
_dlqChannel = _dlqChannelFactory.CreateAsyncChannel(dlqSubscription);
}
- [Fact]
+ [Test]
public async Task When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq_async()
{
//Arrange
@@ -121,32 +120,33 @@ public async Task When_rejecting_fifo_message_with_delivery_error_should_send_to
//Assert - message should appear on DLQ
var dlqMessage = await _dlqChannel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.NotEqual(MessageType.MT_NONE, dlqMessage.Header.MessageType);
- Assert.Equal(_message.Body.Value, dlqMessage.Body.Value);
+ await Assert.That(dlqMessage.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
+ await Assert.That(dlqMessage.Body.Value).IsEqualTo(_message.Body.Value);
//verify FIFO attributes are preserved on DLQ message
- Assert.Equal(_messageGroupId, dlqMessage.Header.PartitionKey);
+ await Assert.That(dlqMessage.Header.PartitionKey).IsEqualTo(_messageGroupId);
//verify rejection metadata was added
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalTopic"));
- Assert.Equal(originalTopic, dlqMessage.Header.Bag["originalTopic"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionReason"));
- Assert.Equal(RejectionReason.DeliveryError.ToString(), dlqMessage.Header.Bag["rejectionReason"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp"));
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalMessageType"));
- Assert.Equal(MessageType.MT_COMMAND.ToString(), dlqMessage.Header.Bag["originalMessageType"].ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalTopic")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalTopic"].ToString()).IsEqualTo(originalTopic);
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionReason")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["rejectionReason"].ToString()).IsEqualTo(RejectionReason.DeliveryError.ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalMessageType")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalMessageType"].ToString()).IsEqualTo(MessageType.MT_COMMAND.ToString());
//verify original message is deleted from source queue
var sourceMessage = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, sourceMessage.Header.MessageType);
+ await Assert.That(sourceMessage.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _dlqChannelFactory.DeleteTopicAsync().Wait();
- _dlqChannelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _dlqChannelFactory.DeleteTopicAsync();
+ await _dlqChannelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_requeueing_a_message_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_requeueing_a_message_async.cs
index e41357e9f4..ec5fcab28f 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_requeueing_a_message_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_requeueing_a_message_async.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTestsAsync : IAsyncDisposable
{
private readonly IAmAMessageProducerAsync _sender;
private Message? _requeuedMessage;
@@ -61,7 +60,7 @@ public SqsMessageProducerRequeueTestsAsync()
_channel = _channelFactory.CreateAsyncChannel(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_a_message_async()
{
await _sender.SendAsync(_message);
@@ -72,13 +71,14 @@ public async Task When_requeueing_a_message_async()
await _channel.AcknowledgeAsync(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
index 7cb781618d..20736e79da 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
@@ -9,14 +9,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTestsAsync : IAsyncDisposable
{
private readonly SqsMessageProducer _sender;
private readonly IAmAChannelAsync _channel;
@@ -69,7 +68,7 @@ public SqsMessageProducerDlqTestsAsync()
_channel = _channelFactory.CreateAsyncChannel(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_redrives_to_the_queue_async()
{
await _sender.SendAsync(_message);
@@ -85,7 +84,7 @@ public async Task When_requeueing_redrives_to_the_queue_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync(_dlqChannelName.ToValidSQSQueueName(true));
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
private async Task GetDLQCountAsync(string queueName)
@@ -108,10 +107,11 @@ private async Task GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
index c76d8a0288..c6cb3de602 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
@@ -12,13 +12,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTestsAsync : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -127,7 +126,7 @@ public async Task GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- [Fact(Skip = "This test is skipped because running tests of the DLQ is unreliable in the CI environment")]
+ [Test, Skip("This test is skipped because running tests of the DLQ is unreliable in the CI environment")]
public async Task When_throwing_defer_action_respect_redrive_async()
{
await _sender.SendAsync(_message);
@@ -143,13 +142,14 @@ public async Task When_throwing_defer_action_respect_redrive_async()
await Task.Delay(5000);
var dlqCount = await GetDLQCountAsync(_dlqChannelName + ".fifo");
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_topic_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
index 67ff91a4be..9d9acf6bce 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
@@ -3,12 +3,11 @@
using Amazon.SQS.Model;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTestsAsync
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -25,7 +24,7 @@ public AwsValidateMissingTopicTestsAsync()
// Because we don't use channel factory to create the infrastructure - it won't exist
}
- [Fact]
+ [Test]
public async Task When_queue_missing_verify_throws_async()
{
// arrange
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
index 920a9cc001..eaebd6dce6 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTests : IAsyncDisposable
{
private readonly SqsMessageProducer _messageProducer;
private readonly SqsMessageConsumer _consumer;
@@ -62,7 +61,7 @@ public SqsBufferedConsumerTests()
));
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages()
{
var routingKey = new RoutingKey(_queueName);
@@ -109,11 +108,11 @@ public async Task When_a_message_consumer_reads_multiple_messages()
);
//send MESSAGE_COUNT messages
- _messageProducer.Send(messageOne);
- _messageProducer.Send(messageTwo);
- _messageProducer.Send(messageThree);
- _messageProducer.Send(messageFour);
- _messageProducer.Send(messageFive);
+ await _messageProducer.SendAsync(messageOne);
+ await _messageProducer.SendAsync(messageTwo);
+ await _messageProducer.SendAsync(messageThree);
+ await _messageProducer.SendAsync(messageFour);
+ await _messageProducer.SendAsync(messageFive);
int iteration = 0;
@@ -125,18 +124,18 @@ public async Task When_a_message_consumer_reads_multiple_messages()
var outstandingMessageCount = MessageCount - messagesReceivedCount;
//retrieve messages
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(10000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
{
messagesReceived.Add(message);
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
messagesReceivedCount = messagesReceived.Count;
@@ -145,15 +144,16 @@ public async Task When_a_message_consumer_reads_multiple_messages()
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_assume.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_assume.cs
index ad14259cf7..db36ec7cd8 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_assume.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_assume.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AwsAssumeInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AwsAssumeInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -69,27 +68,28 @@ public AwsAssumeInfrastructureTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName(true));
}
- [Fact]
- public void When_infastructure_exists_can_assume()
+ [Test]
+ public async Task When_infastructure_exists_can_assume()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(5000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_verify.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_verify.cs
index ac6d2bbdbf..f05120586d 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_verify.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_verify.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AwsValidateInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AwsValidateInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -74,11 +73,11 @@ public AwsValidateInfrastructureTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -86,19 +85,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_verify_by_url.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_verify_by_url.cs
index 6c69d9cb6d..bc0b8a4ad9 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_verify_by_url.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_infastructure_exists_can_verify_by_url.cs
@@ -7,22 +7,22 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AwsValidateInfrastructureByUrlTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AwsValidateInfrastructureByUrlTests : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerSync _consumer;
- private readonly SqsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByUrlTests ()
+ private Message _message;
+ private IAmAMessageConsumerSync _consumer;
+ private SqsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
var replyTo = new RoutingKey("http:\\queueUrl");
var contentType = new ContentType(MediaTypeNames.Text.Plain);
@@ -62,7 +62,7 @@ public AwsValidateInfrastructureByUrlTests ()
_channelFactory = new ChannelFactory(awsConnection);
var channel = _channelFactory.CreateSyncChannel(subscription);
- var queueUrl = FindQueueUrl(awsConnection, routingKey.ToValidSQSQueueName(true));
+ var queueUrl = await FindQueueUrl(awsConnection, routingKey.ToValidSQSQueueName(true));
//Now change the subscription to validate, just check what we made
subscription.MakeChannels = OnMissingChannel.Validate;
@@ -81,11 +81,11 @@ public AwsValidateInfrastructureByUrlTests ()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -93,19 +93,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
@@ -116,10 +117,10 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- private static string FindQueueUrl(AWSMessagingGatewayConnection connection, string queueName)
+ private static async Task FindQueueUrl(AWSMessagingGatewayConnection connection, string queueName)
{
- using var snsClient = new AWSClientFactory(connection).CreateSqsClient();
- var topicResponse = snsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
+ using var snsClient = new AWSClientFactory(connection).CreateSqsClient();
+ var topicResponse = await snsClient.GetQueueUrlAsync(queueName);
return topicResponse.QueueUrl;
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
index dfd107352d..8511cefc41 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.Extensions;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendAsyncTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -71,14 +70,14 @@ public SqsMessageProducerSendAsyncTests()
);
}
- [Fact]
- public void When_posting_a_message_via_the_producer()
+ [Test]
+ public async Task When_posting_a_message_via_the_producer()
{
// arrange
_message.Header.Subject = "test subject";
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
- Task.Delay(1000).GetAwaiter().GetResult();
+ await Task.Delay(1000);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
@@ -86,34 +85,35 @@ public void When_posting_a_message_via_the_producer()
_channel.Acknowledge(message);
// should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_queueName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_queueName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
// allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
// {"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
- Assert.Equal(_messageGroupId, message.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, message.Header.Bag);
- Assert.Equal(_deduplicationId, message.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(message.Header.PartitionKey).IsEqualTo(_messageGroupId);
+ await Assert.That(message.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(message.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(_deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_queues_missing_assume_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_queues_missing_assume_throws.cs
index 56c4d7fc9d..5eda21a309 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_queues_missing_assume_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_queues_missing_assume_throws.cs
@@ -4,13 +4,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AWSAssumeQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AWSAssumeQueuesTests : IAsyncDisposable
{
private readonly ChannelFactory _channelFactory;
private readonly SqsMessageConsumer _consumer;
@@ -40,16 +39,17 @@ public AWSAssumeQueuesTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
- public void When_queues_missing_assume_throws()
+ [Test]
+ public async Task When_queues_missing_assume_throws()
{
//we will try to get the queue url, and fail because it does not exist
- Assert.Throws(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000)));
+ await Assert.That(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000))).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_queues_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_queues_missing_verify_throws.cs
index 7113cd218a..26e0ab6039 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_queues_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_queues_missing_verify_throws.cs
@@ -4,12 +4,11 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AWSValidateQueuesTests : IAsyncDisposable
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -37,13 +36,13 @@ public AWSValidateQueuesTests()
_awsConnection = GatewayFactory.CreateFactory();
}
- [Fact]
- public void When_queues_missing_verify_throws()
+ [Test]
+ public async Task When_queues_missing_verify_throws()
{
// We have no queues so we should throw
// We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
- Assert.Throws(() => _channelFactory.CreateAsyncChannel(_subscription));
+ await Assert.That(() => _channelFactory.CreateAsyncChannel(_subscription)).ThrowsExactly();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
index d27d62e842..7ae11f7033 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTests : IDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTests
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -59,11 +58,11 @@ public SqsMessageConsumerRejectTests()
);
}
- [Fact]
- public void When_rejecting_a_message_should_delete_from_queue()
+ [Test]
+ public async Task When_rejecting_a_message_should_delete_from_queue()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -72,13 +71,14 @@ public void When_rejecting_a_message_should_delete_from_queue()
//Assert - message should be deleted, not requeued
message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq.cs
index 1984144559..20415e9a32 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq.cs
@@ -30,13 +30,12 @@ THE SOFTWARE. */
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerFifoDeliveryErrorDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerFifoDeliveryErrorDlqTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -107,11 +106,11 @@ public SqsMessageConsumerFifoDeliveryErrorDlqTests()
_dlqChannel = _dlqChannelFactory.CreateSyncChannel(dlqSubscription);
}
- [Fact]
- public void When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq()
+ [Test]
+ public async Task When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -121,32 +120,33 @@ public void When_rejecting_fifo_message_with_delivery_error_should_send_to_dlq()
//Assert - message should appear on DLQ
var dlqMessage = _dlqChannel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.NotEqual(MessageType.MT_NONE, dlqMessage.Header.MessageType);
- Assert.Equal(_message.Body.Value, dlqMessage.Body.Value);
+ await Assert.That(dlqMessage.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
+ await Assert.That(dlqMessage.Body.Value).IsEqualTo(_message.Body.Value);
//verify FIFO attributes are preserved on DLQ message
- Assert.Equal(_messageGroupId, dlqMessage.Header.PartitionKey);
+ await Assert.That(dlqMessage.Header.PartitionKey).IsEqualTo(_messageGroupId);
//verify rejection metadata was added
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalTopic"));
- Assert.Equal(originalTopic, dlqMessage.Header.Bag["originalTopic"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionReason"));
- Assert.Equal(RejectionReason.DeliveryError.ToString(), dlqMessage.Header.Bag["rejectionReason"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp"));
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalMessageType"));
- Assert.Equal(MessageType.MT_COMMAND.ToString(), dlqMessage.Header.Bag["originalMessageType"].ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalTopic")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalTopic"].ToString()).IsEqualTo(originalTopic);
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionReason")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["rejectionReason"].ToString()).IsEqualTo(RejectionReason.DeliveryError.ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalMessageType")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalMessageType"].ToString()).IsEqualTo(MessageType.MT_COMMAND.ToString());
//verify original message is deleted from source queue
var sourceMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, sourceMessage.Header.MessageType);
+ await Assert.That(sourceMessage.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _dlqChannelFactory.DeleteTopicAsync().Wait();
- _dlqChannelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _dlqChannelFactory.DeleteTopicAsync();
+ await _dlqChannelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_requeueing_a_message.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_requeueing_a_message.cs
index 0b14c11b17..6e1dcb8446 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_requeueing_a_message.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_requeueing_a_message.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTests : IAsyncDisposable
{
private readonly IAmAMessageProducerSync _sender;
private Message _requeuedMessage;
@@ -63,8 +62,8 @@ public SqsMessageProducerRequeueTests()
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_a_message()
+ [Test]
+ public async Task When_requeueing_a_message()
{
_sender.Send(_message);
_receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
@@ -74,13 +73,14 @@ public void When_requeueing_a_message()
_channel.Acknowledge(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
index e0f95e877a..2fbb42c5d3 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
@@ -9,14 +9,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTests : IAsyncDisposable
{
private readonly SqsMessageProducer _sender;
private readonly IAmAChannelSync _channel;
@@ -71,10 +70,10 @@ public SqsMessageProducerDlqTests()
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_redrives_to_the_queue()
+ [Test]
+ public async Task When_requeueing_redrives_to_the_queue()
{
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
var receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
_channel.Requeue(receivedMessage);
@@ -88,19 +87,19 @@ public void When_requeueing_redrives_to_the_queue()
Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName + ".fifo"));
+ await Assert.That(await GetDLQCount(_dlqChannelName + ".fifo")).IsEqualTo(1);
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageAttributeNames = ["All", "ApproximateReceiveCount"]
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -111,10 +110,11 @@ private int GetDLQCount(string queueName)
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
index 3804fbe7be..cf935901d5 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
@@ -12,13 +12,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTests : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -105,17 +104,17 @@ public SnsReDrivePolicySDlqTests()
};
}
- public int GetDLQCountAsync(string queueName)
+ public async Task GetDLQCountAsync(string queueName)
{
using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName.ToValidSQSQueueName(true)).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName.ToValidSQSQueueName(true));
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageSystemAttributeNames = ["ApproximateReceiveCount"],
MessageAttributeNames = new List { "All" }
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -126,29 +125,30 @@ public int GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- [Fact(Skip = "This test is skipped because running tests of the DLQ is unreliable in the CI environment")]
- public void When_throwing_defer_action_respect_redrive_async()
+ [Test, Skip("This test is skipped because running tests of the DLQ is unreliable in the CI environment")]
+ public async Task When_throwing_defer_action_respect_redrive_async()
{
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
var task = Task.Factory.StartNew(() => _messagePump.Run(), TaskCreationOptions.LongRunning);
- Task.Delay(5000).GetAwaiter().GetResult();
+ await Task.Delay(5000);
var quitMessage = MessageFactory.CreateQuitMessage(_subscription.RoutingKey);
_channel.Enqueue(quitMessage);
- Task.WaitAll(task);
+ await task;
- Task.Delay(5000).GetAwaiter().GetResult();
+ await Task.Delay(5000);
- var dlqCount = GetDLQCountAsync(_dlqChannelName);
- Assert.Equal(1, dlqCount);
+ var dlqCount = await GetDLQCountAsync(_dlqChannelName);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_topic_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_topic_missing_verify_throws.cs
index e18511000f..a462f5c8d3 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_topic_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Fifo/Reactor/When_topic_missing_verify_throws.cs
@@ -1,13 +1,12 @@
-using System;
+using System;
using System.Collections.Generic;
using Amazon.SQS.Model;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Fifo.Reactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AWSValidateMissingTopicTests
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -23,8 +22,8 @@ public AWSValidateMissingTopicTests()
// Because we don't use channel factory to create the infrastructure - it won't exist
}
- [Fact]
- public void When_channel_missing_verify_throws()
+ [Test]
+ public async Task When_channel_missing_verify_throws()
{
// arrange
var producer = new SqsMessageProducer(
@@ -39,10 +38,12 @@ public void When_channel_missing_verify_throws()
var messageGroupId = $"MessageGroup{Guid.NewGuid():N}";
// act & assert
- Assert.Throws(() =>
+ Assert.ThrowsExactly(() =>
+ {
producer.Send(new Message(
new MessageHeader("", _routingKey, MessageType.MT_EVENT,
type: new CloudEventsType("plain/text"), partitionKey: messageGroupId),
- new MessageBody("Test"))));
+ new MessageBody("Test")));
+ });
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
index 8a538e1cc6..8c1e7be081 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
@@ -6,23 +6,23 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SQSBufferedConsumerTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SQSBufferedConsumerTestsAsync : IAsyncDisposable
{
- private readonly SqsMessageProducer _messageProducer;
- private readonly SqsMessageConsumer _consumer;
- private readonly string _queueName;
- private readonly ChannelFactory _channelFactory;
+ private SqsMessageProducer _messageProducer;
+ private SqsMessageConsumer _consumer;
+ private string _queueName;
+ private ChannelFactory _channelFactory;
private readonly ContentType _contentType = new(MediaTypeNames.Text.Plain);
private const int BufferSize = 3;
private const int MessageCount = 4;
- public SQSBufferedConsumerTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var awsConnection = GatewayFactory.CreateFactory();
@@ -33,16 +33,15 @@ public SQSBufferedConsumerTestsAsync()
//we need the channel to create the queues and notifications
var routingKey = new RoutingKey(_queueName);
var channelName = new ChannelName(_queueName);
-
- var channel = _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
+
+ var channel = await _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
subscriptionName: new SubscriptionName(subscriptionName),
channelName: channelName,
- channelType: ChannelType.PointToPoint,
- routingKey: routingKey,
- bufferSize: BufferSize,
+ channelType: ChannelType.PointToPoint,
+ routingKey: routingKey,
+ bufferSize: BufferSize,
makeChannels: OnMissingChannel.Create,
- queueAttributes: new SqsAttributes(tags: new Dictionary { { "Environment", "Test" } })))
- .GetAwaiter().GetResult();
+ queueAttributes: new SqsAttributes(tags: new Dictionary { { "Environment", "Test" } })));
//we want to access via a consumer, to receive multiple messages - we don't want to expose on channel
//just for the tests, so create a new consumer from the properties
@@ -53,7 +52,7 @@ public SQSBufferedConsumerTestsAsync()
);
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages_async()
{
var routingKey = new RoutingKey(_queueName);
@@ -99,10 +98,10 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
//retrieve messages
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
@@ -117,7 +116,7 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
public async ValueTask DisposeAsync()
@@ -127,10 +126,11 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().GetAwaiter().GetResult();
- _channelFactory.DeleteQueueAsync().GetAwaiter().GetResult();
- _messageProducer.DisposeAsync().GetAwaiter().GetResult();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_customising_aws_client_config_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_customising_aws_client_config_async.cs
index 8ae5d61eb0..7cc722fca2 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_customising_aws_client_config_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_customising_aws_client_config_async.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class CustomisingAwsClientConfigTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class CustomisingAwsClientConfigTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -65,7 +64,7 @@ public CustomisingAwsClientConfigTestsAsync()
);
}
- [Fact]
+ [Test]
public async Task When_customising_aws_client_config()
{
//arrange
@@ -79,18 +78,19 @@ public async Task When_customising_aws_client_config()
await _channel.AcknowledgeAsync(message);
//publish_and_subscribe_should_use_custom_http_client_factory
- Assert.Contains("sqs_async_sub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["sqs_async_sub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("sqs_async_sub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["sqs_async_sub"]) > (0)).IsTrue();
- Assert.Contains("sqs_async_pub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["sqs_async_pub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("sqs_async_pub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["sqs_async_pub"]) > (0)).IsTrue();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_assume_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_assume_async.cs
index 32ddae4f3a..2dd5ce6528 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_assume_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_assume_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AWSAssumeInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AWSAssumeInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -67,7 +66,7 @@ public AWSAssumeInfrastructureTestsAsync()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
+ [Test]
public async Task When_infastructure_exists_can_assume()
{
//arrange
@@ -77,17 +76,18 @@ public async Task When_infastructure_exists_can_assume()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
index 03acba2f5d..e19f00cc1d 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor
{
- [Trait("Category", "AWS")]
- [Trait("Fragile", "CI")]
- public class AwsValidateInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+ [Category("AWS")]
+ [Property("Fragile", "CI")]
+ public class AwsValidateInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -64,7 +63,7 @@ public AwsValidateInfrastructureTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -74,18 +73,19 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_by_url.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_by_url.cs
index b32e0faabf..eb2fbd1be9 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_by_url.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_by_url.cs
@@ -7,22 +7,22 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AWSValidateInfrastructureByUrlTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AWSValidateInfrastructureByUrlTests : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerSync _consumer;
- private readonly SqsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AWSValidateInfrastructureByUrlTests()
+ private Message _message;
+ private IAmAMessageConsumerSync _consumer;
+ private SqsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
var replyTo = new RoutingKey("http:\\queueUrl");
@@ -51,7 +51,7 @@ public AWSValidateInfrastructureByUrlTests()
_channelFactory = new ChannelFactory(awsConnection);
var channel = _channelFactory.CreateSyncChannel(subscription);
- var queueUrl = FindQueueUrl(awsConnection, routingKey.Value);
+ var queueUrl = await FindQueueUrl(awsConnection, routingKey.Value);
//Now change the subscription to validate, just check what we made
subscription = new SqsSubscription(
@@ -76,11 +76,11 @@ public AWSValidateInfrastructureByUrlTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -88,19 +88,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
@@ -111,10 +112,10 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- private static string FindQueueUrl(AWSMessagingGatewayConnection connection, string queueName)
+ private static async Task FindQueueUrl(AWSMessagingGatewayConnection connection, string queueName)
{
using var snsClient = new AWSClientFactory(connection).CreateSqsClient();
- var topicResponse = snsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
+ var topicResponse = await snsClient.GetQueueUrlAsync(queueName);
return topicResponse.QueueUrl;
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_by_url_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_by_url_async.cs
index 4973c64b2d..fd3d4fc2f2 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_by_url_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_infrastructure_exists_can_verify_by_url_async.cs
@@ -7,22 +7,22 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AwsValidateInfrastructureByUrlTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AwsValidateInfrastructureByUrlTestsAsync : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerAsync _consumer;
- private readonly SqsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByUrlTestsAsync()
+ private Message _message;
+ private IAmAMessageConsumerAsync _consumer;
+ private SqsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
const string replyTo = "http:\\queueUrl";
@@ -52,9 +52,9 @@ public AwsValidateInfrastructureByUrlTestsAsync()
var awsConnection = GatewayFactory.CreateFactory();
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
- var queueUrl = FindQueueUrl(awsConnection, routingKey.Value).Result;
+ var queueUrl = await FindQueueUrl(awsConnection, routingKey.Value);
subscription = new(
subscriptionName: new SubscriptionName(subscriptionName),
@@ -77,7 +77,7 @@ public AwsValidateInfrastructureByUrlTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -87,7 +87,7 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
@@ -99,13 +99,14 @@ private static async Task FindQueueUrl(AWSMessagingGatewayConnection con
return response.QueueUrl;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_posting_a_message_resources_are_tagged_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_posting_a_message_resources_are_tagged_async.cs
index fa323d48f0..7c23d953c9 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_posting_a_message_resources_are_tagged_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_posting_a_message_resources_are_tagged_async.cs
@@ -8,12 +8,11 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerResourcesAreTaggedAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerResourcesAreTaggedAsyncTests : IAsyncDisposable
{
private readonly SqsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -59,7 +58,7 @@ public SqsMessageProducerResourcesAreTaggedAsyncTests()
});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_resources_are_tagged_async()
{
// arrange
@@ -72,14 +71,15 @@ public async Task When_posting_a_message_resources_are_tagged_async()
new ListQueueTagsRequest { QueueUrl = queueUrlResponse.QueueUrl });
// assert - queue has Environment=Test tag
- Assert.True(queueTagsResponse.Tags.ContainsKey("Environment"));
- Assert.Equal("Test", queueTagsResponse.Tags["Environment"]);
+ await Assert.That(queueTagsResponse.Tags.ContainsKey("Environment")).IsTrue();
+ await Assert.That(queueTagsResponse.Tags["Environment"]).IsEqualTo("Test");
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
index 3d562dad76..36d73f7441 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.Extensions;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendAsyncTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -62,7 +61,7 @@ public SqsMessageProducerSendAsyncTests()
});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer_async()
{
// arrange
@@ -77,30 +76,31 @@ public async Task When_posting_a_message_via_the_producer_async()
await _channel.AcknowledgeAsync(message);
// should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_queueName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_queueName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
// allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
// {"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_queues_missing_assume_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_queues_missing_assume_throws_async.cs
index 30ee9ccda7..0fa3d8865d 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_queues_missing_assume_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_queues_missing_assume_throws_async.cs
@@ -4,18 +4,18 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AWSAssumeQueuesTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AWSAssumeQueuesTestsAsync : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly IAmAMessageConsumerAsync _consumer;
+ private ChannelFactory _channelFactory;
+ private IAmAMessageConsumerAsync _consumer;
- public AWSAssumeQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
var queueName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -37,25 +37,26 @@ public AWSAssumeQueuesTestsAsync()
MakeChannels = OnMissingChannel.Create
});
- producer.ConfirmTopicExistsAsync(queueName).Wait();
+ await producer.ConfirmTopicExistsAsync(queueName);
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
//We need to create the topic at least, to check the queues
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_assume_throws_async()
{
//we will try to get the queue url, and fail because it does not exist
- await Assert.ThrowsAsync(() => _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(1000)));
+ await Assert.That(() => _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(1000))).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_queues_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_queues_missing_verify_throws_async.cs
index 13ca375e79..2c6e774b35 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_queues_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_queues_missing_verify_throws_async.cs
@@ -4,12 +4,11 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AWSValidateQueuesTestsAsync : IAsyncDisposable
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -31,13 +30,13 @@ public AWSValidateQueuesTestsAsync()
_awsConnection = GatewayFactory.CreateFactory();
}
- [Fact]
+ [Test]
public async Task When_queues_missing_verify_throws_async()
{
// We have no queues so we should throw
// We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
- await Assert.ThrowsAsync(() => _channelFactory.CreateAsyncChannelAsync(_subscription));
+ await Assert.That(() => _channelFactory.CreateAsyncChannelAsync(_subscription)).ThrowsExactly();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
index cac38d8505..db20097e27 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -60,7 +59,7 @@ public SqsMessageConsumerRejectTestsAsync()
);
}
- [Fact]
+ [Test]
public async Task When_rejecting_a_message_should_delete_from_queue_async()
{
//Arrange
@@ -73,13 +72,14 @@ public async Task When_rejecting_a_message_should_delete_from_queue_async()
//Assert - message should be deleted, not requeued
message = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_rejecting_message_with_delivery_error_should_send_to_dlq_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_rejecting_message_with_delivery_error_should_send_to_dlq_async.cs
index 786e400dd5..0c5646a5ff 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_rejecting_message_with_delivery_error_should_send_to_dlq_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_rejecting_message_with_delivery_error_should_send_to_dlq_async.cs
@@ -30,13 +30,12 @@ THE SOFTWARE. */
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerDeliveryErrorDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerDeliveryErrorDlqTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -96,7 +95,7 @@ public SqsMessageConsumerDeliveryErrorDlqTestsAsync()
_dlqChannel = _dlqChannelFactory.CreateAsyncChannel(dlqSubscription);
}
- [Fact]
+ [Test]
public async Task When_rejecting_message_with_delivery_error_should_send_to_dlq_async()
{
//Arrange
@@ -110,29 +109,30 @@ public async Task When_rejecting_message_with_delivery_error_should_send_to_dlq_
//Assert - message should appear on DLQ
var dlqMessage = await _dlqChannel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.NotEqual(MessageType.MT_NONE, dlqMessage.Header.MessageType);
- Assert.Equal(_message.Body.Value, dlqMessage.Body.Value);
+ await Assert.That(dlqMessage.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
+ await Assert.That(dlqMessage.Body.Value).IsEqualTo(_message.Body.Value);
//verify rejection metadata was added (keys are camelCase due to JSON serialization policy)
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalTopic"));
- Assert.Equal(originalTopic, dlqMessage.Header.Bag["originalTopic"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionReason"));
- Assert.Equal(RejectionReason.DeliveryError.ToString(), dlqMessage.Header.Bag["rejectionReason"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp"));
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalMessageType"));
- Assert.Equal(MessageType.MT_COMMAND.ToString(), dlqMessage.Header.Bag["originalMessageType"].ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalTopic")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalTopic"].ToString()).IsEqualTo(originalTopic);
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionReason")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["rejectionReason"].ToString()).IsEqualTo(RejectionReason.DeliveryError.ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalMessageType")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalMessageType"].ToString()).IsEqualTo(MessageType.MT_COMMAND.ToString());
//verify original message is deleted from source queue
var sourceMessage = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, sourceMessage.Header.MessageType);
+ await Assert.That(sourceMessage.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _dlqChannelFactory.DeleteTopicAsync().Wait();
- _dlqChannelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _dlqChannelFactory.DeleteTopicAsync();
+ await _dlqChannelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_requeueing_a_message_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_requeueing_a_message_async.cs
index 98781fa72d..99d5ea2eb8 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_requeueing_a_message_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_requeueing_a_message_async.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTestsAsync : IAsyncDisposable
{
private readonly IAmAMessageProducerAsync _sender;
private Message _requeuedMessage;
@@ -54,7 +53,7 @@ public SqsMessageProducerRequeueTestsAsync()
_channel = _channelFactory.CreateAsyncChannel(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_a_message_async()
{
await _sender.SendAsync(_message);
@@ -65,13 +64,14 @@ public async Task When_requeueing_a_message_async()
await _channel.AcknowledgeAsync(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
index 8491371c90..e316275ecc 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
@@ -9,14 +9,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTestsAsync : IAsyncDisposable
{
private readonly SqsMessageProducer _sender;
private readonly IAmAChannelAsync _channel;
@@ -65,7 +64,7 @@ public SqsMessageProducerDlqTestsAsync()
_channel = _channelFactory.CreateAsyncChannel(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_redrives_to_the_queue_async()
{
await _sender.SendAsync(_message);
@@ -81,7 +80,7 @@ public async Task When_requeueing_redrives_to_the_queue_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync(_dlqChannelName);
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
private async Task GetDLQCountAsync(string queueName)
@@ -104,10 +103,11 @@ private async Task GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
index 33898b0bc0..27e02c8f77 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
@@ -12,13 +12,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTestsAsync : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -125,7 +124,7 @@ private async Task GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- [Fact(Skip = "DLQ is fragile on async tests")]
+ [Test, Skip("DLQ is fragile on async tests")]
public async Task When_throwing_defer_action_respect_redrive_async()
{
await _sender.SendAsync(_message);
@@ -141,13 +140,14 @@ public async Task When_throwing_defer_action_respect_redrive_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync(_dlqQueueName);
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_topic_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_topic_missing_verify_throws_async.cs
index 2b4ad9eeb2..11e1d6e6c7 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_topic_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Proactor/When_topic_missing_verify_throws_async.cs
@@ -1,13 +1,12 @@
-using System;
+using System;
using System.Threading.Tasks;
using Amazon.SQS.Model;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AWSValidateMissingTopicTestsAsync
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -24,7 +23,7 @@ public AWSValidateMissingTopicTestsAsync()
// Because we don't use channel factory to create the infrastructure - it won't exist
}
- [Fact]
+ [Test]
public async Task When_topic_missing_verify_throws_async()
{
// arrange
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
index 49ff050640..7f39b18820 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SQSBufferedConsumerTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SQSBufferedConsumerTests : IAsyncDisposable
{
private readonly SqsMessageProducer _messageProducer;
private readonly SqsMessageConsumer _consumer;
@@ -53,7 +52,7 @@ public SQSBufferedConsumerTests()
new SqsPublication(channelName: channelName, makeChannels: OnMissingChannel.Create));
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages()
{
var routingKey = new RoutingKey(_queueName);
@@ -83,10 +82,10 @@ public async Task When_a_message_consumer_reads_multiple_messages()
);
//send MESSAGE_COUNT messages
- _messageProducer.Send(messageOne);
- _messageProducer.Send(messageTwo);
- _messageProducer.Send(messageThree);
- _messageProducer.Send(messageFour);
+ await _messageProducer.SendAsync(messageOne);
+ await _messageProducer.SendAsync(messageTwo);
+ await _messageProducer.SendAsync(messageThree);
+ await _messageProducer.SendAsync(messageFour);
int iteration = 0;
@@ -98,18 +97,18 @@ public async Task When_a_message_consumer_reads_multiple_messages()
var outstandingMessageCount = MessageCount - messagesReceivedCount;
//retrieve messages
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(10000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
{
messagesReceived.Add(message);
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
messagesReceivedCount = messagesReceived.Count;
@@ -119,16 +118,17 @@ public async Task When_a_message_consumer_reads_multiple_messages()
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_customising_aws_client_config.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_customising_aws_client_config.cs
index 396a5cffa2..daa7bd4827 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_customising_aws_client_config.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_customising_aws_client_config.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class CustomisingAwsClientConfigTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class CustomisingAwsClientConfigTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -60,11 +59,11 @@ public CustomisingAwsClientConfigTests()
new SqsPublication { ChannelName = channelName, MakeChannels = OnMissingChannel.Create });
}
- [Fact]
+ [Test]
public async Task When_customising_aws_client_config()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -74,18 +73,19 @@ public async Task When_customising_aws_client_config()
_channel.Acknowledge(message);
//publish_and_subscribe_should_use_custom_http_client_factory
- Assert.Contains("sqs_sync_sub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["sqs_sync_sub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("sqs_sync_sub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["sqs_sync_sub"]) > (0)).IsTrue();
- Assert.Contains("sqs_sync_pub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["sqs_sync_pub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("sqs_sync_pub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["sqs_sync_pub"]) > (0)).IsTrue();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_infastructure_exists_can_assume.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_infastructure_exists_can_assume.cs
index 7fb816dae3..e9b45cb2c0 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_infastructure_exists_can_assume.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_infastructure_exists_can_assume.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AWSAssumeInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AWSAssumeInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -68,27 +67,28 @@ public AWSAssumeInfrastructureTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name);
}
- [Fact]
- public void When_infastructure_exists_can_assume()
+ [Test]
+ public async Task When_infastructure_exists_can_assume()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(5000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_infrastructure_exists_can_verify.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_infrastructure_exists_can_verify.cs
index bd65975469..3bb9c7549a 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_infrastructure_exists_can_verify.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_infrastructure_exists_can_verify.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class AWSValidateInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class AWSValidateInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -73,11 +72,11 @@ public AWSValidateInfrastructureTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -85,19 +84,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
index e59958e576..d9e1dd3082 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.Extensions;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -63,12 +62,12 @@ public SqsMessageProducerSendTests()
);
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer()
{
//arrange
_message.Header.Subject = "test subject";
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -78,30 +77,31 @@ public async Task When_posting_a_message_via_the_producer()
_channel.Acknowledge(message);
//should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_queueName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_queueName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
//allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
//{"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queue_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queue_missing_verify_throws.cs
index 41e5ad966a..080177f41c 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queue_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queue_missing_verify_throws.cs
@@ -1,12 +1,11 @@
-using System;
+using System;
using Amazon.SQS.Model;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTests
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -22,8 +21,8 @@ public AwsValidateMissingTopicTests()
//Because we don't use channel factory to create the infrastructure -it won't exist
}
- [Fact]
- public void When_queue_missing_verify_throws()
+ [Test]
+ public async Task When_queue_missing_verify_throws()
{
//arrange
var producer = new SqsMessageProducer(
@@ -31,8 +30,11 @@ public void When_queue_missing_verify_throws()
new SqsPublication(channelName: new ChannelName(_routingKey), makeChannels: OnMissingChannel.Validate));
//act && assert
- Assert.Throws(() => producer.Send(new Message(
- new MessageHeader("", _routingKey, MessageType.MT_EVENT, type: new CloudEventsType("plain/text")),
- new MessageBody("Test"))));
+ Assert.ThrowsExactly(() =>
+ {
+ producer.Send(new Message(
+ new MessageHeader("", _routingKey, MessageType.MT_EVENT, type: new CloudEventsType("plain/text")),
+ new MessageBody("Test")));
+ });
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queues_missing_assume_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queues_missing_assume_throws.cs
index 1f6ac50789..79de69d336 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queues_missing_assume_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queues_missing_assume_throws.cs
@@ -4,13 +4,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AWSAssumeQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AWSAssumeQueuesTests : IAsyncDisposable
{
private readonly ChannelFactory _channelFactory;
private readonly SqsMessageConsumer _consumer;
@@ -36,16 +35,17 @@ public AWSAssumeQueuesTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
- public void When_queues_missing_assume_throws()
+ [Test]
+ public async Task When_queues_missing_assume_throws()
{
//we will try to get the queue url, and fail because it does not exist
- Assert.Throws(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000)));
+ await Assert.That(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000))).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queues_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queues_missing_verify_throws.cs
index 22298a15e9..34e05fe7b7 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queues_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_queues_missing_verify_throws.cs
@@ -4,13 +4,12 @@
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AWSValidateQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AWSValidateQueuesTests : IAsyncDisposable
{
private readonly AWSMessagingGatewayConnection _awsConnection;
private readonly SqsSubscription _subscription;
@@ -31,18 +30,19 @@ public AWSValidateQueuesTests()
_awsConnection = GatewayFactory.CreateFactory();
}
- [Fact]
- public void When_queues_missing_verify_throws()
+ [Test]
+ public async Task When_queues_missing_verify_throws()
{
//We have no queues so we should throw
//We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
- Assert.Throws(() => _channelFactory.CreateSyncChannel(_subscription));
+ await Assert.That(() => _channelFactory.CreateSyncChannel(_subscription)).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_a_message_should_delete_from_queue.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
index 8787d2a256..83fc6a6b49 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTests : IDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTests
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -61,11 +60,11 @@ public SqsMessageConsumerRejectTests()
);
}
- [Fact]
- public void When_rejecting_a_message_should_delete_from_queue()
+ [Test]
+ public async Task When_rejecting_a_message_should_delete_from_queue()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -74,13 +73,14 @@ public void When_rejecting_a_message_should_delete_from_queue()
//Assert - message should be deleted, not requeued
message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_delivery_error_should_send_to_dlq.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_delivery_error_should_send_to_dlq.cs
index deb6f28168..d14f5e1cb0 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_delivery_error_should_send_to_dlq.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_delivery_error_should_send_to_dlq.cs
@@ -30,13 +30,12 @@ THE SOFTWARE. */
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerDeliveryErrorDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerDeliveryErrorDlqTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -96,11 +95,11 @@ public SqsMessageConsumerDeliveryErrorDlqTests()
_dlqChannel = _dlqChannelFactory.CreateSyncChannel(dlqSubscription);
}
- [Fact]
- public void When_rejecting_message_with_delivery_error_should_send_to_dlq()
+ [Test]
+ public async Task When_rejecting_message_with_delivery_error_should_send_to_dlq()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -110,29 +109,30 @@ public void When_rejecting_message_with_delivery_error_should_send_to_dlq()
//Assert - message should appear on DLQ
var dlqMessage = _dlqChannel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.NotEqual(MessageType.MT_NONE, dlqMessage.Header.MessageType);
- Assert.Equal(_message.Body.Value, dlqMessage.Body.Value);
+ await Assert.That(dlqMessage.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
+ await Assert.That(dlqMessage.Body.Value).IsEqualTo(_message.Body.Value);
//verify rejection metadata was added (keys are camelCase due to JSON serialization policy)
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalTopic"));
- Assert.Equal(originalTopic, dlqMessage.Header.Bag["originalTopic"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionReason"));
- Assert.Equal(RejectionReason.DeliveryError.ToString(), dlqMessage.Header.Bag["rejectionReason"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp"));
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalMessageType"));
- Assert.Equal(MessageType.MT_COMMAND.ToString(), dlqMessage.Header.Bag["originalMessageType"].ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalTopic")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalTopic"].ToString()).IsEqualTo(originalTopic);
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionReason")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["rejectionReason"].ToString()).IsEqualTo(RejectionReason.DeliveryError.ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalMessageType")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalMessageType"].ToString()).IsEqualTo(MessageType.MT_COMMAND.ToString());
//verify original message is deleted from source queue
var sourceMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, sourceMessage.Header.MessageType);
+ await Assert.That(sourceMessage.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _dlqChannelFactory.DeleteTopicAsync().Wait();
- _dlqChannelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _dlqChannelFactory.DeleteTopicAsync();
+ await _dlqChannelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_no_channels_configured_should_acknowledge_and_log.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_no_channels_configured_should_acknowledge_and_log.cs
index d3aaa2ab63..c2d0d34de1 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_no_channels_configured_should_acknowledge_and_log.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_no_channels_configured_should_acknowledge_and_log.cs
@@ -30,13 +30,12 @@ THE SOFTWARE. */
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerNoChannelsRejectTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerNoChannelsRejectTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -79,11 +78,11 @@ public SqsMessageConsumerNoChannelsRejectTests()
new SqsPublication(channelName: channelName, makeChannels: OnMissingChannel.Create));
}
- [Fact]
- public void When_rejecting_message_with_no_channels_configured_should_acknowledge_and_log()
+ [Test]
+ public async Task When_rejecting_message_with_no_channels_configured_should_acknowledge_and_log()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act - reject with a DeliveryError reason but no DLQ configured
@@ -91,13 +90,14 @@ public void When_rejecting_message_with_no_channels_configured_should_acknowledg
//Assert - original message should be deleted (acknowledged) since there is no DLQ
var sourceMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, sourceMessage.Header.MessageType);
+ await Assert.That(sourceMessage.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_unacceptable_and_no_invalid_channel_should_fallback_to_dlq.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_unacceptable_and_no_invalid_channel_should_fallback_to_dlq.cs
index 2af0f741a9..281d751de7 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_unacceptable_and_no_invalid_channel_should_fallback_to_dlq.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_unacceptable_and_no_invalid_channel_should_fallback_to_dlq.cs
@@ -30,13 +30,12 @@ THE SOFTWARE. */
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerUnacceptableFallbackToDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerUnacceptableFallbackToDlqTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -97,11 +96,11 @@ public SqsMessageConsumerUnacceptableFallbackToDlqTests()
_dlqChannel = _dlqChannelFactory.CreateSyncChannel(dlqSubscription);
}
- [Fact]
- public void When_rejecting_message_with_unacceptable_and_no_invalid_channel_should_fallback_to_dlq()
+ [Test]
+ public async Task When_rejecting_message_with_unacceptable_and_no_invalid_channel_should_fallback_to_dlq()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -111,29 +110,30 @@ public void When_rejecting_message_with_unacceptable_and_no_invalid_channel_shou
//Assert - message should fall back to the DLQ since no invalid message queue is configured
var dlqMessage = _dlqChannel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.NotEqual(MessageType.MT_NONE, dlqMessage.Header.MessageType);
- Assert.Equal(_message.Body.Value, dlqMessage.Body.Value);
+ await Assert.That(dlqMessage.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
+ await Assert.That(dlqMessage.Body.Value).IsEqualTo(_message.Body.Value);
//verify rejection metadata was added (keys are camelCase due to JSON serialization policy)
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalTopic"));
- Assert.Equal(originalTopic, dlqMessage.Header.Bag["originalTopic"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionReason"));
- Assert.Equal(RejectionReason.Unacceptable.ToString(), dlqMessage.Header.Bag["rejectionReason"].ToString());
- Assert.True(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp"));
- Assert.True(dlqMessage.Header.Bag.ContainsKey("originalMessageType"));
- Assert.Equal(MessageType.MT_COMMAND.ToString(), dlqMessage.Header.Bag["originalMessageType"].ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalTopic")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalTopic"].ToString()).IsEqualTo(originalTopic);
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionReason")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["rejectionReason"].ToString()).IsEqualTo(RejectionReason.Unacceptable.ToString());
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("rejectionTimestamp")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag.ContainsKey("originalMessageType")).IsTrue();
+ await Assert.That(dlqMessage.Header.Bag["originalMessageType"].ToString()).IsEqualTo(MessageType.MT_COMMAND.ToString());
//verify original message is deleted from source queue
var sourceMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, sourceMessage.Header.MessageType);
+ await Assert.That(sourceMessage.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _dlqChannelFactory.DeleteTopicAsync().Wait();
- _dlqChannelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _dlqChannelFactory.DeleteTopicAsync();
+ await _dlqChannelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_unacceptable_reason_should_send_to_invalid_channel.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_unacceptable_reason_should_send_to_invalid_channel.cs
index 7ab61b8ac9..af45471cdd 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_unacceptable_reason_should_send_to_invalid_channel.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_rejecting_message_with_unacceptable_reason_should_send_to_invalid_channel.cs
@@ -30,13 +30,12 @@ THE SOFTWARE. */
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerUnacceptableInvalidChannelTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerUnacceptableInvalidChannelTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -114,11 +113,11 @@ public SqsMessageConsumerUnacceptableInvalidChannelTests()
_dlqChannel = _dlqChannelFactory.CreateSyncChannel(dlqSubscription);
}
- [Fact]
- public void When_rejecting_message_with_unacceptable_reason_should_send_to_invalid_channel()
+ [Test]
+ public async Task When_rejecting_message_with_unacceptable_reason_should_send_to_invalid_channel()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -128,35 +127,36 @@ public void When_rejecting_message_with_unacceptable_reason_should_send_to_inval
//Assert - message should appear on the invalid message queue
var invalidMessage = _invalidChannel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.NotEqual(MessageType.MT_NONE, invalidMessage.Header.MessageType);
- Assert.Equal(_message.Body.Value, invalidMessage.Body.Value);
+ await Assert.That(invalidMessage.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
+ await Assert.That(invalidMessage.Body.Value).IsEqualTo(_message.Body.Value);
//verify rejection metadata was added (keys are camelCase due to JSON serialization policy)
- Assert.True(invalidMessage.Header.Bag.ContainsKey("originalTopic"));
- Assert.Equal(originalTopic, invalidMessage.Header.Bag["originalTopic"].ToString());
- Assert.True(invalidMessage.Header.Bag.ContainsKey("rejectionReason"));
- Assert.Equal(RejectionReason.Unacceptable.ToString(), invalidMessage.Header.Bag["rejectionReason"].ToString());
- Assert.True(invalidMessage.Header.Bag.ContainsKey("rejectionTimestamp"));
- Assert.True(invalidMessage.Header.Bag.ContainsKey("originalMessageType"));
- Assert.Equal(MessageType.MT_COMMAND.ToString(), invalidMessage.Header.Bag["originalMessageType"].ToString());
+ await Assert.That(invalidMessage.Header.Bag.ContainsKey("originalTopic")).IsTrue();
+ await Assert.That(invalidMessage.Header.Bag["originalTopic"].ToString()).IsEqualTo(originalTopic);
+ await Assert.That(invalidMessage.Header.Bag.ContainsKey("rejectionReason")).IsTrue();
+ await Assert.That(invalidMessage.Header.Bag["rejectionReason"].ToString()).IsEqualTo(RejectionReason.Unacceptable.ToString());
+ await Assert.That(invalidMessage.Header.Bag.ContainsKey("rejectionTimestamp")).IsTrue();
+ await Assert.That(invalidMessage.Header.Bag.ContainsKey("originalMessageType")).IsTrue();
+ await Assert.That(invalidMessage.Header.Bag["originalMessageType"].ToString()).IsEqualTo(MessageType.MT_COMMAND.ToString());
//verify message did NOT go to the DLQ
var dlqMessage = _dlqChannel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, dlqMessage.Header.MessageType);
+ await Assert.That(dlqMessage.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
//verify original message is deleted from source queue
var sourceMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, sourceMessage.Header.MessageType);
+ await Assert.That(sourceMessage.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _invalidChannelFactory.DeleteTopicAsync().Wait();
- _invalidChannelFactory.DeleteQueueAsync().Wait();
- _dlqChannelFactory.DeleteTopicAsync().Wait();
- _dlqChannelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _invalidChannelFactory.DeleteTopicAsync();
+ await _invalidChannelFactory.DeleteQueueAsync();
+ await _dlqChannelFactory.DeleteTopicAsync();
+ await _dlqChannelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_requeueing_a_message.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_requeueing_a_message.cs
index 441eebc13d..8623bfb27c 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_requeueing_a_message.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_requeueing_a_message.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTests : IAsyncDisposable
{
private readonly IAmAMessageProducerSync _sender;
private Message _requeuedMessage;
@@ -63,8 +62,8 @@ public SqsMessageProducerRequeueTests()
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_a_message()
+ [Test]
+ public async Task When_requeueing_a_message()
{
_sender.Send(_message);
_receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
@@ -75,13 +74,14 @@ public void When_requeueing_a_message()
//clear the queue
_channel.Acknowledge(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_requeueing_redrives_to_the_dlq.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_requeueing_redrives_to_the_dlq.cs
index 2bc57911a5..0c0e89ab11 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_requeueing_redrives_to_the_dlq.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_requeueing_redrives_to_the_dlq.cs
@@ -10,13 +10,12 @@
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTests : IAsyncDisposable
{
private readonly SqsMessageProducer _sender;
private readonly IAmAChannelSync _channel;
@@ -69,10 +68,10 @@ public SqsMessageProducerDlqTests()
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_redrives_to_the_queue()
+ [Test]
+ public async Task When_requeueing_redrives_to_the_queue()
{
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
var receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
_channel.Requeue(receivedMessage);
@@ -86,19 +85,19 @@ public void When_requeueing_redrives_to_the_queue()
Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName));
+ await Assert.That(await GetDLQCount(_dlqChannelName)).IsEqualTo(1);
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageAttributeNames = new List { "All", "ApproximateReceiveCount" }
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -109,10 +108,11 @@ private int GetDLQCount(string queueName)
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_throwing_defer_action_respect_redrive.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_throwing_defer_action_respect_redrive.cs
index 207c9a994b..af02e2dadf 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_throwing_defer_action_respect_redrive.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/Standard/Reactor/When_throwing_defer_action_respect_redrive.cs
@@ -12,13 +12,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTests : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -117,17 +116,17 @@ public SnsReDrivePolicySDlqTests()
};
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
- using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageSystemAttributeNames = ["ApproximateReceiveCount"],
MessageAttributeNames = new List { "All" }
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -139,11 +138,11 @@ private int GetDLQCount(string queueName)
}
- [Fact]
+ [Test]
public async Task When_throwing_defer_action_respect_redrive()
{
//put something on an SNS topic, which will be delivered to our SQS queue
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
//start a message pump, let it process messages
var task = Task.Factory.StartNew(() => _messagePump.Run(), TaskCreationOptions.LongRunning);
@@ -159,13 +158,14 @@ public async Task When_throwing_defer_action_respect_redrive()
await Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName));
+ await Assert.That(await GetDLQCount(_dlqChannelName)).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/When_creating_sqs_consumer_with_dlq_subscription_should_pass_routing_keys.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/When_creating_sqs_consumer_with_dlq_subscription_should_pass_routing_keys.cs
index aab7f9aaa2..7a3b1301ea 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/When_creating_sqs_consumer_with_dlq_subscription_should_pass_routing_keys.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/When_creating_sqs_consumer_with_dlq_subscription_should_pass_routing_keys.cs
@@ -27,7 +27,6 @@ THE SOFTWARE. */
using Amazon.Runtime;
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs;
@@ -45,8 +44,8 @@ public SqsMessageConsumerFactoryDlqTests()
_factory = new SqsMessageConsumerFactory(connection);
}
- [Fact]
- public void When_creating_sqs_consumer_with_dlq_subscription_should_pass_routing_keys()
+ [Test]
+ public async Task When_creating_sqs_consumer_with_dlq_subscription_should_pass_routing_keys()
{
//Arrange
var dlqRoutingKey = new RoutingKey("orders-dlq");
@@ -64,7 +63,7 @@ public void When_creating_sqs_consumer_with_dlq_subscription_should_pass_routing
_consumer = _factory.Create(subscription);
//Assert - verify the factory passed routing keys to the consumer
- Assert.NotNull(_consumer);
+ await Assert.That(_consumer).IsNotNull();
var consumerType = _consumer.GetType();
var dlqField = consumerType.GetField("_deadLetterRoutingKey",
@@ -72,17 +71,17 @@ public void When_creating_sqs_consumer_with_dlq_subscription_should_pass_routing
var invalidField = consumerType.GetField("_invalidMessageRoutingKey",
BindingFlags.NonPublic | BindingFlags.Instance);
- Assert.NotNull(dlqField);
- Assert.NotNull(invalidField);
+ await Assert.That(dlqField).IsNotNull();
+ await Assert.That(invalidField).IsNotNull();
var actualDlq = dlqField.GetValue(_consumer) as RoutingKey;
var actualInvalid = invalidField.GetValue(_consumer) as RoutingKey;
- Assert.NotNull(actualDlq);
- Assert.Equal("orders-dlq", actualDlq.Value);
+ await Assert.That(actualDlq).IsNotNull();
+ await Assert.That(actualDlq.Value).IsEqualTo("orders-dlq");
- Assert.NotNull(actualInvalid);
- Assert.Equal("orders-invalid", actualInvalid.Value);
+ await Assert.That(actualInvalid).IsNotNull();
+ await Assert.That(actualInvalid.Value).IsEqualTo("orders-invalid");
}
public void Dispose()
diff --git a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/When_creating_sqs_subscription_with_dlq_routing_keys_should_expose_properties.cs b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/When_creating_sqs_subscription_with_dlq_routing_keys_should_expose_properties.cs
index f3d71de9ab..af568e4970 100644
--- a/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/When_creating_sqs_subscription_with_dlq_routing_keys_should_expose_properties.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/MessagingGateway/Sqs/When_creating_sqs_subscription_with_dlq_routing_keys_should_expose_properties.cs
@@ -23,14 +23,13 @@ THE SOFTWARE. */
using Paramore.Brighter.AWS.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.MessagingGateway.Sqs;
public class SqsSubscriptionDlqRoutingKeyTests
{
- [Fact]
- public void When_creating_sqs_subscription_with_dlq_routing_keys_should_expose_properties()
+ [Test]
+ public async Task When_creating_sqs_subscription_with_dlq_routing_keys_should_expose_properties()
{
//Arrange
var deadLetterRoutingKey = new RoutingKey("orders-dlq");
@@ -46,17 +45,17 @@ public void When_creating_sqs_subscription_with_dlq_routing_keys_should_expose_p
);
//Assert
- Assert.IsAssignableFrom(subscription);
+ await Assert.That(subscription).IsAssignableTo();
var dlqSupport = (IUseBrighterDeadLetterSupport)subscription;
- Assert.Equal(deadLetterRoutingKey, dlqSupport.DeadLetterRoutingKey);
+ await Assert.That(dlqSupport.DeadLetterRoutingKey).IsEqualTo(deadLetterRoutingKey);
- Assert.IsAssignableFrom(subscription);
+ await Assert.That(subscription).IsAssignableTo();
var invalidSupport = (IUseBrighterInvalidMessageSupport)subscription;
- Assert.Equal(invalidMessageRoutingKey, invalidSupport.InvalidMessageRoutingKey);
+ await Assert.That(invalidSupport.InvalidMessageRoutingKey).IsEqualTo(invalidMessageRoutingKey);
}
- [Fact]
- public void When_creating_sqs_subscription_without_dlq_routing_keys_should_default_to_null()
+ [Test]
+ public async Task When_creating_sqs_subscription_without_dlq_routing_keys_should_default_to_null()
{
//Arrange & Act
var subscription = new SqsSubscription(
@@ -66,12 +65,12 @@ public void When_creating_sqs_subscription_without_dlq_routing_keys_should_defau
);
//Assert
- Assert.IsAssignableFrom(subscription);
+ await Assert.That(subscription).IsAssignableTo();
var dlqSupport = (IUseBrighterDeadLetterSupport)subscription;
- Assert.Null(dlqSupport.DeadLetterRoutingKey);
+ await Assert.That(dlqSupport.DeadLetterRoutingKey).IsNull();
- Assert.IsAssignableFrom(subscription);
+ await Assert.That(subscription).IsAssignableTo();
var invalidSupport = (IUseBrighterInvalidMessageSupport)subscription;
- Assert.Null(invalidSupport.InvalidMessageRoutingKey);
+ await Assert.That(invalidSupport.InvalidMessageRoutingKey).IsNull();
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/Paramore.Brighter.AWS.Tests.csproj b/tests/Paramore.Brighter.AWS.Tests/Paramore.Brighter.AWS.Tests.csproj
index 7ea80ae547..5e3c4e8c97 100644
--- a/tests/Paramore.Brighter.AWS.Tests/Paramore.Brighter.AWS.Tests.csproj
+++ b/tests/Paramore.Brighter.AWS.Tests/Paramore.Brighter.AWS.Tests.csproj
@@ -1,30 +1,15 @@
-
$(BrighterTestTargetFrameworks)
false
+ Exe
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
@@ -32,9 +17,7 @@
-
-
-
+
\ No newline at end of file
diff --git a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_creating_luggagestore_missing_parameters.cs b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_creating_luggagestore_missing_parameters.cs
index 55f7825494..fea60f7010 100644
--- a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_creating_luggagestore_missing_parameters.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_creating_luggagestore_missing_parameters.cs
@@ -1,10 +1,9 @@
-using System;
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Paramore.Brighter.AWS.Tests.Helpers;
using Paramore.Brighter.Transformers.AWS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.Transformers;
@@ -23,39 +22,39 @@ public S3LuggageUploadMissingParametersTests()
_bucketName = $"brightertestbucket-{Guid.NewGuid()}";
}
- [Fact]
- public void When_creating_luggagestore_missing_client()
+ [Test]
+ public async Task When_creating_luggagestore_missing_client()
{
//arrange
var exception = Catch.Exception(() => new S3LuggageStore(new S3LuggageOptions(null!, null!)));
- Assert.NotNull(exception);
- Assert.IsType(exception);
+ await Assert.That(exception).IsNotNull();
+ await Assert.That(exception).IsTypeOf();
}
- [Theory]
- [InlineData("")]
- [InlineData(null)]
- public void When_creating_luggagestore_missing_bucketName(string? bucketName)
+ [Test]
+ [Arguments("")]
+ [Arguments(null)]
+ public async Task When_creating_luggagestore_missing_bucketName(string? bucketName)
{
//arrange
var exception = Catch.Exception(() => new S3LuggageStore(new S3LuggageOptions(GatewayFactory.CreateS3Connection(), bucketName!)));
- Assert.NotNull(exception);
- Assert.IsType(exception);
+ await Assert.That(exception).IsNotNull();
+ await Assert.That(exception).IsTypeOf();
}
- [Fact]
+ [Test]
public async Task When_creating_luggagestore_bad_bucketName()
{
//arrange
var exception = Catch.Exception(() => new S3LuggageStore(new S3LuggageOptions(GatewayFactory.CreateS3Connection(), "A" )));
- Assert.NotNull(exception);
- Assert.IsType(exception);
+ await Assert.That(exception).IsNotNull();
+ await Assert.That(exception).IsTypeOf();
}
- [Fact]
+ [Test]
public async Task When_creating_luggagestore_missing_httpClient()
{
//arrange
@@ -65,11 +64,11 @@ public async Task When_creating_luggagestore_missing_httpClient()
await store.EnsureStoreExistsAsync();
});
- Assert.NotNull(exception);
- Assert.IsType(exception);
+ await Assert.That(exception).IsNotNull();
+ await Assert.That(exception).IsTypeOf();
}
- [Fact]
+ [Test]
public async Task When_creating_luggagestore_missing_ACL()
{
//arrange
@@ -83,7 +82,7 @@ public async Task When_creating_luggagestore_missing_ACL()
await store.EnsureStoreExistsAsync();
});
- Assert.NotNull(exception);
- Assert.IsType(exception);
+ await Assert.That(exception).IsNotNull();
+ await Assert.That(exception).IsTypeOf();
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_unwrapping_a_large_message.cs b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_unwrapping_a_large_message.cs
index 56690adc44..6d5b44cb4e 100644
--- a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_unwrapping_a_large_message.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_unwrapping_a_large_message.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Net.Http;
using System.Text.Json;
@@ -11,12 +11,11 @@
using Paramore.Brighter.Observability;
using Paramore.Brighter.Transformers.AWS;
using Paramore.Brighter.Transforms.Transformers;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.Transformers;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
+[Category("AWS")]
+[Property("Fragile", "CI")]
public class LargeMessagePaylodUnwrapTests : IAsyncDisposable
{
private readonly TransformPipelineBuilderAsync _pipelineBuilder;
@@ -27,7 +26,6 @@ public class LargeMessagePaylodUnwrapTests : IAsyncDisposable
public LargeMessagePaylodUnwrapTests()
{
//arrange
- TransformPipelineBuilder.ClearPipelineCache();
var mapperRegistry = new MessageMapperRegistry(
null,
@@ -59,7 +57,7 @@ public LargeMessagePaylodUnwrapTests()
_pipelineBuilder = new TransformPipelineBuilderAsync(mapperRegistry, messageTransformerFactory, InstrumentationOptions.All);
}
- [Fact]
+ [Test]
public async Task When_unwrapping_a_large_message()
{
//arrange
@@ -98,8 +96,8 @@ public async Task When_unwrapping_a_large_message()
//assert
//contents should be from storage
- Assert.Equal(contents, transformedMessage.Value);
- Assert.False((await _luggageStore.HasClaimAsync(id)));
+ await Assert.That(transformedMessage.Value).IsEqualTo(contents);
+ await Assert.That((await _luggageStore.HasClaimAsync(id))).IsFalse();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_uploading_luggage_to_S3.cs b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_uploading_luggage_to_S3.cs
index 5ae9a9f24a..073379125e 100644
--- a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_uploading_luggage_to_S3.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_uploading_luggage_to_S3.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Net;
using System.Net.Http;
@@ -11,7 +11,6 @@
using Polly;
using Polly.Contrib.WaitAndRetry;
using Polly.Retry;
-using Xunit;
using Policy = Polly.Policy;
namespace Paramore.Brighter.AWS.Tests.Transformers;
@@ -30,7 +29,7 @@ public S3LuggageUploadTests()
_bucketName = $"brightertestbucket-{Guid.NewGuid()}";
}
- [Fact]
+ [Test]
public async Task When_uploading_luggage_to_S3()
{
//arrange
@@ -58,12 +57,12 @@ public async Task When_uploading_luggage_to_S3()
//assert
//do we have a claim?
- Assert.True((await luggageStore.HasClaimAsync(claim)));
+ await Assert.That((await luggageStore.HasClaimAsync(claim))).IsTrue();
//check for the contents indicated by the claim id on S3
var result = await luggageStore.RetrieveAsync(claim);
var resultAsString = await new StreamReader(result).ReadToEndAsync();
- Assert.Equal(testContent, resultAsString);
+ await Assert.That(resultAsString).IsEqualTo(testContent);
await luggageStore.DeleteAsync(claim);
diff --git a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_validating_a_luggage_store_exists.cs b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_validating_a_luggage_store_exists.cs
index 3b71382985..7663bc7aa9 100644
--- a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_validating_a_luggage_store_exists.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_validating_a_luggage_store_exists.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using Amazon.S3;
@@ -8,12 +8,11 @@
using Paramore.Brighter.MessagingGateway.AWSSQS;
using Paramore.Brighter.Transformers.AWS;
using Paramore.Brighter.Transforms.Storage;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.Transformers;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
+[Category("AWS")]
+[Property("Fragile", "CI")]
public class S3LuggageStoreExistsTests
{
private readonly IHttpClientFactory _httpClientFactory;
@@ -27,7 +26,7 @@ public S3LuggageStoreExistsTests()
_httpClientFactory = provider.GetRequiredService();
}
- [Fact]
+ [Test]
public async Task When_checking_store_that_exists()
{
var bucketName = $"brightertestbucket-{Guid.NewGuid()}";
@@ -55,7 +54,7 @@ public async Task When_checking_store_that_exists()
Tags = [new Tag { Key = "BrighterTests", Value = "S3LuggageUploadTests" }],
});
- Assert.NotNull(luggageStore);
+ await Assert.That(luggageStore).IsNotNull();
//teardown
var factory = new AWSClientFactory(GatewayFactory.CreateFactory());
@@ -63,7 +62,7 @@ public async Task When_checking_store_that_exists()
await client.DeleteBucketAsync(bucketName);
}
- [Fact]
+ [Test]
public async Task When_checking_store_that_does_not_exist()
{
//act
@@ -82,7 +81,7 @@ public async Task When_checking_store_that_does_not_exist()
await luggageStore.EnsureStoreExistsAsync();
});
- Assert.NotNull(doesNotExist);
- Assert.True(doesNotExist is InvalidOperationException);
+ await Assert.That(doesNotExist).IsNotNull();
+ await Assert.That(doesNotExist is InvalidOperationException).IsTrue();
}
}
diff --git a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_wrapping_a_large_message.cs b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_wrapping_a_large_message.cs
index 1ec692ec15..9cc070b234 100644
--- a/tests/Paramore.Brighter.AWS.Tests/Transformers/When_wrapping_a_large_message.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/Transformers/When_wrapping_a_large_message.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using Amazon.S3;
@@ -10,7 +10,6 @@
using Paramore.Brighter.Observability;
using Paramore.Brighter.Transformers.AWS;
using Paramore.Brighter.Transforms.Transformers;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests.Transformers;
@@ -29,7 +28,6 @@ public class LargeMessagePayloadWrapTests : IAsyncDisposable
public LargeMessagePayloadWrapTests()
{
//arrange
- TransformPipelineBuilderAsync.ClearPipelineCache();
var mapperRegistry =
new MessageMapperRegistry(null, new SimpleMessageMapperFactoryAsync(
@@ -67,7 +65,7 @@ public LargeMessagePayloadWrapTests()
_pipelineBuilder = new TransformPipelineBuilderAsync(mapperRegistry, transformerFactoryAsync, InstrumentationOptions.All);
}
- [Fact]
+ [Test]
public async Task When_wrapping_a_large_message()
{
//act
@@ -75,12 +73,12 @@ public async Task When_wrapping_a_large_message()
var message = await _transformPipeline.WrapAsync(_myCommand, new RequestContext(), _publication);
//assert
- Assert.True(message.Header.Bag.ContainsKey(ClaimCheckTransformer.CLAIM_CHECK));
- Assert.NotNull(message.Header.DataRef);
+ await Assert.That(message.Header.Bag.ContainsKey(ClaimCheckTransformer.CLAIM_CHECK)).IsTrue();
+ await Assert.That(message.Header.DataRef).IsNotNull();
_id = (string)message.Header.Bag[ClaimCheckTransformer.CLAIM_CHECK];
- Assert.Equal($"Claim Check {_id}", message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo($"Claim Check {_id}");
- Assert.True(await _luggageStore.HasClaimAsync(_id));
+ await Assert.That(await _luggageStore.HasClaimAsync(_id)).IsTrue();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.Tests/When_creating_sns_attributes_with_tags.cs b/tests/Paramore.Brighter.AWS.Tests/When_creating_sns_attributes_with_tags.cs
index c807142089..b5f8703c72 100644
--- a/tests/Paramore.Brighter.AWS.Tests/When_creating_sns_attributes_with_tags.cs
+++ b/tests/Paramore.Brighter.AWS.Tests/When_creating_sns_attributes_with_tags.cs
@@ -1,14 +1,13 @@
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
using Paramore.Brighter.MessagingGateway.AWSSQS;
-using Xunit;
namespace Paramore.Brighter.AWS.Tests;
public class When_creating_sns_attributes_with_tags
{
- [Fact]
- public void When_tags_provided_should_store_them()
+ [Test]
+ public async Task When_tags_provided_should_store_them()
{
//arrange
var tags = new List { new() { Key = "Environment", Value = "Test" } };
@@ -17,36 +16,36 @@ public void When_tags_provided_should_store_them()
var snsAttributes = new SnsAttributes(tags: tags);
//assert
- Assert.NotNull(snsAttributes.Tags);
- Assert.Single(snsAttributes.Tags);
- Assert.Equal("Environment", snsAttributes.Tags[0].Key);
- Assert.Equal("Test", snsAttributes.Tags[0].Value);
+ await Assert.That(snsAttributes.Tags).IsNotNull();
+ await Assert.That(snsAttributes.Tags).HasSingleItem();
+ await Assert.That(snsAttributes.Tags[0].Key).IsEqualTo("Environment");
+ await Assert.That(snsAttributes.Tags[0].Value).IsEqualTo("Test");
}
- [Fact]
- public void When_no_tags_provided_should_be_empty()
+ [Test]
+ public async Task When_no_tags_provided_should_be_empty()
{
//act
var snsAttributes = new SnsAttributes();
//assert
- Assert.NotNull(snsAttributes.Tags);
- Assert.Empty(snsAttributes.Tags);
+ await Assert.That(snsAttributes.Tags).IsNotNull();
+ await Assert.That(snsAttributes.Tags).IsEmpty();
}
- [Fact]
- public void When_empty_should_have_empty_tags()
+ [Test]
+ public async Task When_empty_should_have_empty_tags()
{
//act
var snsAttributes = SnsAttributes.Empty;
//assert
- Assert.NotNull(snsAttributes.Tags);
- Assert.Empty(snsAttributes.Tags);
+ await Assert.That(snsAttributes.Tags).IsNotNull();
+ await Assert.That(snsAttributes.Tags).IsEmpty();
}
- [Fact]
- public void When_tags_provided_should_not_affect_other_parameters()
+ [Test]
+ public async Task When_tags_provided_should_not_affect_other_parameters()
{
//arrange
var tags = new List { new() { Key = "Environment", Value = "Test" } };
@@ -63,11 +62,11 @@ public void When_tags_provided_should_not_affect_other_parameters()
);
//assert
- Assert.Equal(deliveryPolicy, snsAttributes.DeliveryPolicy);
- Assert.Equal(policy, snsAttributes.Policy);
- Assert.Equal(SqsType.Fifo, snsAttributes.Type);
- Assert.False(snsAttributes.ContentBasedDeduplication);
- Assert.NotNull(snsAttributes.Tags);
- Assert.Single(snsAttributes.Tags);
+ await Assert.That(snsAttributes.DeliveryPolicy).IsEqualTo(deliveryPolicy);
+ await Assert.That(snsAttributes.Policy).IsEqualTo(policy);
+ await Assert.That(snsAttributes.Type).IsEqualTo(SqsType.Fifo);
+ await Assert.That(snsAttributes.ContentBasedDeduplication).IsFalse();
+ await Assert.That(snsAttributes.Tags).IsNotNull();
+ await Assert.That(snsAttributes.Tags).HasSingleItem();
}
}
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
index 01d6c06be6..f84e9bf2d9 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
@@ -6,23 +6,23 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTestsAsync : IAsyncDisposable
{
- private readonly SnsMessageProducer _messageProducer;
- private readonly SqsMessageConsumer _consumer;
- private readonly string _topicName;
- private readonly ChannelFactory _channelFactory;
+ private SnsMessageProducer _messageProducer;
+ private SqsMessageConsumer _consumer;
+ private string _topicName;
+ private ChannelFactory _channelFactory;
private readonly ContentType _contentType = new(MediaTypeNames.Text.Plain);
private const int BufferSize = 3;
private const int MessageCount = 4;
- public SqsBufferedConsumerTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var awsConnection = GatewayFactory.CreateFactory();
@@ -34,7 +34,7 @@ public SqsBufferedConsumerTestsAsync()
//we need the channel to create the queues and notifications
var routingKey = new RoutingKey(_topicName);
- var channel = _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
+ var channel = await _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
subscriptionName: new SubscriptionName(channelName),
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
@@ -45,9 +45,9 @@ public SqsBufferedConsumerTestsAsync()
type: SqsType.Fifo,
deduplicationScope: DeduplicationScope.MessageGroup,
fifoThroughputLimit: FifoThroughputLimit.PerMessageGroupId,
- tags: new Dictionary { { "Environment", "Test" } }),
+ tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- makeChannels: OnMissingChannel.Create)).GetAwaiter().GetResult();
+ makeChannels: OnMissingChannel.Create));
//we want to access via a consumer, to receive multiple messages - we don't want to expose on channel
//just for the tests, so create a new consumer from the properties
@@ -59,7 +59,7 @@ public SqsBufferedConsumerTestsAsync()
});
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages_async()
{
var routingKey = new RoutingKey(_topicName);
@@ -121,10 +121,10 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
//retrieve messages
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
@@ -138,7 +138,7 @@ public async Task When_a_message_consumer_reads_multiple_messages_async()
await Task.Delay(1000);
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
public async ValueTask DisposeAsync()
@@ -148,10 +148,11 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().GetAwaiter().GetResult();
- _channelFactory.DeleteQueueAsync().GetAwaiter().GetResult();
- _messageProducer.DisposeAsync().GetAwaiter().GetResult();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
}
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
index 1c85ad66e4..847bfbdc9e 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infastructure_exists_can_assume_async.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -65,7 +64,7 @@ public AwsAssumeInfrastructureTestsAsync()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName(true));
}
- [Fact]
+ [Test]
public async Task When_infastructure_exists_can_assume()
{
//arrange
@@ -75,17 +74,18 @@ public async Task When_infastructure_exists_can_assume()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
index cc7579b106..807217a178 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_async.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -71,7 +70,7 @@ public AwsValidateInfrastructureTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -81,18 +80,19 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
index b288e02e7a..ad2825aa76 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
@@ -7,21 +7,21 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByArnTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByArnTestsAsync : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerAsync _consumer;
- private readonly SnsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByArnTestsAsync()
+ private Message _message;
+ private IAmAMessageConsumerAsync _consumer;
+ private SnsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
const string replyTo = "http:\\queueUrl";
@@ -37,9 +37,9 @@ public AwsValidateInfrastructureByArnTestsAsync()
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
routingKey: routingKey,
- queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
+ queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- messagePumpType: MessagePumpType.Proactor,
+ messagePumpType: MessagePumpType.Proactor,
makeChannels: OnMissingChannel.Create);
_message = new Message(
@@ -51,9 +51,9 @@ public AwsValidateInfrastructureByArnTestsAsync()
var awsConnection = GatewayFactory.CreateFactory();
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
- var topicArn = FindTopicArn(awsConnection, routingKey.ToValidSNSTopicName(true)).Result;
+ var topicArn = await FindTopicArn(awsConnection, routingKey.ToValidSNSTopicName(true));
var routingKeyArn = new RoutingKey(topicArn);
subscription.MakeChannels = OnMissingChannel.Validate;
@@ -74,7 +74,7 @@ public AwsValidateInfrastructureByArnTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -84,7 +84,7 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
@@ -96,13 +96,14 @@ private static async Task FindTopicArn(AWSMessagingGatewayConnection con
return topicResponse.TopicArn;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
index 609634fcf1..0d220e6bfb 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendAsyncTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -72,7 +71,7 @@ public SqsMessageProducerSendAsyncTests()
});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer_async()
{
// arrange
@@ -87,34 +86,35 @@ public async Task When_posting_a_message_via_the_producer_async()
await _channel.AcknowledgeAsync(message);
// should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_topicName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_topicName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
// allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
// {"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
- Assert.Equal(_messageGroupId, message.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, message.Header.Bag);
- Assert.Equal(_deduplicationId, message.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(message.Header.PartitionKey).IsEqualTo(_messageGroupId);
+ await Assert.That(message.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(message.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(_deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_assume_throws_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
index 75b22b2f3d..6672bbf9af 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_assume_throws_async.cs
@@ -4,18 +4,18 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTestsAsync : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly IAmAMessageConsumerAsync _consumer;
+ private ChannelFactory _channelFactory;
+ private IAmAMessageConsumerAsync _consumer;
- public AwsAssumeQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -27,9 +27,9 @@ public AwsAssumeQueuesTestsAsync()
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
routingKey: routingKey,
- queueAttributes: new SqsAttributes( type:SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
+ queueAttributes: new SqsAttributes( type:SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- messagePumpType: MessagePumpType.Proactor,
+ messagePumpType: MessagePumpType.Proactor,
makeChannels: OnMissingChannel.Assume);
var awsConnection = GatewayFactory.CreateFactory();
@@ -42,16 +42,16 @@ public AwsAssumeQueuesTestsAsync()
MakeChannels = OnMissingChannel.Create, TopicAttributes = topicAttributes
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
//We need to create the topic at least, to check the queues
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_assume_throws_async()
{
//we will try to get the queue url, and fail because it does not exist
@@ -59,9 +59,10 @@ await Assert.ThrowsAsync(async () =>
await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(1000)));
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
index d74896366b..23a81d23fe 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_queues_missing_verify_throws_async.cs
@@ -4,19 +4,19 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateQueuesTestsAsync : IAsyncDisposable
{
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly SqsSubscription _subscription;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private SqsSubscription _subscription;
private ChannelFactory? _channelFactory;
- public AwsValidateQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -41,10 +41,10 @@ public AwsValidateQueuesTestsAsync()
{
MakeChannels = OnMissingChannel.Create, TopicAttributes = topicAttributes
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_verify_throws_async()
{
// We have no queues so we should throw
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
index 3899575aaa..51bbc9aedf 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_raw_message_delivery_disabled_async.cs
@@ -5,12 +5,11 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -48,7 +47,7 @@ public SqsRawMessageDeliveryTestsAsync()
});
}
- [Fact]
+ [Test]
public async Task When_raw_message_delivery_disabled_async()
{
// Arrange
@@ -76,24 +75,25 @@ public async Task When_raw_message_delivery_disabled_async()
await _channel.AcknowledgeAsync(messageReceived);
// Assert
- Assert.Equal(messageToSend.Id, messageReceived.Id);
- Assert.Equal(messageToSend.Header.Topic.ToValidSNSTopicName(true), messageReceived.Header.Topic);
- Assert.Equal(messageToSend.Header.MessageType, messageReceived.Header.MessageType);
- Assert.Equal(messageToSend.Header.CorrelationId, messageReceived.Header.CorrelationId);
- Assert.Equal(messageToSend.Header.ReplyTo, messageReceived.Header.ReplyTo);
- Assert.Equal(messageToSend.Header.ContentType, messageReceived.Header.ContentType);
- Assert.Contains(customHeaderItem.Key, messageReceived.Header.Bag);
- Assert.Equal(customHeaderItem.Value, messageReceived.Header.Bag[customHeaderItem.Key]);
- Assert.Equal(messageToSend.Body.Value, messageReceived.Body.Value);
- Assert.Equal(messageGroupId, messageReceived.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, messageReceived.Header.Bag);
- Assert.Equal(deduplicationId, messageReceived.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(messageReceived.Id).IsEqualTo(messageToSend.Id);
+ await Assert.That(messageReceived.Header.Topic).IsEqualTo(messageToSend.Header.Topic.ToValidSNSTopicName(true));
+ await Assert.That(messageReceived.Header.MessageType).IsEqualTo(messageToSend.Header.MessageType);
+ await Assert.That(messageReceived.Header.CorrelationId).IsEqualTo(messageToSend.Header.CorrelationId);
+ await Assert.That(messageReceived.Header.ReplyTo).IsEqualTo(messageToSend.Header.ReplyTo);
+ await Assert.That(messageReceived.Header.ContentType).IsEqualTo(messageToSend.Header.ContentType);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(customHeaderItem.Key);
+ await Assert.That(messageReceived.Header.Bag[customHeaderItem.Key]).IsEqualTo(customHeaderItem.Value);
+ await Assert.That(messageReceived.Body.Value).IsEqualTo(messageToSend.Body.Value);
+ await Assert.That(messageReceived.Header.PartitionKey).IsEqualTo(messageGroupId);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(messageReceived.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
index f87d92cd8c..79b0b60046 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageConsumerRejectTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageConsumerRejectTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -62,7 +61,7 @@ public SqsMessageConsumerRejectTestsAsync()
});
}
- [Fact]
+ [Test]
public async Task When_rejecting_a_message_should_delete_from_queue_async()
{
//Arrange
@@ -75,13 +74,14 @@ public async Task When_rejecting_a_message_should_delete_from_queue_async()
//Assert - message should be deleted, not requeued
message = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_a_message_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_a_message_async.cs
index c6b69a5536..217b64d61c 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_a_message_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_a_message_async.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTestsAsync : IAsyncDisposable
{
private readonly IAmAMessageProducerAsync _sender;
private Message _requeuedMessage;
@@ -63,7 +62,7 @@ public SqsMessageProducerRequeueTestsAsync()
_channel = _channelFactory.CreateAsyncChannel(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_a_message_async()
{
await _sender.SendAsync(_message);
@@ -74,13 +73,14 @@ public async Task When_requeueing_a_message_async()
await _channel.AcknowledgeAsync(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
index fe3055058b..0175c20533 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
@@ -10,22 +10,22 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTestsAsync : IAsyncDisposable
{
- private readonly SnsMessageProducer _sender;
- private readonly IAmAChannelAsync _channel;
- private readonly ChannelFactory _channelFactory;
- private readonly Message _message;
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly ChannelName _deadLetterChannel;
-
- public SqsMessageProducerDlqTestsAsync()
+ private SnsMessageProducer _sender;
+ private IAmAChannelAsync _channel;
+ private ChannelFactory _channelFactory;
+ private Message _message;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private ChannelName _deadLetterChannel;
+
+ [Before(Test)]
+ public async Task Setup()
{
MyCommand myCommand = new MyCommand { Value = "Test" };
const string replyTo = "http:\\queueUrl";
@@ -67,13 +67,13 @@ public SqsMessageProducerDlqTestsAsync()
TopicAttributes = topicAttributes
});
- _sender.ConfirmTopicExistsAsync(topicName).Wait();
+ await _sender.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(_awsConnection);
- _channel = _channelFactory.CreateAsyncChannel(subscription);
+ _channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_redrives_to_the_queue_async()
{
await _sender.SendAsync(_message);
@@ -89,7 +89,7 @@ public async Task When_requeueing_redrives_to_the_queue_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync();
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
private async Task GetDLQCountAsync()
@@ -112,10 +112,11 @@ private async Task GetDLQCountAsync()
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
index 462edc1afc..878da9010c 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_throwing_defer_action_respect_redrive_async.cs
@@ -12,13 +12,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTestsAsync : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -128,7 +127,7 @@ public async Task GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- [Fact(Skip = "Failing async tests caused by task scheduler issues")]
+ [Test, Skip("Failing async tests caused by task scheduler issues")]
public async Task When_throwing_defer_action_respect_redrive_async()
{
await _sender.SendAsync(_message);
@@ -144,13 +143,14 @@ public async Task When_throwing_defer_action_respect_redrive_async()
await Task.Delay(5000);
var dlqCount = await GetDLQCountAsync(_dlqChannelName + ".fifo");
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_topic_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
index 5689410af7..f9e8656908 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Proactor/When_topic_missing_verify_throws_async.cs
@@ -1,12 +1,11 @@
-using System;
+using System;
using System.Threading.Tasks;
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTestsAsync
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -22,7 +21,7 @@ public AwsValidateMissingTopicTestsAsync()
// Because we don't use channel factory to create the infrastructure - it won't exist
}
- [Fact]
+ [Test]
public async Task When_topic_missing_verify_throws_async()
{
// arrange
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
index dab990d887..c6787ba083 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_a_message_consumer_reads_multiple_messages.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly SqsMessageConsumer _consumer;
@@ -63,7 +62,7 @@ public SqsBufferedConsumerTests()
});
}
- [Fact]
+ [Test]
public async Task When_a_message_consumer_reads_multiple_messages()
{
var routingKey = new RoutingKey(_topicName);
@@ -110,11 +109,11 @@ public async Task When_a_message_consumer_reads_multiple_messages()
);
//send MESSAGE_COUNT messages
- _messageProducer.Send(messageOne);
- _messageProducer.Send(messageTwo);
- _messageProducer.Send(messageThree);
- _messageProducer.Send(messageFour);
- _messageProducer.Send(messageFive);
+ await _messageProducer.SendAsync(messageOne);
+ await _messageProducer.SendAsync(messageTwo);
+ await _messageProducer.SendAsync(messageThree);
+ await _messageProducer.SendAsync(messageFour);
+ await _messageProducer.SendAsync(messageFive);
int iteration = 0;
@@ -126,18 +125,18 @@ public async Task When_a_message_consumer_reads_multiple_messages()
var outstandingMessageCount = MessageCount - messagesReceivedCount;
//retrieve messages
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(10000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
{
messagesReceived.Add(message);
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
messagesReceivedCount = messagesReceived.Count;
@@ -146,15 +145,16 @@ public async Task When_a_message_consumer_reads_multiple_messages()
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_assume.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_assume.cs
index 501045ca21..c54ac9802b 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_assume.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_assume.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -81,27 +80,28 @@ public AwsAssumeInfrastructureTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName(true));
}
- [Fact]
- public void When_infastructure_exists_can_assume()
+ [Test]
+ public async Task When_infastructure_exists_can_assume()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(5000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify.cs
index d9687ad4d6..2b28904fe4 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -78,11 +77,11 @@ public AwsValidateInfrastructureTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -90,19 +89,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_arn.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_arn.cs
index 3890f9d9b7..1a133b264f 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_arn.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_arn.cs
@@ -7,22 +7,22 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("CI", "Fragile")]
-public class AwsValidateInfrastructureByArnTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("CI", "Fragile")]
+public class AwsValidateInfrastructureByArnTests : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerSync _consumer;
- private readonly SnsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByArnTests()
+ private Message _message;
+ private IAmAMessageConsumerSync _consumer;
+ private SnsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
const string replyTo = "http:\\queueUrl";
var contentType = new ContentType(MediaTypeNames.Text.Plain);
@@ -39,9 +39,9 @@ public AwsValidateInfrastructureByArnTests()
channelName: new ChannelName(channelName),
channelType: ChannelType.PubSub,
routingKey: routingKey,
- queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
+ queueAttributes: new SqsAttributes(type: SqsType.Fifo, tags: new Dictionary { { "Environment", "Test" } }),
topicAttributes: topicAttributes,
- messagePumpType: MessagePumpType.Reactor,
+ messagePumpType: MessagePumpType.Reactor,
makeChannels: OnMissingChannel.Create);
_message = new Message(
@@ -58,7 +58,7 @@ public AwsValidateInfrastructureByArnTests()
_channelFactory = new ChannelFactory(awsConnection);
var channel = _channelFactory.CreateSyncChannel(subscription);
- var topicArn = FindTopicArn(awsConnection, routingKey.ToValidSNSTopicName(true));
+ var topicArn = await FindTopicArn(awsConnection, routingKey.ToValidSNSTopicName(true));
var routingKeyArn = new RoutingKey(topicArn);
//Now change the subscription to validate, just check what we made
@@ -79,11 +79,11 @@ public AwsValidateInfrastructureByArnTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -91,19 +91,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
@@ -114,10 +115,10 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- private static string FindTopicArn(AWSMessagingGatewayConnection connection, string topicName)
+ private static async Task FindTopicArn(AWSMessagingGatewayConnection connection, string topicName)
{
using var snsClient = new AWSClientFactory(connection).CreateSnsClient();
- var topicResponse = snsClient.FindTopicAsync(topicName).GetAwaiter().GetResult();
+ var topicResponse = await snsClient.FindTopicAsync(topicName);
return topicResponse.TopicArn;
}
}
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_convention.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_convention.cs
index 97c7881e53..935786e141 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_convention.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infastructure_exists_can_verify_by_convention.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByConventionTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByConventionTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -78,11 +77,11 @@ public AwsValidateInfrastructureByConventionTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -90,19 +89,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infrastructure_exists_can_verify_by_convention.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infrastructure_exists_can_verify_by_convention.cs
index 8687631e40..d24841ccf5 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infrastructure_exists_can_verify_by_convention.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_infrastructure_exists_can_verify_by_convention.cs
@@ -7,13 +7,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByConventionTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByConventionTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -72,28 +71,29 @@ public AwsValidateInfrastructureByConventionTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
var messages = _consumer.Receive(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
(_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
index 9e5dba4e24..669f2a5ae2 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -76,12 +75,12 @@ public SqsMessageProducerSendTests()
});
}
- [Fact]
+ [Test]
public async Task When_posting_a_message_via_the_producer()
{
//arrange
_message.Header.Subject = "test subject";
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -91,34 +90,35 @@ public async Task When_posting_a_message_via_the_producer()
_channel.Acknowledge(message);
//should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_topicName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_topicName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
//allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
//{"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
- Assert.Equal(_messageGroupId, message.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, message.Header.Bag);
- Assert.Equal(_deduplicationId, message.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(message.Header.PartitionKey).IsEqualTo(_messageGroupId);
+ await Assert.That(message.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(message.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(_deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_assume_throws.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_assume_throws.cs
index bb9ad8bd9d..dacb2ae9dd 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_assume_throws.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_assume_throws.cs
@@ -4,18 +4,18 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTests : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly SqsMessageConsumer _consumer;
+ private ChannelFactory _channelFactory;
+ private SqsMessageConsumer _consumer;
- public AwsAssumeQueuesTests()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -45,7 +45,7 @@ public AwsAssumeQueuesTests()
MakeChannels = OnMissingChannel.Create, TopicAttributes = topicAttributes
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(awsConnection);
var channel = _channelFactory.CreateSyncChannel(subscription);
@@ -54,16 +54,17 @@ public AwsAssumeQueuesTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
- public void When_queues_missing_assume_throws()
+ [Test]
+ public async Task When_queues_missing_assume_throws()
{
//we will try to get the queue url, and fail because it does not exist
- Assert.Throws(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000)));
+ await Assert.That(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000))).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_verify_throws.cs
index 97f6561b0a..2885ece17f 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_queues_missing_verify_throws.cs
@@ -4,19 +4,19 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateQueuesTests : IAsyncDisposable
{
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly SqsSubscription _subscription;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private SqsSubscription _subscription;
private ChannelFactory? _channelFactory;
- public AwsValidateQueuesTests()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -41,22 +41,23 @@ public AwsValidateQueuesTests()
{
MakeChannels = OnMissingChannel.Create, TopicAttributes = topicAttributes
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
}
- [Fact]
- public void When_queues_missing_verify_throws()
+ [Test]
+ public async Task When_queues_missing_verify_throws()
{
//We have no queues so we should throw
//We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
- Assert.Throws(() => _channelFactory.CreateSyncChannel(_subscription));
+ await Assert.That(() => _channelFactory.CreateSyncChannel(_subscription)).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
if (_channelFactory != null)
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_raw_message_delivery_disabled.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_raw_message_delivery_disabled.cs
index 34f0156b24..1f8e0fb4e2 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_raw_message_delivery_disabled.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_raw_message_delivery_disabled.cs
@@ -5,12 +5,11 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class SqsRawMessageDeliveryTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsRawMessageDeliveryTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -51,8 +50,8 @@ public SqsRawMessageDeliveryTests()
});
}
- [Fact]
- public void When_raw_message_delivery_disabled()
+ [Test]
+ public async Task When_raw_message_delivery_disabled()
{
//arrange
var messageGroupId = $"MessageGroupId{Guid.NewGuid():N}";
@@ -72,32 +71,33 @@ public void When_raw_message_delivery_disabled()
var messageToSent = new Message(messageHeader, new MessageBody("test content one"));
//act
- _messageProducer.Send(messageToSent);
+ await _messageProducer.SendAsync(messageToSent);
var messageReceived = _channel.Receive(TimeSpan.FromMilliseconds(10000));
_channel.Acknowledge(messageReceived);
//assert
- Assert.Equal(messageToSent.Id, messageReceived.Id);
- Assert.Equal(messageToSent.Header.Topic.ToValidSNSTopicName(true), messageReceived.Header.Topic);
- Assert.Equal(messageToSent.Header.MessageType, messageReceived.Header.MessageType);
- Assert.Equal(messageToSent.Header.CorrelationId, messageReceived.Header.CorrelationId);
- Assert.Equal(messageToSent.Header.ReplyTo, messageReceived.Header.ReplyTo);
- Assert.Equal(messageToSent.Header.ContentType, messageReceived.Header.ContentType);
- Assert.Contains(customHeaderItem.Key, messageReceived.Header.Bag);
- Assert.Equal(customHeaderItem.Value, messageReceived.Header.Bag[customHeaderItem.Key]);
- Assert.Equal(messageToSent.Body.Value, messageReceived.Body.Value);
-
- Assert.Equal(messageGroupId, messageReceived.Header.PartitionKey);
- Assert.Contains(HeaderNames.DeduplicationId, messageReceived.Header.Bag);
- Assert.Equal(deduplicationId, messageReceived.Header.Bag[HeaderNames.DeduplicationId]);
+ await Assert.That(messageReceived.Id).IsEqualTo(messageToSent.Id);
+ await Assert.That(messageReceived.Header.Topic).IsEqualTo(messageToSent.Header.Topic.ToValidSNSTopicName(true));
+ await Assert.That(messageReceived.Header.MessageType).IsEqualTo(messageToSent.Header.MessageType);
+ await Assert.That(messageReceived.Header.CorrelationId).IsEqualTo(messageToSent.Header.CorrelationId);
+ await Assert.That(messageReceived.Header.ReplyTo).IsEqualTo(messageToSent.Header.ReplyTo);
+ await Assert.That(messageReceived.Header.ContentType).IsEqualTo(messageToSent.Header.ContentType);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(customHeaderItem.Key);
+ await Assert.That(messageReceived.Header.Bag[customHeaderItem.Key]).IsEqualTo(customHeaderItem.Value);
+ await Assert.That(messageReceived.Body.Value).IsEqualTo(messageToSent.Body.Value);
+
+ await Assert.That(messageReceived.Header.PartitionKey).IsEqualTo(messageGroupId);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(HeaderNames.DeduplicationId);
+ await Assert.That(messageReceived.Header.Bag[HeaderNames.DeduplicationId]).IsEqualTo(deduplicationId);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
index 97289301e2..e3f056cc03 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_rejecting_a_message_should_delete_from_queue.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTests : IDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTests
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -64,11 +63,11 @@ public SqsMessageConsumerRejectTests()
});
}
- [Fact]
- public void When_rejecting_a_message_should_delete_from_queue()
+ [Test]
+ public async Task When_rejecting_a_message_should_delete_from_queue()
{
//Arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
var message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
//Act
@@ -77,13 +76,14 @@ public void When_rejecting_a_message_should_delete_from_queue()
//Assert - message should be deleted, not requeued
message = _channel.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_a_message.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_a_message.cs
index 1f0a6d8759..ad32deaaae 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_a_message.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_a_message.cs
@@ -6,13 +6,12 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTests : IAsyncDisposable
{
private readonly IAmAMessageProducerSync _sender;
private Message? _requeuedMessage;
@@ -62,8 +61,8 @@ public SqsMessageProducerRequeueTests()
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_a_message()
+ [Test]
+ public async Task When_requeueing_a_message()
{
_sender.Send(_message);
_receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
@@ -74,13 +73,14 @@ public void When_requeueing_a_message()
//clear the queue
_channel.Acknowledge(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
index fdf5f77873..f015351b87 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_requeueing_redrives_to_the_dlq.cs
@@ -9,23 +9,23 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTests : IAsyncDisposable
{
- private readonly SnsMessageProducer _sender;
- private readonly IAmAChannelSync _channel;
- private readonly ChannelFactory _channelFactory;
- private readonly Message _message;
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly string _dlqChannelName;
-
- public SqsMessageProducerDlqTests()
+ private SnsMessageProducer _sender;
+ private IAmAChannelSync _channel;
+ private ChannelFactory _channelFactory;
+ private Message _message;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private string _dlqChannelName;
+
+ [Before(Test)]
+ public async Task Setup()
{
MyCommand myCommand = new MyCommand { Value = "Test" };
const string replyTo = "http:\\queueUrl";
@@ -70,17 +70,17 @@ public SqsMessageProducerDlqTests()
TopicAttributes = topicAttributes
});
- _sender.ConfirmTopicExistsAsync(topicName).Wait();
+ await _sender.ConfirmTopicExistsAsync(topicName);
//We need to do this manually in a test - will create the channel from subscriber parameters
_channelFactory = new ChannelFactory(_awsConnection);
_channel = _channelFactory.CreateSyncChannel(subscription);
}
- [Fact]
- public void When_requeueing_redrives_to_the_queue()
+ [Test]
+ public async Task When_requeueing_redrives_to_the_queue()
{
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
var receivedMessage = _channel.Receive(TimeSpan.FromMilliseconds(5000));
_channel.Requeue(receivedMessage);
@@ -94,19 +94,19 @@ public void When_requeueing_redrives_to_the_queue()
Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName + ".fifo"));
+ await Assert.That(await GetDLQCount(_dlqChannelName + ".fifo")).IsEqualTo(1);
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageAttributeNames = ["All", "ApproximateReceiveCount"]
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -117,10 +117,11 @@ private int GetDLQCount(string queueName)
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
index abd438e537..7c98e29285 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_throwing_defer_action_respect_redrive.cs
@@ -11,14 +11,13 @@
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
using System.Collections.Generic;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTests : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -118,17 +117,17 @@ public SnsReDrivePolicySDlqTests()
};
}
- private int GetDLQCount(string queueName)
+ private async Task GetDLQCount(string queueName)
{
using var sqsClient = new AWSClientFactory(_awsConnection).CreateSqsClient();
- var queueUrlResponse = sqsClient.GetQueueUrlAsync(queueName).GetAwaiter().GetResult();
- var response = sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
+ var queueUrlResponse = await sqsClient.GetQueueUrlAsync(queueName);
+ var response = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = queueUrlResponse.QueueUrl,
WaitTimeSeconds = 5,
MessageSystemAttributeNames = ["ApproximateReceiveCount"],
MessageAttributeNames = ["All"]
- }).GetAwaiter().GetResult();
+ });
if (response.HttpStatusCode != HttpStatusCode.OK)
{
@@ -140,17 +139,17 @@ private int GetDLQCount(string queueName)
}
- [Fact]
+ [Test]
public async Task When_throwing_defer_action_respect_redrive()
{
//put something on an SNS topic, which will be delivered to our SQS queue
- _sender.Send(_message);
+ await _sender.SendAsync(_message);
//start a message pump, let it process messages
var task = Task.Factory.StartNew(() => _messagePump.Run(), TaskCreationOptions.LongRunning);
await Task.Delay(5000);
- //send a quit message to the pump to terminate it
+ //send a quit message to the pump to terminate it
var quitMessage = MessageFactory.CreateQuitMessage(_subscription.RoutingKey);
_channel.Enqueue(quitMessage);
@@ -160,13 +159,14 @@ public async Task When_throwing_defer_action_respect_redrive()
await Task.Delay(5000);
//inspect the dlq
- Assert.Equal(1, GetDLQCount(_dlqChannelName + ".fifo"));
+ await Assert.That(await GetDLQCount(_dlqChannelName + ".fifo")).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_topic_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_topic_missing_verify_throws.cs
index dc98c208c4..6d9bf9fb36 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_topic_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Fifo/Reactor/When_topic_missing_verify_throws.cs
@@ -1,11 +1,10 @@
-using System;
+using System;
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Fifo.Reactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTests
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -21,8 +20,8 @@ public AwsValidateMissingTopicTests()
//Because we don't use channel factory to create the infrastructure -it won't exist
}
- [Fact]
- public void When_topic_missing_verify_throws()
+ [Test]
+ public async Task When_topic_missing_verify_throws()
{
//arrange
var producer = new SnsMessageProducer(_awsConnection,
@@ -35,9 +34,12 @@ public void When_topic_missing_verify_throws()
var messageGroupId = $"MessageGroup{Guid.NewGuid():N}";
//act && assert
- Assert.Throws(() => producer.Send(new Message(
- new MessageHeader("", _routingKey, MessageType.MT_EVENT,
- type: new CloudEventsType("plain/text"), partitionKey: messageGroupId),
- new MessageBody("Test"))));
+ Assert.ThrowsExactly(() =>
+ {
+ producer.Send(new Message(
+ new MessageHeader("", _routingKey, MessageType.MT_EVENT,
+ type: new CloudEventsType("plain/text"), partitionKey: messageGroupId),
+ new MessageBody("Test")));
+ });
}
}
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
index eb7874b0d0..eb5a8e236e 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_a_message_consumer_reads_multiple_messages_async.cs
@@ -6,24 +6,24 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTestsAsync : IAsyncDisposable
{
- private readonly SnsMessageProducer _messageProducer;
- private readonly SqsMessageConsumer _consumer;
- private readonly string _topicName;
- private readonly ChannelFactory _channelFactory;
+ private SnsMessageProducer _messageProducer;
+ private SqsMessageConsumer _consumer;
+ private string _topicName;
+ private ChannelFactory _channelFactory;
private readonly ContentType _contentType = new(MediaTypeNames.Text.Plain);
private const int BufferSize = 3;
private const int MessageCount = 4;
- public SqsBufferedConsumerTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var awsConnection = GatewayFactory.CreateFactory();
@@ -34,7 +34,7 @@ public SqsBufferedConsumerTestsAsync()
//we need the channel to create the queues and notifications
var routingKey = new RoutingKey(_topicName);
- var channel = _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
+ var channel = await _channelFactory.CreateAsyncChannelAsync(new SqsSubscription(
subscriptionName: new SubscriptionName(channelName),
channelName: new ChannelName(channelName),
routingKey: routingKey,
@@ -42,7 +42,7 @@ public SqsBufferedConsumerTestsAsync()
messagePumpType: MessagePumpType.Proactor,
makeChannels: OnMissingChannel.Create,
queueAttributes: new SqsAttributes(tags: new Dictionary { { "Environment", "Test" } }),
- topicAttributes: new SnsAttributes(tags: [new Tag { Key = "Environment", Value = "Test" }]))).GetAwaiter().GetResult();
+ topicAttributes: new SnsAttributes(tags: [new Tag { Key = "Environment", Value = "Test" }])));
//we want to access via a consumer, to receive multiple messages - we don't want to expose on channel
//just for the tests, so create a new consumer from the properties
@@ -51,9 +51,9 @@ public SqsBufferedConsumerTestsAsync()
new SnsPublication { MakeChannels = OnMissingChannel.Create });
}
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
+ [Test]
+ [Arguments(true)]
+ [Arguments(false)]
public async Task When_a_message_consumer_reads_multiple_messages_async(bool fairQueue)
{
var partitionOne = fairQueue ? new PartitionKey(Uuid.NewAsString()) : PartitionKey.Empty;
@@ -101,10 +101,10 @@ public async Task When_a_message_consumer_reads_multiple_messages_async(bool fai
//retrieve messages
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
@@ -119,7 +119,7 @@ public async Task When_a_message_consumer_reads_multiple_messages_async(bool fai
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
public async ValueTask DisposeAsync()
@@ -129,10 +129,11 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().GetAwaiter().GetResult();
- _channelFactory.DeleteQueueAsync().GetAwaiter().GetResult();
- _messageProducer.DisposeAsync().GetAwaiter().GetResult();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
}
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_customising_aws_client_config_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_customising_aws_client_config_async.cs
index 8063220d2c..0335e38f64 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_customising_aws_client_config_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_customising_aws_client_config_async.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class CustomisingAwsClientConfigTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class CustomisingAwsClientConfigTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -67,7 +66,7 @@ public CustomisingAwsClientConfigTestsAsync()
);
}
- [Fact]
+ [Test]
public async Task When_customising_aws_client_config()
{
//arrange
@@ -78,22 +77,23 @@ public async Task When_customising_aws_client_config()
var message = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
//clear the queue
- Assert.NotEqual(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
await _channel.AcknowledgeAsync(message);
//publish_and_subscribe_should_use_custom_http_client_factory
- Assert.Contains("async_pub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["async_pub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("async_pub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["async_pub"]) > (0)).IsTrue();
- Assert.Contains("async_pub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["async_pub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("async_pub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["async_pub"]) > (0)).IsTrue();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infastructure_exists_can_assume_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infastructure_exists_can_assume_async.cs
index 1eef276308..8f3003ea6b 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infastructure_exists_can_assume_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infastructure_exists_can_assume_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeInfrastructureTestsAsync : IAsyncDisposable
{ private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
private readonly SnsMessageProducer _messageProducer;
@@ -68,7 +67,7 @@ public AwsAssumeInfrastructureTestsAsync()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
+ [Test]
public async Task When_infastructure_exists_can_assume()
{
//arrange
@@ -78,17 +77,18 @@ public async Task When_infastructure_exists_can_assume()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
index 54c1b2ab2e..fb0579a5d2 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor
{
- [Trait("Category", "AWS")]
- public class AwsValidateInfrastructureTestsAsync : IDisposable, IAsyncDisposable
+ [Category("AWS")]
+ public class AwsValidateInfrastructureTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -69,7 +68,7 @@ public AwsValidateInfrastructureTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -79,18 +78,19 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
index 3bca81d33d..8ce295488d 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_arn_async.cs
@@ -9,22 +9,22 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByArnTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByArnTestsAsync : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerAsync _consumer;
- private readonly SnsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByArnTestsAsync()
+ private Message _message;
+ private IAmAMessageConsumerAsync _consumer;
+ private SnsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
string correlationId = Id.Random();
@@ -53,9 +53,9 @@ public AwsValidateInfrastructureByArnTestsAsync()
var awsConnection = GatewayFactory.CreateFactory(credentials, region);
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
- var topicArn = FindTopicArn(awsConnection, routingKey.Value).Result;
+ var topicArn = await FindTopicArn(awsConnection, routingKey.Value);
var routingKeyArn = new RoutingKey(topicArn);
subscription.MakeChannels = OnMissingChannel.Validate;
@@ -75,7 +75,7 @@ public AwsValidateInfrastructureByArnTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -85,7 +85,7 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
@@ -97,13 +97,14 @@ private static async Task FindTopicArn(AWSMessagingGatewayConnection con
return topicResponse.TopicArn;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_convention_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_convention_async.cs
index 0a53861b7b..7b64e9c47b 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_convention_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_infrastructure_exists_can_verify_by_convention_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByConventionTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByConventionTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerAsync _consumer;
@@ -69,7 +68,7 @@ public AwsValidateInfrastructureByConventionTestsAsync()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify_async()
{
await _messageProducer.SendAsync(_message);
@@ -79,18 +78,19 @@ public async Task When_infrastructure_exists_can_verify_async()
var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
index 8afe1f5546..f179c6445a 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_posting_a_message_via_the_messaging_gateway_async.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendAsyncTests : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendAsyncTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -64,9 +63,9 @@ public SqsMessageProducerSendAsyncTests()
});
}
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
+ [Test]
+ [Arguments(true)]
+ [Arguments(false)]
public async Task When_posting_a_message_via_the_producer_async(bool fairQueue)
{
// arrange
@@ -82,30 +81,31 @@ public async Task When_posting_a_message_via_the_producer_async(bool fairQueue)
await _channel.AcknowledgeAsync(message);
// should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
-
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_topicName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
+
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_topicName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
// allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
// {"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_assume_throws_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_assume_throws_async.cs
index e77f7b46f2..7af74aaa6c 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_assume_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_assume_throws_async.cs
@@ -4,19 +4,19 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTestsAsync : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly IAmAMessageConsumerAsync _consumer;
+ private ChannelFactory _channelFactory;
+ private IAmAMessageConsumerAsync _consumer;
- public AwsAssumeQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -42,16 +42,16 @@ public AwsAssumeQueuesTestsAsync()
MakeChannels = OnMissingChannel.Create
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
//We need to create the topic at least, to check the queues
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_assume_throws_async()
{
//we will try to get the queue url, and fail because it does not exist
@@ -59,9 +59,10 @@ await Assert.ThrowsAsync(async () =>
await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(1000)));
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_verify_throws_async.cs
index 8392b094f9..052ddedbcf 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_queues_missing_verify_throws_async.cs
@@ -4,20 +4,20 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateQueuesTestsAsync : IAsyncDisposable
{
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly SqsSubscription _subscription;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private SqsSubscription _subscription;
private ChannelFactory? _channelFactory;
- public AwsValidateQueuesTestsAsync()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -41,10 +41,10 @@ public AwsValidateQueuesTestsAsync()
{
MakeChannels = OnMissingChannel.Create
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
}
- [Fact]
+ [Test]
public async Task When_queues_missing_verify_throws_async()
{
// We have no queues so we should throw
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_raw_message_delivery_disabled_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_raw_message_delivery_disabled_async.cs
index ce9dd23838..e67480b69d 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_raw_message_delivery_disabled_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_raw_message_delivery_disabled_async.cs
@@ -5,13 +5,12 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable, IDisposable
+[Category("AWS")]
+public class SqsRawMessageDeliveryTestsAsync : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly ChannelFactory _channelFactory;
@@ -49,7 +48,7 @@ public SqsRawMessageDeliveryTestsAsync()
});
}
- [Fact]
+ [Test]
public async Task When_raw_message_delivery_disabled_async()
{
// Arrange
@@ -74,21 +73,22 @@ public async Task When_raw_message_delivery_disabled_async()
await _channel.AcknowledgeAsync(messageReceived);
// Assert
- Assert.Equal(messageToSend.Id, messageReceived.Id);
- Assert.Equal(messageToSend.Header.Topic, messageReceived.Header.Topic);
- Assert.Equal(messageToSend.Header.MessageType, messageReceived.Header.MessageType);
- Assert.Equal(messageToSend.Header.CorrelationId, messageReceived.Header.CorrelationId);
- Assert.Equal(messageToSend.Header.ReplyTo, messageReceived.Header.ReplyTo);
- Assert.Equal(messageToSend.Header.ContentType, messageReceived.Header.ContentType);
- Assert.Contains(customHeaderItem.Key, messageReceived.Header.Bag);
- Assert.Equal(customHeaderItem.Value, messageReceived.Header.Bag[customHeaderItem.Key]);
- Assert.Equal(messageToSend.Body.Value, messageReceived.Body.Value);
+ await Assert.That(messageReceived.Id).IsEqualTo(messageToSend.Id);
+ await Assert.That(messageReceived.Header.Topic).IsEqualTo(messageToSend.Header.Topic);
+ await Assert.That(messageReceived.Header.MessageType).IsEqualTo(messageToSend.Header.MessageType);
+ await Assert.That(messageReceived.Header.CorrelationId).IsEqualTo(messageToSend.Header.CorrelationId);
+ await Assert.That(messageReceived.Header.ReplyTo).IsEqualTo(messageToSend.Header.ReplyTo);
+ await Assert.That(messageReceived.Header.ContentType).IsEqualTo(messageToSend.Header.ContentType);
+ await Assert.That(messageReceived.Header.Bag).ContainsKey(customHeaderItem.Key);
+ await Assert.That(messageReceived.Header.Bag[customHeaderItem.Key]).IsEqualTo(customHeaderItem.Value);
+ await Assert.That(messageReceived.Body.Value).IsEqualTo(messageToSend.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
index d44c76ad1e..9ca973844d 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_rejecting_a_message_should_delete_from_queue_async.cs
@@ -6,15 +6,14 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageConsumerRejectTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageConsumerRejectTestsAsync : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelAsync _channel;
@@ -56,7 +55,7 @@ public SqsMessageConsumerRejectTestsAsync()
_messageProducer = new SnsMessageProducer(awsConnection, new SnsPublication { MakeChannels = OnMissingChannel.Create });
}
- [Fact]
+ [Test]
public async Task When_rejecting_a_message_should_delete_from_queue_async()
{
//Arrange
@@ -69,13 +68,14 @@ public async Task When_rejecting_a_message_should_delete_from_queue_async()
//Assert - message should be deleted, not requeued
message = await _channel.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
- Assert.Equal(MessageType.MT_NONE, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_NONE);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_a_message_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_a_message_async.cs
index cd725633d1..50ba450df7 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_a_message_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_a_message_async.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerRequeueTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerRequeueTestsAsync : IAsyncDisposable
{
private readonly IAmAMessageProducerAsync _sender;
private Message? _requeuedMessage;
@@ -59,7 +58,7 @@ public SqsMessageProducerRequeueTestsAsync()
_channel = _channelFactory.CreateAsyncChannel(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_a_message_async()
{
await _sender.SendAsync(_message);
@@ -70,13 +69,14 @@ public async Task When_requeueing_a_message_async()
await _channel.AcknowledgeAsync(_requeuedMessage);
- Assert.Equal(_receivedMessage.Body.Value, _requeuedMessage.Body.Value);
+ await Assert.That(_requeuedMessage.Body.Value).IsEqualTo(_receivedMessage.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
index 6c812d0829..9a5d12e76b 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_requeueing_redrives_to_the_dlq_async.cs
@@ -10,23 +10,23 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsMessageProducerDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsMessageProducerDlqTestsAsync : IAsyncDisposable
{
- private readonly SnsMessageProducer _sender;
- private readonly IAmAChannelAsync _channel;
- private readonly ChannelFactory _channelFactory;
- private readonly Message _message;
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly ChannelName _deadLetterChannel;
-
- public SqsMessageProducerDlqTestsAsync()
+ private SnsMessageProducer _sender;
+ private IAmAChannelAsync _channel;
+ private ChannelFactory _channelFactory;
+ private Message _message;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private ChannelName _deadLetterChannel;
+
+ [Before(Test)]
+ public async Task Setup()
{
MyCommand myCommand = new MyCommand { Value = "Test" };
string correlationId = Guid.NewGuid().ToString();
@@ -61,13 +61,13 @@ public SqsMessageProducerDlqTestsAsync()
_sender = new SnsMessageProducer(_awsConnection, new SnsPublication { Topic = routingKey, MakeChannels = OnMissingChannel.Create });
- _sender.ConfirmTopicExistsAsync(topicName).Wait();
+ await _sender.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(_awsConnection);
- _channel = _channelFactory.CreateAsyncChannel(subscription);
+ _channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_requeueing_redrives_to_the_queue_async()
{
await _sender.SendAsync(_message);
@@ -83,7 +83,7 @@ public async Task When_requeueing_redrives_to_the_queue_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync();
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
private async Task GetDLQCountAsync()
@@ -106,10 +106,11 @@ private async Task GetDLQCountAsync()
return response.Messages.Count;
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
index 99d10d0a15..cfec9ca08a 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_throwing_defer_action_respect_redrive_async.cs
@@ -13,13 +13,12 @@
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
using Paramore.Brighter.ServiceActivator;
using Polly.Registry;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SnsReDrivePolicySDlqTestsAsync : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SnsReDrivePolicySDlqTestsAsync : IAsyncDisposable
{
private readonly IAmAMessagePump _messagePump;
private readonly Message _message;
@@ -126,7 +125,7 @@ public async Task GetDLQCountAsync(string queueName)
return response.Messages.Count;
}
- [Fact(Skip = "Failing async tests caused by task scheduler issues")]
+ [Test, Skip("Failing async tests caused by task scheduler issues")]
public async Task When_throwing_defer_action_respect_redrive_async()
{
await _sender.SendAsync(_message);
@@ -142,13 +141,14 @@ public async Task When_throwing_defer_action_respect_redrive_async()
await Task.Delay(5000);
int dlqCount = await GetDLQCountAsync(_dlqChannelName);
- Assert.Equal(1, dlqCount);
+ await Assert.That(dlqCount).IsEqualTo(1);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_topic_missing_verify_throws_async.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_topic_missing_verify_throws_async.cs
index 468fb32603..2828bbea93 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_topic_missing_verify_throws_async.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Proactor/When_topic_missing_verify_throws_async.cs
@@ -1,12 +1,11 @@
-using System;
+using System;
using System.Threading.Tasks;
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Proactor;
-[Trait("Category", "AWS")]
+[Category("AWS")]
public class AwsValidateMissingTopicTestsAsync
{
private readonly AWSMessagingGatewayConnection _awsConnection;
@@ -22,7 +21,7 @@ public AwsValidateMissingTopicTestsAsync()
// Because we don't use channel factory to create the infrastructure - it won't exist
}
- [Fact]
+ [Test]
public async Task When_topic_missing_verify_throws_async()
{
// arrange
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
index d30f9bc6bb..f39b33e971 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_a_message_consumer_reads_multiple_messages.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-[Trait("Fragile", "CI")]
-public class SqsBufferedConsumerTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+[Property("Fragile", "CI")]
+public class SqsBufferedConsumerTests : IAsyncDisposable
{
private readonly SnsMessageProducer _messageProducer;
private readonly SqsMessageConsumer _consumer;
@@ -55,9 +54,9 @@ public SqsBufferedConsumerTests()
});
}
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
+ [Test]
+ [Arguments(true)]
+ [Arguments(false)]
public async Task When_a_message_consumer_reads_multiple_messages(bool fairQueue)
{
var partitionOne = fairQueue ? new PartitionKey(Uuid.NewAsString()) : PartitionKey.Empty;
@@ -90,10 +89,10 @@ public async Task When_a_message_consumer_reads_multiple_messages(bool fairQueue
);
//send MESSAGE_COUNT messages
- _messageProducer.Send(messageOne);
- _messageProducer.Send(messageTwo);
- _messageProducer.Send(messageThree);
- _messageProducer.Send(messageFour);
+ await _messageProducer.SendAsync(messageOne);
+ await _messageProducer.SendAsync(messageTwo);
+ await _messageProducer.SendAsync(messageThree);
+ await _messageProducer.SendAsync(messageFour);
int iteration = 0;
@@ -105,18 +104,18 @@ public async Task When_a_message_consumer_reads_multiple_messages(bool fairQueue
var outstandingMessageCount = MessageCount - messagesReceivedCount;
//retrieve messages
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(10000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(10000));
- Assert.True(messages.Length <= outstandingMessageCount);
+ await Assert.That(messages.Length <= outstandingMessageCount).IsTrue();
//should not receive more than buffer in one hit
- Assert.True(messages.Length <= BufferSize);
+ await Assert.That(messages.Length <= BufferSize).IsTrue();
var moreMessages = messages.Where(m => m.Header.MessageType == MessageType.MT_COMMAND);
foreach (var message in moreMessages)
{
messagesReceived.Add(message);
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
messagesReceivedCount = messagesReceived.Count;
@@ -126,16 +125,17 @@ public async Task When_a_message_consumer_reads_multiple_messages(bool fairQueue
} while ((iteration <= 5) && (messagesReceivedCount < MessageCount));
- Assert.Equal(4, messagesReceivedCount);
+ await Assert.That(messagesReceivedCount).IsEqualTo(4);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_customising_aws_client_config.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_customising_aws_client_config.cs
index ea2a7116a2..92649e8cd1 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_customising_aws_client_config.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_customising_aws_client_config.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class CustomisingAwsClientConfigTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class CustomisingAwsClientConfigTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -63,11 +62,11 @@ public CustomisingAwsClientConfigTests()
MakeChannels = OnMissingChannel.Create });
}
- [Fact]
+ [Test]
public async Task When_customising_aws_client_config()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -77,18 +76,19 @@ public async Task When_customising_aws_client_config()
_channel.Acknowledge(message);
//publish_and_subscribe_should_use_custom_http_client_factory
- Assert.Contains("sync_sub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["sync_sub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("sync_sub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["sync_sub"]) > (0)).IsTrue();
- Assert.Contains("sync_pub", InterceptingDelegatingHandler.RequestCount);
- Assert.True((InterceptingDelegatingHandler.RequestCount["sync_pub"]) > (0));
+ await Assert.That(InterceptingDelegatingHandler.RequestCount).ContainsKey("sync_pub");
+ await Assert.That((InterceptingDelegatingHandler.RequestCount["sync_pub"]) > (0)).IsTrue();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_assume.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_assume.cs
index a2c44ac4e7..3064584ceb 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_assume.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_assume.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly SqsMessageConsumer _consumer;
@@ -65,27 +64,28 @@ public AwsAssumeInfrastructureTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
- public void When_infastructure_exists_can_assume()
+ [Test]
+ public async Task When_infastructure_exists_can_assume()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
- var messages = _consumer.Receive(TimeSpan.FromMilliseconds(5000));
+ var messages = await _consumer.ReceiveAsync(TimeSpan.FromMilliseconds(5000));
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
- _consumer.Acknowledge(message);
+ await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify.cs
index 3d78c8c794..73764c28b0 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -71,11 +70,11 @@ public AwsValidateInfrastructureTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -83,19 +82,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_arn.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_arn.cs
index e5246ed530..5c6653bedd 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_arn.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_arn.cs
@@ -9,22 +9,22 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByArnTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByArnTests : IAsyncDisposable
{
- private readonly Message _message;
- private readonly IAmAMessageConsumerAsync _consumer;
- private readonly SnsMessageProducer _messageProducer;
- private readonly ChannelFactory _channelFactory;
- private readonly MyCommand _myCommand;
-
- public AwsValidateInfrastructureByArnTests()
+ private Message _message;
+ private IAmAMessageConsumerAsync _consumer;
+ private SnsMessageProducer _messageProducer;
+ private ChannelFactory _channelFactory;
+ private MyCommand _myCommand;
+
+ [Before(Test)]
+ public async Task Setup()
{
_myCommand = new MyCommand { Value = "Test" };
string correlationId = Guid.NewGuid().ToString();
@@ -56,9 +56,9 @@ public AwsValidateInfrastructureByArnTests()
//This doesn't look that different from our create tests - this is because we create using the channel factory in
//our AWS transport, not the consumer (as it's a more likely to use infrastructure declared elsewhere)
_channelFactory = new ChannelFactory(awsConnection);
- var channel = _channelFactory.CreateAsyncChannel(subscription);
+ var channel = await _channelFactory.CreateAsyncChannelAsync(subscription);
- var topicArn = FindTopicArn(awsConnection, routingKey.Value);
+ var topicArn = await FindTopicArn(awsConnection, routingKey.Value);
var routingKeyArn = new RoutingKey(topicArn);
//Now change the subscription to validate, just check what we made
@@ -79,7 +79,7 @@ public AwsValidateInfrastructureByArnTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).CreateAsync(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
@@ -91,20 +91,21 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.NotEqual(MessageType.MT_NONE, message.Header.MessageType);
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Header.MessageType).IsNotEqualTo(MessageType.MT_NONE);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
await _consumer.AcknowledgeAsync(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
((IAmAMessageConsumerSync)_consumer).Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
@@ -115,10 +116,10 @@ public async ValueTask DisposeAsync()
await _messageProducer.DisposeAsync();
}
- private static string FindTopicArn(AWSMessagingGatewayConnection connection, string topicName)
+ private static async Task FindTopicArn(AWSMessagingGatewayConnection connection, string topicName)
{
using var snsClient = new AWSClientFactory(connection).CreateSnsClient();
- var topicResponse = snsClient.FindTopicAsync(topicName).GetAwaiter().GetResult();
+ var topicResponse = await snsClient.FindTopicAsync(topicName);
return topicResponse.TopicArn;
}
}
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_convention.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_convention.cs
index ab5e3cc3b8..a5bec4c961 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_convention.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_infastructure_exists_can_verify_by_convention.cs
@@ -7,14 +7,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateInfrastructureByConventionTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateInfrastructureByConventionTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAMessageConsumerSync _consumer;
@@ -69,11 +68,11 @@ public AwsValidateInfrastructureByConventionTests()
_consumer = new SqsMessageConsumerFactory(awsConnection).Create(subscription);
}
- [Fact]
+ [Test]
public async Task When_infrastructure_exists_can_verify()
{
//arrange
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -81,19 +80,20 @@ public async Task When_infrastructure_exists_can_verify()
//Assert
var message = messages.First();
- Assert.Equal(_myCommand.Id, message.Id);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
//clear the queue
_consumer.Acknowledge(message);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
_consumer.Dispose();
- _messageProducer.Dispose();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
index 7907c03f3a..29045b3c4c 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_posting_a_message_via_the_messaging_gateway.cs
@@ -6,14 +6,13 @@
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.JsonConverters;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class SqsMessageProducerSendTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class SqsMessageProducerSendTests : IAsyncDisposable
{
private readonly Message _message;
private readonly IAmAChannelSync _channel;
@@ -62,15 +61,15 @@ public SqsMessageProducerSendTests()
new SnsPublication{Topic = new RoutingKey(_topicName), MakeChannels = OnMissingChannel.Create});
}
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
+ [Test]
+ [Arguments(true)]
+ [Arguments(false)]
public async Task When_posting_a_message_via_the_producer(bool fairQueue)
{
//arrange
_message.Header.Subject = "test subject";
_message.Header.PartitionKey = fairQueue ? new PartitionKey(Uuid.NewAsString()) : PartitionKey.Empty;
- _messageProducer.Send(_message);
+ await _messageProducer.SendAsync(_message);
await Task.Delay(1000);
@@ -80,30 +79,31 @@ public async Task When_posting_a_message_via_the_producer(bool fairQueue)
_channel.Acknowledge(message);
//should_send_the_message_to_aws_sqs
- Assert.Equal(MessageType.MT_COMMAND, message.Header.MessageType);
+ await Assert.That(message.Header.MessageType).IsEqualTo(MessageType.MT_COMMAND);
- Assert.Equal(_myCommand.Id, message.Id);
- Assert.False(message.Redelivered);
- Assert.Equal(_myCommand.Id, message.Header.MessageId);
- Assert.Contains(_topicName, message.Header.Topic.Value);
- Assert.Equal(_correlationId, message.Header.CorrelationId);
- Assert.Equal(_replyTo, message.Header.ReplyTo);
- Assert.Equal(_contentType, message.Header.ContentType);
- Assert.Equal(0, message.Header.HandledCount);
- Assert.Equal(_message.Header.Subject, message.Header.Subject);
+ await Assert.That(message.Id).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Redelivered).IsFalse();
+ await Assert.That(message.Header.MessageId).IsEqualTo(_myCommand.Id);
+ await Assert.That(message.Header.Topic.Value).Contains(_topicName);
+ await Assert.That(message.Header.CorrelationId).IsEqualTo(_correlationId);
+ await Assert.That(message.Header.ReplyTo).IsEqualTo(_replyTo);
+ await Assert.That(message.Header.ContentType).IsEqualTo(_contentType);
+ await Assert.That(message.Header.HandledCount).IsEqualTo(0);
+ await Assert.That(message.Header.Subject).IsEqualTo(_message.Header.Subject);
//allow for clock drift in the following test, more important to have a contemporary timestamp than anything
- Assert.True((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))));
- Assert.Equal(TimeSpan.Zero, message.Header.Delayed);
+ await Assert.That((message.Header.TimeStamp) > (RoundToSeconds(DateTime.UtcNow.AddMinutes(-1)))).IsTrue();
+ await Assert.That(message.Header.Delayed).IsEqualTo(TimeSpan.Zero);
//{"Id":"cd581ced-c066-4322-aeaf-d40944de8edd","Value":"Test","WasCancelled":false,"TaskCompleted":false}
- Assert.Equal(_message.Body.Value, message.Body.Value);
+ await Assert.That(message.Body.Value).IsEqualTo(_message.Body.Value);
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
//Clean up resources that we have created
- _channelFactory.DeleteTopicAsync().Wait();
- _channelFactory.DeleteQueueAsync().Wait();
- _messageProducer.Dispose();
+ await _channelFactory.DeleteTopicAsync();
+ await _channelFactory.DeleteQueueAsync();
+ await _messageProducer.DisposeAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_assume_throws.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_assume_throws.cs
index 6efdc8a68c..488544fa83 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_assume_throws.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_assume_throws.cs
@@ -4,19 +4,19 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsAssumeQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsAssumeQueuesTests : IAsyncDisposable
{
- private readonly ChannelFactory _channelFactory;
- private readonly SqsMessageConsumer _consumer;
+ private ChannelFactory _channelFactory;
+ private SqsMessageConsumer _consumer;
- public AwsAssumeQueuesTests()
+ [Before(Test)]
+ public async Task Setup()
{
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
string topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
@@ -42,7 +42,7 @@ public AwsAssumeQueuesTests()
MakeChannels = OnMissingChannel.Create
});
- producer.ConfirmTopicExistsAsync(topicName).Wait();
+ await producer.ConfirmTopicExistsAsync(topicName);
_channelFactory = new ChannelFactory(awsConnection);
var channel = _channelFactory.CreateSyncChannel(subscription);
@@ -51,16 +51,17 @@ public AwsAssumeQueuesTests()
_consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName());
}
- [Fact]
- public void When_queues_missing_assume_throws()
+ [Test]
+ public async Task When_queues_missing_assume_throws()
{
//we will try to get the queue url, and fail because it does not exist
- Assert.Throws(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000)));
+ await Assert.That(() => _consumer.Receive(TimeSpan.FromMilliseconds(1000))).ThrowsExactly();
}
- public void Dispose()
+ [After(Test)]
+ public async Task Cleanup()
{
- _channelFactory.DeleteTopicAsync().Wait();
+ await _channelFactory.DeleteTopicAsync();
}
public async ValueTask DisposeAsync()
diff --git a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_verify_throws.cs b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_verify_throws.cs
index 07ee0c8f51..74f4f65853 100644
--- a/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_verify_throws.cs
+++ b/tests/Paramore.Brighter.AWS.V4.Tests/MessagingGateway/Sns/Standard/Reactor/When_queues_missing_verify_throws.cs
@@ -4,20 +4,20 @@
using Paramore.Brighter.AWS.V4.Tests.Helpers;
using Paramore.Brighter.AWS.V4.Tests.TestDoubles;
using Paramore.Brighter.MessagingGateway.AWSSQS.V4;
-using Xunit;
using System.Collections.Generic;
using Amazon.SimpleNotificationService.Model;
namespace Paramore.Brighter.AWS.V4.Tests.MessagingGateway.Sns.Standard.Reactor;
-[Trait("Category", "AWS")]
-public class AwsValidateQueuesTests : IDisposable, IAsyncDisposable
+[Category("AWS")]
+public class AwsValidateQueuesTests : IAsyncDisposable
{
- private readonly AWSMessagingGatewayConnection _awsConnection;
- private readonly SqsSubscription _subscription;
+ private AWSMessagingGatewayConnection _awsConnection;
+ private SqsSubscription