diff --git a/src/NServiceBus.AcceptanceTesting/ContextAppender.cs b/src/NServiceBus.AcceptanceTesting/ContextAppender.cs
index 137aaba85ec..2391f45b8ac 100644
--- a/src/NServiceBus.AcceptanceTesting/ContextAppender.cs
+++ b/src/NServiceBus.AcceptanceTesting/ContextAppender.cs
@@ -109,7 +109,7 @@ void Log(string message, LogLevel messageSeverity)
if (context == null)
{
// avoid NRE in case something logs outside of a test scenario
- TestContext.WriteLine(message);
+ TestContext.Out.WriteLine(message);
return;
}
diff --git a/src/NServiceBus.AcceptanceTesting/NServiceBus.AcceptanceTesting.csproj b/src/NServiceBus.AcceptanceTesting/NServiceBus.AcceptanceTesting.csproj
index 212d3029aa0..cd39c07aba1 100644
--- a/src/NServiceBus.AcceptanceTesting/NServiceBus.AcceptanceTesting.csproj
+++ b/src/NServiceBus.AcceptanceTesting/NServiceBus.AcceptanceTesting.csproj
@@ -12,7 +12,8 @@
-
+
+
diff --git a/src/NServiceBus.AcceptanceTesting/ScenarioWithContext.cs b/src/NServiceBus.AcceptanceTesting/ScenarioWithContext.cs
index 86dc7f76113..bfd0c5e3102 100644
--- a/src/NServiceBus.AcceptanceTesting/ScenarioWithContext.cs
+++ b/src/NServiceBus.AcceptanceTesting/ScenarioWithContext.cs
@@ -45,7 +45,7 @@ public async Task Run(RunSettings settings)
await runDescriptor.RaiseOnTestCompleted(runSummary).ConfigureAwait(false);
- TestContext.WriteLine("Test {0}: Scenario completed in {1:0.0}s", TestContext.CurrentContext.Test.FullName, sw.Elapsed.TotalSeconds);
+ TestContext.Out.WriteLine("Test {0}: Scenario completed in {1:0.0}s", TestContext.CurrentContext.Test.FullName, sw.Elapsed.TotalSeconds);
if (runSummary.Result.Failed)
{
diff --git a/src/NServiceBus.AcceptanceTesting/Support/EndpointBehavior.cs b/src/NServiceBus.AcceptanceTesting/Support/EndpointBehavior.cs
index 8aa2b1e4f14..a49751624be 100644
--- a/src/NServiceBus.AcceptanceTesting/Support/EndpointBehavior.cs
+++ b/src/NServiceBus.AcceptanceTesting/Support/EndpointBehavior.cs
@@ -46,7 +46,7 @@ public async Task CreateRunner(RunDescriptor run)
}
catch (Exception)
{
- TestContext.WriteLine($"Endpoint {runner.Name} failed to initialize");
+ await TestContext.Out.WriteLineAsync($"Endpoint {runner.Name} failed to initialize").ConfigureAwait(false);
throw;
}
return runner;
diff --git a/src/NServiceBus.AcceptanceTests/Audit/When_a_message_is_audited.cs b/src/NServiceBus.AcceptanceTests/Audit/When_a_message_is_audited.cs
index 320829e2d73..4268c3bdae0 100644
--- a/src/NServiceBus.AcceptanceTests/Audit/When_a_message_is_audited.cs
+++ b/src/NServiceBus.AcceptanceTests/Audit/When_a_message_is_audited.cs
@@ -23,7 +23,7 @@ public async Task Should_preserve_the_original_body()
.Done(c => c.Done)
.Run();
- Assert.AreEqual(context.OriginalBodyChecksum, context.AuditChecksum, "The body of the message sent to audit should be the same as the original message coming off the queue");
+ Assert.That(context.AuditChecksum, Is.EqualTo(context.OriginalBodyChecksum), "The body of the message sent to audit should be the same as the original message coming off the queue");
}
public static byte Checksum(byte[] data)
diff --git a/src/NServiceBus.AcceptanceTests/Audit/When_a_replymessage_is_audited.cs b/src/NServiceBus.AcceptanceTests/Audit/When_a_replymessage_is_audited.cs
index 202599f2110..bcfbfa02e4c 100644
--- a/src/NServiceBus.AcceptanceTests/Audit/When_a_replymessage_is_audited.cs
+++ b/src/NServiceBus.AcceptanceTests/Audit/When_a_replymessage_is_audited.cs
@@ -21,9 +21,12 @@ public async Task Should_audit_the_message()
.Done(c => c.MessageAudited)
.Run();
- Assert.True(context.MessageProcessed);
- Assert.True(context.MessageAudited);
- Assert.AreEqual("SomeValue", context.HeaderValue);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageProcessed, Is.True);
+ Assert.That(context.MessageAudited, Is.True);
+ Assert.That(context.HeaderValue, Is.EqualTo("SomeValue"));
+ });
}
public static byte Checksum(byte[] data)
diff --git a/src/NServiceBus.AcceptanceTests/Audit/When_audit_is_overridden_in_code.cs b/src/NServiceBus.AcceptanceTests/Audit/When_audit_is_overridden_in_code.cs
index cda85bb62d8..690f354e6a5 100644
--- a/src/NServiceBus.AcceptanceTests/Audit/When_audit_is_overridden_in_code.cs
+++ b/src/NServiceBus.AcceptanceTests/Audit/When_audit_is_overridden_in_code.cs
@@ -16,7 +16,7 @@ public async Task Should_audit_to_target_queue()
.Done(c => c.MessageAudited)
.Run();
- Assert.True(context.MessageAudited);
+ Assert.That(context.MessageAudited, Is.True);
}
public class UserEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Audit/When_auditing.cs b/src/NServiceBus.AcceptanceTests/Audit/When_auditing.cs
index b420149d996..0a3caccd675 100644
--- a/src/NServiceBus.AcceptanceTests/Audit/When_auditing.cs
+++ b/src/NServiceBus.AcceptanceTests/Audit/When_auditing.cs
@@ -18,7 +18,7 @@ public async Task Should_not_be_forwarded_to_auditQueue_when_auditing_is_disable
.Done(c => c.IsMessageHandlingComplete)
.Run();
- Assert.IsFalse(context.IsMessageHandledByTheAuditEndpoint);
+ Assert.That(context.IsMessageHandledByTheAuditEndpoint, Is.False);
}
[Test]
@@ -30,7 +30,7 @@ public async Task Should_be_forwarded_to_auditQueue_when_auditing_is_enabled()
.Done(c => c.IsMessageHandlingComplete && c.IsMessageHandledByTheAuditEndpoint)
.Run();
- Assert.IsTrue(context.IsMessageHandledByTheAuditEndpoint);
+ Assert.That(context.IsMessageHandledByTheAuditEndpoint, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Audit/When_auditing_message_with_TimeToBeReceived.cs b/src/NServiceBus.AcceptanceTests/Audit/When_auditing_message_with_TimeToBeReceived.cs
index 5147862621b..698c12d2153 100644
--- a/src/NServiceBus.AcceptanceTests/Audit/When_auditing_message_with_TimeToBeReceived.cs
+++ b/src/NServiceBus.AcceptanceTests/Audit/When_auditing_message_with_TimeToBeReceived.cs
@@ -23,7 +23,7 @@ public async Task Should_not_honor_TimeToBeReceived_for_audit_message()
.Done(c => c.IsMessageHandlingComplete && c.TTBRHasExpiredAndMessageIsStillInAuditQueue)
.Run();
- Assert.IsTrue(context.IsMessageHandlingComplete);
+ Assert.That(context.IsMessageHandlingComplete, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Audit/When_a_message_is_audited.cs b/src/NServiceBus.AcceptanceTests/Core/Audit/When_a_message_is_audited.cs
index 65400d87bb5..c9c393b94f2 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Audit/When_a_message_is_audited.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Audit/When_a_message_is_audited.cs
@@ -24,7 +24,7 @@ public async Task Should_allow_audit_action_to_be_replaced()
.Done(c => c.AuditMessageReceived)
.Run();
- Assert.True(context.BodyWasEmpty);
+ Assert.That(context.BodyWasEmpty, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_excluding_event_type_from_autosubscribe.cs b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_excluding_event_type_from_autosubscribe.cs
index 8d5120c104a..524cee991ec 100644
--- a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_excluding_event_type_from_autosubscribe.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_excluding_event_type_from_autosubscribe.cs
@@ -22,10 +22,10 @@ public async Task Should_not_subscribe_excluded_events()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.AreEqual(1, ctx.EventsSubscribedTo.Count);
- Assert.AreEqual(typeof(EventToSubscribeTo), ctx.EventsSubscribedTo[0]);
+ Assert.That(ctx.EventsSubscribedTo, Has.Count.EqualTo(1));
+ Assert.That(ctx.EventsSubscribedTo[0], Is.EqualTo(typeof(EventToSubscribeTo)));
- CollectionAssert.IsEmpty(ctx.Logs.Where(l => l.LoggerName == typeof(AutoSubscribe).FullName && l.Level == LogLevel.Error));
+ Assert.That(ctx.Logs.Where(l => l.LoggerName == typeof(AutoSubscribe).FullName && l.Level == LogLevel.Error), Is.Empty);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs
index 67aa9dbfb09..9da97253dde 100644
--- a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs
@@ -19,8 +19,8 @@ public async Task Should_autoSubscribe_the_saga_messageHandler_by_default()
.Done(c => c.EventsSubscribedTo.Count >= 2)
.Run();
- Assert.True(context.EventsSubscribedTo.Contains(typeof(MyEvent)), "Events only handled by sagas should be auto subscribed");
- Assert.True(context.EventsSubscribedTo.Contains(typeof(MyEventBase)), "Sagas should be auto subscribed even when handling a base class event");
+ Assert.That(context.EventsSubscribedTo, Does.Contain(typeof(MyEvent)), "Events only handled by sagas should be auto subscribed");
+ Assert.That(context.EventsSubscribedTo, Does.Contain(typeof(MyEventBase)), "Sagas should be auto subscribed even when handling a base class event");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs
index 57b33c16b8f..6049153f245 100644
--- a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs
@@ -19,7 +19,7 @@ public async Task Should_not_autoSubscribe_messages_handled_by_sagas_if_asked_to
.Done(c => c.EndpointsStarted)
.Run();
- Assert.False(context.EventsSubscribedTo.Count != 0, "Events only handled by sagas should not be auto subscribed");
+ Assert.That(context.EventsSubscribedTo.Count, Is.EqualTo(0), "Events only handled by sagas should not be auto subscribed");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_autosubscribe.cs b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_autosubscribe.cs
index 31451547916..b9fd8c0c373 100644
--- a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_autosubscribe.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_autosubscribe.cs
@@ -20,12 +20,15 @@ public async Task Should_autosubscribe_to_relevant_messagetypes()
.Done(c => c.EndpointsStarted && c.EventsSubscribedTo.Count >= 1)
.Run();
- Assert.AreEqual(1, context.EventsSubscribedTo.Count);
- Assert.True(context.EventsSubscribedTo.Contains(typeof(MyEvent).AssemblyQualifiedName), "Events should be auto subscribed");
- Assert.False(context.EventsSubscribedTo.Contains(typeof(MyEventWithNoRouting).AssemblyQualifiedName), "Events without routing should not be auto subscribed");
- Assert.False(context.EventsSubscribedTo.Contains(typeof(MyEventWithNoHandler).AssemblyQualifiedName), "Events without handlers should not be auto subscribed");
- Assert.False(context.EventsSubscribedTo.Contains(typeof(MyCommand).AssemblyQualifiedName), "Commands should not be auto subscribed");
- Assert.False(context.EventsSubscribedTo.Contains(typeof(MyMessage).AssemblyQualifiedName), "Plain messages should not be auto subscribed by default");
+ Assert.That(context.EventsSubscribedTo, Has.Count.EqualTo(1));
+ Assert.That(context.EventsSubscribedTo, Does.Contain(typeof(MyEvent).AssemblyQualifiedName), "Events should be auto subscribed");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.EventsSubscribedTo.Contains(typeof(MyEventWithNoRouting).AssemblyQualifiedName), Is.False, "Events without routing should not be auto subscribed");
+ Assert.That(context.EventsSubscribedTo.Contains(typeof(MyEventWithNoHandler).AssemblyQualifiedName), Is.False, "Events without handlers should not be auto subscribed");
+ Assert.That(context.EventsSubscribedTo.Contains(typeof(MyCommand).AssemblyQualifiedName), Is.False, "Commands should not be auto subscribed");
+ Assert.That(context.EventsSubscribedTo.Contains(typeof(MyMessage).AssemblyQualifiedName), Is.False, "Plain messages should not be auto subscribed by default");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_autosubscribe_disabled.cs b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_autosubscribe_disabled.cs
index ee245f673d4..b25d5ab8d8e 100644
--- a/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_autosubscribe_disabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/AutomaticSubscriptions/When_starting_an_endpoint_with_autosubscribe_disabled.cs
@@ -20,7 +20,7 @@ public async Task Should_not_autosubscribe_any_events()
.Done(ctx => ctx.EndpointsStarted)
.Run();
- Assert.IsEmpty(context.SubscribedEvents);
+ Assert.That(context.SubscribedEvents, Is.Empty);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_injecting_message_session_into_handlers.cs b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_injecting_message_session_into_handlers.cs
index 4d935f991b8..553c629b52c 100644
--- a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_injecting_message_session_into_handlers.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_injecting_message_session_into_handlers.cs
@@ -16,7 +16,7 @@ public void Should_throw_on_startup()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("IMessageSession", exception.ToString());
+ Assert.That(exception.ToString(), Does.Contain("IMessageSession"));
}
public class StartedEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command.cs b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command.cs
index 51c5e51b1d9..3912658394a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command.cs
@@ -27,7 +27,7 @@ public async Task Should_throw()
.Done(c => c.GotTheException)
.Run();
- Assert.IsInstanceOf(context.Exception);
+ Assert.That(context.Exception, Is.InstanceOf());
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command_bestpractices_disabled.cs b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command_bestpractices_disabled.cs
index 25a13d76008..6e5b9f0c31a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command_bestpractices_disabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command_bestpractices_disabled.cs
@@ -28,7 +28,7 @@ public async Task Should_allow_publishing_commands()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.True(context.EndpointsStarted);
+ Assert.That(context.EndpointsStarted, Is.True);
}
public class Endpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs
index 12beef59e0f..50566e822f9 100644
--- a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs
@@ -22,7 +22,7 @@ public async Task Should_allow_publishing_commands()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.True(context.EndpointsStarted);
+ Assert.That(context.EndpointsStarted, Is.True);
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_sending_event.cs b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_sending_event.cs
index 4047d2d048e..23b6428eaa8 100644
--- a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_sending_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_sending_event.cs
@@ -27,7 +27,7 @@ public async Task Should_throw()
.Done(c => c.GotTheException)
.Run();
- Assert.IsInstanceOf(context.Exception);
+ Assert.That(context.Exception, Is.InstanceOf());
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_sending_events_bestpractices_disabled.cs b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_sending_events_bestpractices_disabled.cs
index 95b73058e88..19bf547c1d4 100644
--- a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_sending_events_bestpractices_disabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_sending_events_bestpractices_disabled.cs
@@ -22,7 +22,7 @@ public async Task Should_allow_sending_events()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.True(context.EndpointsStarted);
+ Assert.That(context.EndpointsStarted, Is.True);
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_subscribing_to_command.cs b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_subscribing_to_command.cs
index 34858728a09..b7d3efa7057 100644
--- a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_subscribing_to_command.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_subscribing_to_command.cs
@@ -27,7 +27,7 @@ public async Task Should_throw()
.Done(c => c.GotTheException)
.Run();
- Assert.IsInstanceOf(context.Exception);
+ Assert.That(context.Exception, Is.InstanceOf());
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_unsubscribing_to_command.cs b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_unsubscribing_to_command.cs
index f265e217221..c27037db68e 100644
--- a/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_unsubscribing_to_command.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/BestPractices/When_unsubscribing_to_command.cs
@@ -27,7 +27,7 @@ public async Task Should_throw()
.Done(c => c.GotTheException)
.Run();
- Assert.IsInstanceOf(context.Exception);
+ Assert.That(context.Exception, Is.InstanceOf());
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Causation/When_a_message_is_sent.cs b/src/NServiceBus.AcceptanceTests/Core/Causation/When_a_message_is_sent.cs
index da4a78ee05b..4328c290cc0 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Causation/When_a_message_is_sent.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Causation/When_a_message_is_sent.cs
@@ -15,8 +15,11 @@ public async Task Should_flow_causation_headers()
.Done(c => c.Done)
.Run();
- Assert.AreEqual(context.FirstConversationId, context.ConversationIdReceived, "Conversation id should flow to outgoing messages");
- Assert.AreEqual(context.MessageIdOfFirstMessage, context.RelatedToReceived, "RelatedToId on outgoing messages should be set to the message id of the message causing it to be sent");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ConversationIdReceived, Is.EqualTo(context.FirstConversationId), "Conversation id should flow to outgoing messages");
+ Assert.That(context.RelatedToReceived, Is.EqualTo(context.MessageIdOfFirstMessage), "RelatedToId on outgoing messages should be set to the message id of the message causing it to be sent");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Causation/When_overriding_conversation_id_generation.cs b/src/NServiceBus.AcceptanceTests/Core/Causation/When_overriding_conversation_id_generation.cs
index 42fa9cc30de..3f8e864bb04 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Causation/When_overriding_conversation_id_generation.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Causation/When_overriding_conversation_id_generation.cs
@@ -34,8 +34,11 @@ public async Task Should_use_custom_id()
.Done(c => c.MatchingMessageReceived && c.NonMatchingMessageReceived)
.Run();
- Assert.AreEqual($"{tennantId}-{myBusinessMessage.MyBusinessId}", context.MatchingConversationIdReceived);
- Assert.True(Guid.TryParse(context.NonMatchingConversationIdReceived, out var _));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MatchingConversationIdReceived, Is.EqualTo($"{tennantId}-{myBusinessMessage.MyBusinessId}"));
+ Assert.That(Guid.TryParse(context.NonMatchingConversationIdReceived, out var _), Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Causation/When_starting_new_conversation_inside_message_handler.cs b/src/NServiceBus.AcceptanceTests/Core/Causation/When_starting_new_conversation_inside_message_handler.cs
index e8eb34cc69e..7eb9a9759cb 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Causation/When_starting_new_conversation_inside_message_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Causation/When_starting_new_conversation_inside_message_handler.cs
@@ -23,8 +23,11 @@ public async Task With_specified_conversation_id()
.Done(ctx => ctx.MessageHandled)
.Run();
- Assert.That(context.NewConversationId, Is.EqualTo(UserDefinedConverstionId), "ConversationId should be set to the user defined value.");
- Assert.That(context.PreviousConversationId, Is.EqualTo(context.OriginalConversationId), "PreviousConversationId header should be set to the original conversation id.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.NewConversationId, Is.EqualTo(UserDefinedConverstionId), "ConversationId should be set to the user defined value.");
+ Assert.That(context.PreviousConversationId, Is.EqualTo(context.OriginalConversationId), "PreviousConversationId header should be set to the original conversation id.");
+ });
}
[Test]
@@ -40,8 +43,11 @@ public async Task Without_specified_conversation_id()
.Run();
Assert.That(context.NewConversationId, Is.EqualTo(GeneratedConversationId), "ConversationId should be generated.");
- Assert.That(context.NewConversationId, Is.Not.EqualTo(context.OriginalConversationId), "ConversationId should not be equal to the original conversation id.");
- Assert.That(context.PreviousConversationId, Is.EqualTo(context.OriginalConversationId), "PreviousConversationId header should be set to the original conversation id.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.NewConversationId, Is.Not.EqualTo(context.OriginalConversationId), "ConversationId should not be equal to the original conversation id.");
+ Assert.That(context.PreviousConversationId, Is.EqualTo(context.OriginalConversationId), "PreviousConversationId header should be set to the original conversation id.");
+ });
}
class NewConversationScenario : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Causation/When_starting_new_conversation_outside_message_handler.cs b/src/NServiceBus.AcceptanceTests/Core/Causation/When_starting_new_conversation_outside_message_handler.cs
index a69fe3985ea..de5585783a6 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Causation/When_starting_new_conversation_outside_message_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Causation/When_starting_new_conversation_outside_message_handler.cs
@@ -26,8 +26,11 @@ public async Task With_specified_conversation_id()
.Done(ctx => ctx.MessageHandled)
.Run();
- Assert.That(context.ConversationId, Is.EqualTo(NewConversionId), "ConversationId should be set to configured user defined value.");
- Assert.That(context.PreviousConversationId, Is.Null, "Previous ConversationId should not be set when handling a message outside of a message handler.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ConversationId, Is.EqualTo(NewConversionId), "ConversationId should be set to configured user defined value.");
+ Assert.That(context.PreviousConversationId, Is.Null, "Previous ConversationId should not be set when handling a message outside of a message handler.");
+ });
}
[Test]
@@ -46,8 +49,11 @@ public async Task Without_specified_conversation_id()
.Run();
Assert.That(context.ConversationId, Is.EqualTo(GeneratedConversationId), "ConversationId should be generated.");
- Assert.That(context.ConversationId, Is.Not.EqualTo(context.PreviousConversationId), "ConversationId should not match the previous conversationId.");
- Assert.That(context.PreviousConversationId, Is.Null, "Previous ConversationId should not be set when handling a message outside of a message handler.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ConversationId, Is.Not.EqualTo(context.PreviousConversationId), "ConversationId should not match the previous conversationId.");
+ Assert.That(context.PreviousConversationId, Is.Null, "Previous ConversationId should not be set when handling a message outside of a message handler.");
+ });
}
[Test]
@@ -77,8 +83,11 @@ public async Task Cannot_set_value_for_header_directly()
.Run();
var expectedExceptionMessage = $"Cannot set the NServiceBus.ConversationId header to '{overrideConversationId}' as StartNewConversation() was called.";
- Assert.That(context.ExceptionThrown, Is.True, "Exception should be thrown when trying to directly set conversationId");
- Assert.That(context.ExceptionMessage, Is.EqualTo(expectedExceptionMessage));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ExceptionThrown, Is.True, "Exception should be thrown when trying to directly set conversationId");
+ Assert.That(context.ExceptionMessage, Is.EqualTo(expectedExceptionMessage));
+ });
}
public class AnyMessage : IMessage
diff --git a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_receiving_non_matching_message_with_handler.cs b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_receiving_non_matching_message_with_handler.cs
index 223dba5cfab..6f3f19887fc 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_receiving_non_matching_message_with_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_receiving_non_matching_message_with_handler.cs
@@ -17,7 +17,7 @@ public async Task Should_process_message()
.Done(c => c.GotTheMessage)
.Run();
- Assert.True(context.GotTheMessage);
+ Assert.That(context.GotTheMessage, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_receiving_unobtrusive_message_without_handler.cs b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_receiving_unobtrusive_message_without_handler.cs
index e24a12ecc14..b6f83b7163f 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_receiving_unobtrusive_message_without_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_receiving_unobtrusive_message_without_handler.cs
@@ -19,9 +19,12 @@ public async Task Message_should_be_moved_to_error_because_handler_not_found()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.True(context.Logs.Any(l => l.Level == LogLevel.Error && l.Message.Contains($"No handlers could be found for message type: {typeof(MyCommand).FullName}")), "No handlers could be found was not logged.");
- Assert.False(context.Logs.Any(l => l.Level == LogLevel.Warn && l.Message.Contains($"Message header '{typeof(MyCommand).FullName}' was mapped to type '{typeof(MyCommand).FullName}' but that type was not found in the message registry, ensure the same message registration conventions are used in all endpoints, especially if using unobtrusive mode.")), "Message type could not be mapped.");
- Assert.False(context.Logs.Any(l => l.Level == LogLevel.Warn && l.Message.Contains($"Could not determine message type from message header '{typeof(MyCommand).FullName}'")), "Message type could not be mapped.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Logs.Any(l => l.Level == LogLevel.Error && l.Message.Contains($"No handlers could be found for message type: {typeof(MyCommand).FullName}")), Is.True, "No handlers could be found was not logged.");
+ Assert.That(context.Logs.Any(l => l.Level == LogLevel.Warn && l.Message.Contains($"Message header '{typeof(MyCommand).FullName}' was mapped to type '{typeof(MyCommand).FullName}' but that type was not found in the message registry, ensure the same message registration conventions are used in all endpoints, especially if using unobtrusive mode.")), Is.False, "Message type could not be mapped.");
+ Assert.That(context.Logs.Any(l => l.Level == LogLevel.Warn && l.Message.Contains($"Could not determine message type from message header '{typeof(MyCommand).FullName}'")), Is.False, "Message type could not be mapped.");
+ });
}
public class Context : ScenarioContext { }
diff --git a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_sending_interface_message_with_conventions.cs b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_sending_interface_message_with_conventions.cs
index 67708b8a656..5f1ab6540d4 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_sending_interface_message_with_conventions.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_sending_interface_message_with_conventions.cs
@@ -21,7 +21,7 @@ public async Task Should_receive_the_message()
.Done(c => c.MessageInterfaceReceived)
.Run();
- Assert.True(context.MessageInterfaceReceived);
+ Assert.That(context.MessageInterfaceReceived, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_sending_with_conventions.cs b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_sending_with_conventions.cs
index c9537140158..a8fea618996 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_sending_with_conventions.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_sending_with_conventions.cs
@@ -20,8 +20,11 @@ public async Task Should_receive_the_message()
.Done(c => c.MessageClassReceived && c.MessageInterfaceReceived)
.Run();
- Assert.True(context.MessageClassReceived);
- Assert.True(context.MessageInterfaceReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageClassReceived, Is.True);
+ Assert.That(context.MessageInterfaceReceived, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_using_a_greedy_convention.cs b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_using_a_greedy_convention.cs
index 304bf36a220..7fbba4a0bb9 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Conventions/When_using_a_greedy_convention.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Conventions/When_using_a_greedy_convention.cs
@@ -20,7 +20,7 @@ public async Task Should_receive_the_message()
.Done(c => c.WasCalled)
.Run();
- Assert.True(context.WasCalled, "The message handler should be called");
+ Assert.That(context.WasCalled, Is.True, "The message handler should be called");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/CriticalError/When_raising_critical_error_at_startup.cs b/src/NServiceBus.AcceptanceTests/Core/CriticalError/When_raising_critical_error_at_startup.cs
index 76e17ab6ec9..94da2e1694e 100644
--- a/src/NServiceBus.AcceptanceTests/Core/CriticalError/When_raising_critical_error_at_startup.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/CriticalError/When_raising_critical_error_at_startup.cs
@@ -29,8 +29,11 @@ public async Task Should_call_critical_error_action_for_every_error_that_occurre
.Done(c => c.CriticalErrorsRaised >= 2 && exceptions.Count >= 2)
.Run();
- Assert.AreEqual(2, context.CriticalErrorsRaised);
- Assert.AreEqual(context.CriticalErrorsRaised, exceptions.Count);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.CriticalErrorsRaised, Is.EqualTo(2));
+ Assert.That(exceptions, Has.Count.EqualTo(context.CriticalErrorsRaised));
+ });
}
public class TestContext : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/CriticalError/When_raising_critical_error_from_a_handler.cs b/src/NServiceBus.AcceptanceTests/Core/CriticalError/When_raising_critical_error_from_a_handler.cs
index db2838e1ed3..b0ed14047ae 100644
--- a/src/NServiceBus.AcceptanceTests/Core/CriticalError/When_raising_critical_error_from_a_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/CriticalError/When_raising_critical_error_from_a_handler.cs
@@ -41,7 +41,7 @@ await Scenario.Define()
.Done(c => c.CriticalErrorsRaised > 0 && exceptions.Keys.Count > 0)
.Run();
- Assert.AreEqual(1, exceptions.Keys.Count);
+ Assert.That(exceptions.Keys, Has.Count.EqualTo(1));
}
public class TestContext : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/DelayedDelivery/When_delayed_delivery_is_not_supported.cs b/src/NServiceBus.AcceptanceTests/Core/DelayedDelivery/When_delayed_delivery_is_not_supported.cs
index 7fb3640b557..532aea47f0a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/DelayedDelivery/When_delayed_delivery_is_not_supported.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/DelayedDelivery/When_delayed_delivery_is_not_supported.cs
@@ -28,8 +28,11 @@ public async Task Trying_to_delay_should_throw()
.Done(c => c.ExceptionThrown || c.SecondMessageReceived)
.Run();
- Assert.AreEqual(true, context.ExceptionThrown);
- Assert.AreEqual(false, context.SecondMessageReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ExceptionThrown, Is.EqualTo(true));
+ Assert.That(context.SecondMessageReceived, Is.EqualTo(false));
+ });
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_overriding_services_in_registercomponents.cs b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_overriding_services_in_registercomponents.cs
index 3dc84f089dd..40da2b842fa 100644
--- a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_overriding_services_in_registercomponents.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_overriding_services_in_registercomponents.cs
@@ -31,11 +31,14 @@ public async Task RegisterComponents_calls_override_registrations()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.IsInstanceOf(context.DependencyFromFeature);
- Assert.IsInstanceOf(context.DependencyBeforeEndpointConfiguration);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.DependencyFromFeature, Is.InstanceOf());
+ Assert.That(context.DependencyBeforeEndpointConfiguration, Is.InstanceOf());
- // Registrations after the startable endpoint has been created can't be overriden by the RegisterComponents API
- Assert.IsInstanceOf(context.DependencyBeforeEndpointStart);
+ // Registrations after the startable endpoint has been created can't be overriden by the RegisterComponents API
+ Assert.That(context.DependencyBeforeEndpointStart, Is.InstanceOf());
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_registering_async_disposables_externally_managed.cs b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_registering_async_disposables_externally_managed.cs
index 2eb4268d736..0a922f7955c 100644
--- a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_registering_async_disposables_externally_managed.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_registering_async_disposables_externally_managed.cs
@@ -35,8 +35,11 @@ public async Task Should_dispose()
await serviceProvider.DisposeAsync();
- Assert.That(context.ScopedAsyncDisposableDisposed, Is.True, "Scoped AsyncDisposable wasn't disposed as it should have been.");
- Assert.That(context.SingletonAsyncDisposableDisposed, Is.True, "Singleton AsyncDisposable wasn't disposed as it should have been.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ScopedAsyncDisposableDisposed, Is.True, "Scoped AsyncDisposable wasn't disposed as it should have been.");
+ Assert.That(context.SingletonAsyncDisposableDisposed, Is.True, "Singleton AsyncDisposable wasn't disposed as it should have been.");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_registering_async_disposables_internally_managed.cs b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_registering_async_disposables_internally_managed.cs
index 4f35619282e..826621a3612 100644
--- a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_registering_async_disposables_internally_managed.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_registering_async_disposables_internally_managed.cs
@@ -21,8 +21,11 @@ public async Task Should_dispose()
.Done(c => c.ScopedAsyncDisposableDisposed)
.Run(TimeSpan.FromSeconds(10));
- Assert.That(context.ScopedAsyncDisposableDisposed, Is.True, "Scoped AsyncDisposable wasn't disposed as it should have been.");
- Assert.That(context.SingletonAsyncDisposableDisposed, Is.True, "Singleton AsyncDisposable wasn't disposed as it should have been.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ScopedAsyncDisposableDisposed, Is.True, "Scoped AsyncDisposable wasn't disposed as it should have been.");
+ Assert.That(context.SingletonAsyncDisposableDisposed, Is.True, "Singleton AsyncDisposable wasn't disposed as it should have been.");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_resolving_address_translator.cs b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_resolving_address_translator.cs
index ba70520d610..9c99ac67dd7 100644
--- a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_resolving_address_translator.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_resolving_address_translator.cs
@@ -64,7 +64,7 @@ await Scenario.Define()
.Done(ctx => thrownException != null)
.Run();
- StringAssert.Contains("Transport address resolution is not supported before the NServiceBus transport has been started.", thrownException.Message);
+ Assert.That(thrownException.Message, Does.Contain("Transport address resolution is not supported before the NServiceBus transport has been started."));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_using_externally_managed_container.cs b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_using_externally_managed_container.cs
index 14860387f47..12fb678c6e0 100644
--- a/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_using_externally_managed_container.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/DependencyInjection/When_using_externally_managed_container.cs
@@ -29,8 +29,11 @@ public async Task Should_use_it_for_component_resolution()
.Done(c => c.MessageReceived)
.Run();
- Assert.NotNull(result.ServiceProvider, "IServiceProvider should be injectable");
- Assert.AreSame(myComponent, result.CustomService, "Should inject custom services");
+ Assert.Multiple(() =>
+ {
+ Assert.That(result.ServiceProvider, Is.Not.Null, "IServiceProvider should be injectable");
+ Assert.That(result.CustomService, Is.SameAs(myComponent), "Should inject custom services");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_a_message_is_audited.cs b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_a_message_is_audited.cs
index f72e883d5c3..f8cf80596cd 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_a_message_is_audited.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_a_message_is_audited.cs
@@ -17,10 +17,13 @@ public async Task Should_add_host_related_headers()
.Done(c => c.Done)
.Run();
- Assert.IsNotNull(context.HostId);
- Assert.IsNotNull(context.HostName);
- Assert.IsNotNull(context.Endpoint);
- Assert.IsNotNull(context.Machine);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HostId, Is.Not.Null);
+ Assert.That(context.HostName, Is.Not.Null);
+ Assert.That(context.Endpoint, Is.Not.Null);
+ Assert.That(context.Machine, Is.Not.Null);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_a_message_is_faulted.cs b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_a_message_is_faulted.cs
index bcced65568a..c2b375fe4c3 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_a_message_is_faulted.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_a_message_is_faulted.cs
@@ -17,10 +17,13 @@ public async Task Should_add_host_related_headers()
.Done(c => c.Done)
.Run();
- Assert.IsNotNull(context.HostId, "Host Id should be included in fault message headers");
- Assert.IsNotNull(context.HostName, "Host Name should be included in fault message headers");
- Assert.IsNotNull(context.Endpoint, "Endpoint name should be included in fault message headers.");
- Assert.IsNotNull(context.Machine, "Machine should be included in fault message headers.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HostId, Is.Not.Null, "Host Id should be included in fault message headers");
+ Assert.That(context.HostName, Is.Not.Null, "Host Name should be included in fault message headers");
+ Assert.That(context.Endpoint, Is.Not.Null, "Endpoint name should be included in fault message headers.");
+ Assert.That(context.Machine, Is.Not.Null, "Machine should be included in fault message headers.");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_endpoint_is_started.cs b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_endpoint_is_started.cs
index f580e9e9a47..b6b15d29277 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_endpoint_is_started.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_endpoint_is_started.cs
@@ -31,10 +31,10 @@ await Scenario.Define()
var startupDiagnosticsFileName = $"{endpointName}-configuration.txt";
var pathToFile = Path.Combine(basePath, startupDiagnosticsFileName);
- Assert.True(File.Exists(pathToFile));
+ Assert.That(File.Exists(pathToFile), Is.True);
var diagnosticContent = File.ReadAllText(pathToFile);
- Assert.True(diagnosticContent.Contains("\"Licensing\""));
+ Assert.That(diagnosticContent, Does.Contain("\"Licensing\""));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_license_expired.cs b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_license_expired.cs
index 590e168fbe1..98bb27763b5 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_license_expired.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_license_expired.cs
@@ -20,11 +20,11 @@ public async Task Should_add_the_license_diagnostic_headers_to_audited_messages(
.Done(c => c.Done)
.Run();
- Assert.IsTrue(context.HasDiagnosticLicensingHeaders);
+ Assert.That(context.HasDiagnosticLicensingHeaders, Is.True);
if (Debugger.IsAttached)
{
- Assert.True(context.Logs.Any(m => m.Level == LogLevel.Error && m.Message.StartsWith("Your license has expired")), "Error should be logged");
+ Assert.That(context.Logs.Any(m => m.Level == LogLevel.Error && m.Message.StartsWith("Your license has expired")), Is.True, "Error should be logged");
}
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_message_is_audited.cs b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_message_is_audited.cs
index f586d7697d1..1c7cefba5c1 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_message_is_audited.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_message_is_audited.cs
@@ -26,12 +26,15 @@ public async Task Should_contain_processing_stats_headers()
var processingEnded = DateTimeOffsetHelper.ToDateTimeOffset(context.Headers[Headers.ProcessingEnded]);
var timeSent = DateTimeOffsetHelper.ToDateTimeOffset(context.Headers[Headers.TimeSent]);
- Assert.That(processingStarted, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(processingStarted));
- Assert.That(processingEnded, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(processingEnded));
- Assert.That(timeSent, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(timeSent));
+ Assert.Multiple(() =>
+ {
+ Assert.That(processingStarted, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(processingStarted));
+ Assert.That(processingEnded, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(processingEnded));
+ Assert.That(timeSent, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(timeSent));
+ });
Assert.That(processingStarted, Is.LessThanOrEqualTo(processingEnded), nameof(processingStarted));
Assert.That(timeSent, Is.LessThanOrEqualTo(processingEnded), nameof(timeSent));
- Assert.IsTrue(context.IsMessageHandledByTheAuditEndpoint, nameof(context.IsMessageHandledByTheAuditEndpoint));
+ Assert.That(context.IsMessageHandledByTheAuditEndpoint, Is.True, nameof(context.IsMessageHandledByTheAuditEndpoint));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_message_is_faulted.cs b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_message_is_faulted.cs
index d1a59919098..6149dfa60fc 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_message_is_faulted.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_message_is_faulted.cs
@@ -28,16 +28,22 @@ public async Task Should_contain_processing_stats_headers()
var timeSent = DateTimeOffsetHelper.ToDateTimeOffset(context.Headers[Headers.TimeSent]);
var timeSentWhenFailedMessageWasSentToTheErrorQueue = DateTimeOffsetHelper.ToDateTimeOffset(context.FaultHeaders[Headers.TimeSent]);
- Assert.That(processingStarted, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(processingStarted));
- Assert.That(processingEnded, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(processingEnded));
- Assert.That(timeSent, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(timeSent));
- Assert.That(timeSentWhenFailedMessageWasSentToTheErrorQueue, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(timeSentWhenFailedMessageWasSentToTheErrorQueue));
+ Assert.Multiple(() =>
+ {
+ Assert.That(processingStarted, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(processingStarted));
+ Assert.That(processingEnded, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(processingEnded));
+ Assert.That(timeSent, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(timeSent));
+ Assert.That(timeSentWhenFailedMessageWasSentToTheErrorQueue, Is.EqualTo(now).Within(TimeSpan.FromSeconds(30)), nameof(timeSentWhenFailedMessageWasSentToTheErrorQueue));
+ });
Assert.That(timeSent, Is.LessThanOrEqualTo(processingEnded), nameof(processingEnded));
- Assert.That(timeSent, Is.LessThanOrEqualTo(timeSentWhenFailedMessageWasSentToTheErrorQueue), nameof(timeSentWhenFailedMessageWasSentToTheErrorQueue));
+ Assert.Multiple(() =>
+ {
+ Assert.That(timeSent, Is.LessThanOrEqualTo(timeSentWhenFailedMessageWasSentToTheErrorQueue), nameof(timeSentWhenFailedMessageWasSentToTheErrorQueue));
- Assert.That(timeSentWhenFailedMessageWasSentToTheErrorQueue, Is.EqualTo(context.TimeSentOnTheFailingMessageWhenItWasHandled), nameof(timeSentWhenFailedMessageWasSentToTheErrorQueue));
- Assert.That(processingStarted, Is.LessThanOrEqualTo(processingEnded), nameof(processingStarted));
- Assert.IsTrue(context.IsMessageHandledByTheFaultEndpoint, nameof(context.IsMessageHandledByTheFaultEndpoint));
+ Assert.That(timeSentWhenFailedMessageWasSentToTheErrorQueue, Is.EqualTo(context.TimeSentOnTheFailingMessageWhenItWasHandled), nameof(timeSentWhenFailedMessageWasSentToTheErrorQueue));
+ Assert.That(processingStarted, Is.LessThanOrEqualTo(processingEnded), nameof(processingStarted));
+ Assert.That(context.IsMessageHandledByTheFaultEndpoint, Is.True, nameof(context.IsMessageHandledByTheFaultEndpoint));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_overriding_input_queue_name.cs b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_overriding_input_queue_name.cs
index c7d66112441..8037f5b7a3f 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_overriding_input_queue_name.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_overriding_input_queue_name.cs
@@ -15,8 +15,11 @@ public async Task Should_use_custom_queue_names()
.Done(c => c.Done)
.Run();
- Assert.IsTrue(context.Done);
- Assert.IsTrue(context.InputQueue.StartsWith("OverriddenInputQueue"));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Done, Is.True);
+ Assert.That(context.InputQueue, Does.StartWith("OverriddenInputQueue"));
+ });
}
public class MyEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_sending_ensure_proper_headers.cs b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_sending_ensure_proper_headers.cs
index a5da4d49d6d..a8f58f4ef0e 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_sending_ensure_proper_headers.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Diagnostics/When_sending_ensure_proper_headers.cs
@@ -20,10 +20,13 @@ public async Task Should_have_proper_headers_for_the_originating_endpoint()
.Done(c => c.WasCalled)
.Run();
- Assert.True(context.WasCalled, "The message handler should be called");
- Assert.AreEqual("SenderForEnsureProperHeadersTest", context.ReceivedHeaders[Headers.OriginatingEndpoint], "Message should contain the Originating endpoint");
- Assert.That(context.ReceivedHeaders[Headers.OriginatingHostId], Is.Not.Null.Or.Empty, "OriginatingHostId cannot be null or empty");
- Assert.That(context.ReceivedHeaders[Headers.OriginatingMachine], Is.Not.Null.Or.Empty, "Endpoint machine name cannot be null or empty");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.WasCalled, Is.True, "The message handler should be called");
+ Assert.That(context.ReceivedHeaders[Headers.OriginatingEndpoint], Is.EqualTo("SenderForEnsureProperHeadersTest"), "Message should contain the Originating endpoint");
+ Assert.That(context.ReceivedHeaders[Headers.OriginatingHostId], Is.Not.Null.Or.Empty, "OriginatingHostId cannot be null or empty");
+ Assert.That(context.ReceivedHeaders[Headers.OriginatingMachine], Is.Not.Null.Or.Empty, "Endpoint machine name cannot be null or empty");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/CriticalError/When_registering_custom_critical_error_handler.cs b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/CriticalError/When_registering_custom_critical_error_handler.cs
index b60bd387ae1..291c70d53dd 100644
--- a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/CriticalError/When_registering_custom_critical_error_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/CriticalError/When_registering_custom_critical_error_handler.cs
@@ -19,8 +19,11 @@ public async Task Critical_error_should_be_raised_inside_delegate()
.Done(c => c.ExceptionReceived)
.Run();
- Assert.True(context.Message.StartsWith("Startup task failed to complete."));
- Assert.AreEqual("ExceptionInBusStarts", context.Exception.Message);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Message, Does.StartWith("Startup task failed to complete."));
+ Assert.That(context.Exception.Message, Is.EqualTo("ExceptionInBusStarts"));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs
index 585e8764a70..63ce4e65da2 100644
--- a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs
@@ -54,7 +54,7 @@ public Task Initialize(PushRuntimeSettings limitations, OnMessage onMessage, OnE
public Task StartReceive(CancellationToken cancellationToken = default)
{
- Assert.AreEqual(10, pushSettings.MaxConcurrency);
+ Assert.That(pushSettings.MaxConcurrency, Is.EqualTo(10));
return Task.CompletedTask;
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/Feature/When_depending_on_feature.cs b/src/NServiceBus.AcceptanceTests/Core/Feature/When_depending_on_feature.cs
index e29fd07c30d..3a2d79cff4d 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Feature/When_depending_on_feature.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Feature/When_depending_on_feature.cs
@@ -23,8 +23,11 @@ public async Task Should_start_startup_tasks_in_order_of_dependency()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.That(context.StartCalled, Is.True);
- Assert.That(context.StopCalled, Is.True);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.StartCalled, Is.True);
+ Assert.That(context.StopCalled, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Feature/When_registering_a_startup_task.cs b/src/NServiceBus.AcceptanceTests/Core/Feature/When_registering_a_startup_task.cs
index 20821450201..880557cb217 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Feature/When_registering_a_startup_task.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Feature/When_registering_a_startup_task.cs
@@ -19,7 +19,7 @@ public async Task The_endpoint_should_start()
.Done(c => c.SendOnlyEndpointWasStarted)
.Run();
- Assert.True(context.SendOnlyEndpointWasStarted, "The endpoint should have started without any errors");
+ Assert.That(context.SendOnlyEndpointWasStarted, Is.True, "The endpoint should have started without any errors");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Hosting/When_custom_host_id_is_configured.cs b/src/NServiceBus.AcceptanceTests/Core/Hosting/When_custom_host_id_is_configured.cs
index 532ba952d46..921fd5b5778 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Hosting/When_custom_host_id_is_configured.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Hosting/When_custom_host_id_is_configured.cs
@@ -22,8 +22,11 @@ public async Task Should_not_apply_default_to_be_FIPS_compliant()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.False(context.HostIdDefaultApplied);
- Assert.AreEqual(context.CustomHostId, context.HostIdObserved);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HostIdDefaultApplied, Is.False);
+ Assert.That(context.HostIdObserved, Is.EqualTo(context.CustomHostId));
+ });
}
public class MyEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Hosting/When_disabling_assembly_scanning.cs b/src/NServiceBus.AcceptanceTests/Core/Hosting/When_disabling_assembly_scanning.cs
index 57dcec52280..4f757e6db3a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Hosting/When_disabling_assembly_scanning.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Hosting/When_disabling_assembly_scanning.cs
@@ -15,7 +15,7 @@ public void Should_not_start_endpoint()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains($"Assembly scanning has been disabled. This prevents messages, message handlers, features and other functionality from loading correctly. Enable {nameof(AssemblyScannerConfiguration.ScanAppDomainAssemblies)} or {nameof(AssemblyScannerConfiguration.ScanFileSystemAssemblies)}", exception.Message);
+ Assert.That(exception.Message, Does.Contain($"Assembly scanning has been disabled. This prevents messages, message handlers, features and other functionality from loading correctly. Enable {nameof(AssemblyScannerConfiguration.ScanAppDomainAssemblies)} or {nameof(AssemblyScannerConfiguration.ScanFileSystemAssemblies)}"));
}
public class EndpointWithDisabledAssemblyScanning : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Hosting/When_endpoint_starts.cs b/src/NServiceBus.AcceptanceTests/Core/Hosting/When_endpoint_starts.cs
index b4f2ffc475c..b2850d3b92f 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Hosting/When_endpoint_starts.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Hosting/When_endpoint_starts.cs
@@ -30,9 +30,9 @@ await Scenario.Define()
var startupDiagnoticsFileName = $"{endpointName}-configuration.txt";
var pathToFile = Path.Combine(basePath, startupDiagnoticsFileName);
- Assert.True(File.Exists(pathToFile));
+ Assert.That(File.Exists(pathToFile), Is.True);
- TestContext.WriteLine(File.ReadAllText(pathToFile));
+ await TestContext.Out.WriteLineAsync(await File.ReadAllTextAsync(pathToFile));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Hosting/When_failing_write_startup_diagnostics.cs b/src/NServiceBus.AcceptanceTests/Core/Hosting/When_failing_write_startup_diagnostics.cs
index 27201b38d62..9af1eb13b1a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Hosting/When_failing_write_startup_diagnostics.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Hosting/When_failing_write_startup_diagnostics.cs
@@ -17,7 +17,7 @@ public async Task Should_still_start_endpoint()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.True(context.Logs.Any(l => l.Message.Contains("Diagnostics write failed")));
+ Assert.That(context.Logs.Any(l => l.Message.Contains("Diagnostics write failed")), Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Installers/When_creating_queues.cs b/src/NServiceBus.AcceptanceTests/Core/Installers/When_creating_queues.cs
index 8d62a1094d2..6a6fd1f26eb 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Installers/When_creating_queues.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Installers/When_creating_queues.cs
@@ -25,7 +25,7 @@ public async Task Should_not_create_queues_when_installers_disabled()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.IsFalse(context.SetupInfrastructure);
+ Assert.That(context.SetupInfrastructure, Is.False);
}
[Test]
@@ -39,7 +39,7 @@ public async Task Should_create_queues_when_installers_enabled()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.IsTrue(context.SetupInfrastructure);
+ Assert.That(context.SetupInfrastructure, Is.True);
}
[Test]
@@ -62,10 +62,10 @@ public async Task Should_not_create_when_sendonly()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.IsTrue(context.SetupInfrastructure);
+ Assert.That(context.SetupInfrastructure, Is.True);
- CollectionAssert.DoesNotContain(context.SendingAddresses, errorQueueName);
- CollectionAssert.DoesNotContain(context.SendingAddresses, auditQueueName);
+ Assert.That(context.SendingAddresses, Has.No.Member(errorQueueName));
+ Assert.That(context.SendingAddresses, Has.No.Member(auditQueueName));
}
[Test]
@@ -84,22 +84,22 @@ public async Task Should_pass_receive_and_send_queue_addresses()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.IsTrue(context.SetupInfrastructure);
+ Assert.That(context.SetupInfrastructure, Is.True);
- CollectionAssert.AreEqual(new List
+ Assert.That(context.SendingAddresses, Is.EqualTo(new List
{
"myAudit",
"error"
- }, context.SendingAddresses);
+ }).AsCollection);
var endpointName = AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(Endpoint));
- CollectionAssert.AreEquivalent(new List<(string basename, string discriminator)>
+ Assert.That(context.ReceivingAddresses.Select(a => (a.BaseAddress, a.Discriminator)), Is.EquivalentTo(new List<(string basename, string discriminator)>
{
(endpointName, null), //main input queue
(endpointName, instanceDiscriminator), // instance-specific queue
("MySatelliteAddress", null)
- }, context.ReceivingAddresses.Select(a => (a.BaseAddress, a.Discriminator)));
+ }));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Installers/When_installers_enabled.cs b/src/NServiceBus.AcceptanceTests/Core/Installers/When_installers_enabled.cs
index 86bc45eea49..45a83fef16f 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Installers/When_installers_enabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Installers/When_installers_enabled.cs
@@ -17,7 +17,7 @@ public async Task Should_run_installers()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.IsTrue(context.InstallerCalled);
+ Assert.That(context.InstallerCalled, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Installers/When_installers_not_enabled.cs b/src/NServiceBus.AcceptanceTests/Core/Installers/When_installers_not_enabled.cs
index 13295687d96..882f4675b18 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Installers/When_installers_not_enabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Installers/When_installers_not_enabled.cs
@@ -18,7 +18,7 @@ public async Task Should_not_run_installers()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.IsFalse(context.InstallerCalled);
+ Assert.That(context.InstallerCalled, Is.False);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Installers/When_installing_endpoint.cs b/src/NServiceBus.AcceptanceTests/Core/Installers/When_installing_endpoint.cs
index 47e4055bbe1..fc050e05a48 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Installers/When_installing_endpoint.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Installers/When_installing_endpoint.cs
@@ -20,14 +20,17 @@ public async Task Should_only_execute_setup_and_complete()
.WithComponent(new InstallationOnlyComponent())
.Run();
- Assert.IsTrue(context.InstallerCalled, "Should run installers");
- Assert.IsTrue(context.FeatureSetupCalled, "Should initialize Features");
- Assert.IsFalse(context.FeatureStartupTaskCalled, "Should not start FeatureStartupTasks");
- CollectionAssert.AreEqual(context.TransportStartupSequence, new string[]
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.InstallerCalled, Is.True, "Should run installers");
+ Assert.That(context.FeatureSetupCalled, Is.True, "Should initialize Features");
+ Assert.That(context.FeatureStartupTaskCalled, Is.False, "Should not start FeatureStartupTasks");
+ });
+ Assert.That(new string[]
{
$"{nameof(TransportDefinition)}.{nameof(TransportDefinition.Initialize)}",
$"{nameof(IMessageReceiver)}.{nameof(IMessageReceiver.Initialize)} for receiver Main",
- }, "Should not start the receivers");
+ }, Is.EqualTo(context.TransportStartupSequence).AsCollection, "Should not start the receivers");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/JsonSerializer/When_deserializing_interface_message.cs b/src/NServiceBus.AcceptanceTests/Core/JsonSerializer/When_deserializing_interface_message.cs
index a57e7704dfe..6b114e954d9 100644
--- a/src/NServiceBus.AcceptanceTests/Core/JsonSerializer/When_deserializing_interface_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/JsonSerializer/When_deserializing_interface_message.cs
@@ -16,7 +16,7 @@ public async Task Should_work()
.Done(c => c.GotTheMessage)
.Run();
- Assert.True(context.GotTheMessage);
+ Assert.That(context.GotTheMessage, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/JsonSerializer/When_using_system_json_serializer.cs b/src/NServiceBus.AcceptanceTests/Core/JsonSerializer/When_using_system_json_serializer.cs
index 44f180db61e..297af854c59 100644
--- a/src/NServiceBus.AcceptanceTests/Core/JsonSerializer/When_using_system_json_serializer.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/JsonSerializer/When_using_system_json_serializer.cs
@@ -16,7 +16,7 @@ public async Task Should_work()
.Done(c => c.GotTheMessage)
.Run();
- Assert.True(context.GotTheMessage);
+ Assert.That(context.GotTheMessage, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_defining_outgoing_message_mutators.cs b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_defining_outgoing_message_mutators.cs
index 74ec8dd76da..63d66852247 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_defining_outgoing_message_mutators.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_defining_outgoing_message_mutators.cs
@@ -16,9 +16,12 @@ public async Task Should_be_applied_to_outgoing_messages()
.Done(c => c.MessageProcessed)
.Run();
- Assert.True(context.TransportMutatorCalled);
- Assert.True(context.OtherTransportMutatorCalled);
- Assert.True(context.MessageMutatorCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.TransportMutatorCalled, Is.True);
+ Assert.That(context.OtherTransportMutatorCalled, Is.True);
+ Assert.That(context.MessageMutatorCalled, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_incoming_mutator_changes_message_type.cs b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_incoming_mutator_changes_message_type.cs
index 9a7c0f6386a..1526c71ef1f 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_incoming_mutator_changes_message_type.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_incoming_mutator_changes_message_type.cs
@@ -17,10 +17,13 @@ public async Task Should_invoke_handlers_for_new_message_type()
.Done(c => c.NewMessageHandlerCalled || c.OriginalMessageHandlerCalled)
.Run();
- Assert.IsTrue(context.NewMessageHandlerCalled);
- Assert.IsTrue(context.NewMessageSagaHandlerCalled);
- Assert.IsFalse(context.OriginalMessageHandlerCalled);
- Assert.IsFalse(context.OriginalMessageSagaHandlerCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.NewMessageHandlerCalled, Is.True);
+ Assert.That(context.NewMessageSagaHandlerCalled, Is.True);
+ Assert.That(context.OriginalMessageHandlerCalled, Is.False);
+ Assert.That(context.OriginalMessageSagaHandlerCalled, Is.False);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_mutating.cs b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_mutating.cs
index 8b77d721265..0bd1a43c026 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_mutating.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_mutating.cs
@@ -19,7 +19,7 @@ public async Task Context_should_be_populated()
.Done(c => c.WasCalled)
.Run(TimeSpan.FromHours(1));
- Assert.True(context.WasCalled, "The message handler should be called");
+ Assert.That(context.WasCalled, Is.True, "The message handler should be called");
}
public class Context : ScenarioContext
@@ -77,37 +77,55 @@ public class Mutator :
{
public Task MutateIncoming(MutateIncomingMessageContext context)
{
- Assert.IsNotEmpty(context.Headers);
- Assert.IsNotNull(context.Message);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Headers, Is.Not.Empty);
+ Assert.That(context.Message, Is.Not.Null);
+ });
return Task.CompletedTask;
}
public Task MutateIncoming(MutateIncomingTransportMessageContext context)
{
- Assert.IsNotEmpty(context.Headers);
- Assert.IsNotNull(context.Body);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Headers, Is.Not.Empty);
+ Assert.That(context.Body, Is.Not.EqualTo(default(ReadOnlyMemory)));
+ });
return Task.CompletedTask;
}
public Task MutateOutgoing(MutateOutgoingMessageContext context)
{
- Assert.IsNotEmpty(context.OutgoingHeaders);
- Assert.IsNotNull(context.OutgoingMessage);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.OutgoingHeaders, Is.Not.Empty);
+ Assert.That(context.OutgoingMessage, Is.Not.Null);
+ });
context.TryGetIncomingHeaders(out var incomingHeaders);
context.TryGetIncomingMessage(out var incomingMessage);
- Assert.IsNotEmpty(incomingHeaders);
- Assert.IsNotNull(incomingMessage);
+ Assert.Multiple(() =>
+ {
+ Assert.That(incomingHeaders, Is.Not.Empty);
+ Assert.That(incomingMessage, Is.Not.Null);
+ });
return Task.CompletedTask;
}
public Task MutateOutgoing(MutateOutgoingTransportMessageContext context)
{
- Assert.IsNotEmpty(context.OutgoingHeaders);
- Assert.IsNotNull(context.OutgoingBody);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.OutgoingHeaders, Is.Not.Empty);
+ Assert.That(context.OutgoingBody, Is.Not.EqualTo(default(ReadOnlyMemory)));
+ });
context.TryGetIncomingHeaders(out var incomingHeaders);
context.TryGetIncomingMessage(out var incomingMessage);
- Assert.IsNotEmpty(incomingHeaders);
- Assert.IsNotNull(incomingMessage);
+ Assert.Multiple(() =>
+ {
+ Assert.That(incomingHeaders, Is.Not.Empty);
+ Assert.That(incomingMessage, Is.Not.Null);
+ });
return Task.CompletedTask;
}
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_outgoing_mutator_replaces_instance.cs b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_outgoing_mutator_replaces_instance.cs
index ef5b39607af..2274a606e89 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_outgoing_mutator_replaces_instance.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_outgoing_mutator_replaces_instance.cs
@@ -16,8 +16,11 @@ public async Task Message_sent_should_be_new_instance()
.Done(c => c.V2MessageReceived)
.Run();
- Assert.IsTrue(context.V2MessageReceived);
- Assert.IsFalse(context.V1MessageReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.V2MessageReceived, Is.True);
+ Assert.That(context.V1MessageReceived, Is.False);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_using_outgoing_tm_mutator.cs b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_using_outgoing_tm_mutator.cs
index 76f9afadb45..a69f88f1176 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Mutators/When_using_outgoing_tm_mutator.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Mutators/When_using_outgoing_tm_mutator.cs
@@ -17,8 +17,11 @@ public async Task Should_be_able_to_update_message()
.Done(c => c.MessageProcessed)
.Run();
- Assert.True(context.CanAddHeaders);
- Assert.AreEqual("SomeValue", context.MutatedPropertyValue, "Mutator should be able to mutate body.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.CanAddHeaders, Is.True);
+ Assert.That(context.MutatedPropertyValue, Is.EqualTo("SomeValue"), "Mutator should be able to mutate body.");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/ActivityTestingExtensions.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/ActivityTestingExtensions.cs
index 801a79d9577..2df05a22e0a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/ActivityTestingExtensions.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/ActivityTestingExtensions.cs
@@ -9,8 +9,11 @@ public static class ActivityTestingExtensions
{
public static void VerifyTag(this ImmutableDictionary tags, string tagName, string expectedValue)
{
- Assert.IsTrue(tags.TryGetValue(tagName, out var tagValue), $"Tags should contain key '{tagName}'");
- Assert.AreEqual(expectedValue, tagValue, $"Tag value with key '{tagName}' is incorrect");
+ Assert.Multiple(() =>
+ {
+ Assert.That(tags.TryGetValue(tagName, out var tagValue), Is.True, $"Tags should contain key '{tagName}'");
+ Assert.That(tagValue, Is.EqualTo(expectedValue), $"Tag value with key '{tagName}' is incorrect");
+ });
}
///
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Metrics/TestingMetricListener.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Metrics/TestingMetricListener.cs
index 01cce8da1dd..4940c0f472d 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Metrics/TestingMetricListener.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Metrics/TestingMetricListener.cs
@@ -19,7 +19,7 @@ public TestingMetricListener(string sourceName)
{
if (instrument.Meter.Name == sourceName)
{
- TestContext.WriteLine($"Subscribing to {instrument.Meter.Name}\\{instrument.Name}");
+ TestContext.Out.WriteLine($"Subscribing to {instrument.Meter.Name}\\{instrument.Name}");
listener.EnableMeasurementEvents(instrument);
}
}
@@ -30,7 +30,7 @@ public TestingMetricListener(string sourceName)
ReadOnlySpan> t,
object _) =>
{
- TestContext.WriteLine($"{instrument.Meter.Name}\\{instrument.Name}:{measurement}");
+ TestContext.Out.WriteLine($"{instrument.Meter.Name}\\{instrument.Name}:{measurement}");
var tags = t.ToArray();
ReportedMeters.AddOrUpdate(instrument.Name, measurement, (_, val) => val + measurement);
@@ -41,7 +41,7 @@ public TestingMetricListener(string sourceName)
ReadOnlySpan> t,
object _) =>
{
- TestContext.WriteLine($"{instrument.Meter.Name}\\{instrument.Name}:{measurement}");
+ TestContext.Out.WriteLine($"{instrument.Meter.Name}\\{instrument.Name}:{measurement}");
var tags = t.ToArray();
ReportedMeters.AddOrUpdate(instrument.Name, 1, (_, val) => val + 1);
Tags.AddOrUpdate(instrument.Name, _ => tags, (_, _) => tags);
@@ -67,12 +67,15 @@ public void AssertMetric(string metricName, long expected)
{
if (expected == 0)
{
- Assert.False(ReportedMeters.ContainsKey(metricName), $"Should not have '{metricName}' metric reported.");
+ Assert.That(ReportedMeters.ContainsKey(metricName), Is.False, $"Should not have '{metricName}' metric reported.");
}
else
{
- Assert.True(ReportedMeters.ContainsKey(metricName), $"'{metricName}' metric was not reported.");
- Assert.AreEqual(expected, ReportedMeters[metricName]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ReportedMeters.ContainsKey(metricName), Is.True, $"'{metricName}' metric was not reported.");
+ Assert.That(ReportedMeters[metricName], Is.EqualTo(expected));
+ });
}
}
@@ -98,7 +101,7 @@ public void AssertTags(string metricName, Dictionary expectedTag
foreach (var kvp in expectedTags)
{
var actualTagValue = AssertTagKeyExists(metricName, kvp.Key);
- Assert.AreEqual(kvp.Value, actualTagValue);
+ Assert.That(actualTagValue, Is.EqualTo(kvp.Value));
}
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Metrics/When_message_is_processed_successfully.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Metrics/When_message_is_processed_successfully.cs
index 03418a84f8c..c0892442028 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Metrics/When_message_is_processed_successfully.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Metrics/When_message_is_processed_successfully.cs
@@ -107,10 +107,13 @@ public async Task Should_only_tag_most_concrete_type_on_metric()
var fetchedEndpoint = metricsListener.AssertTagKeyExists("nservicebus.messaging.fetches", "nservicebus.queue");
- Assert.AreEqual(Conventions.EndpointNamingConvention(typeof(EndpointWithMetrics)), successEndpoint);
- Assert.AreEqual(Conventions.EndpointNamingConvention(typeof(EndpointWithMetrics)), fetchedEndpoint);
- Assert.AreEqual(typeof(OutgoingWithComplexHierarchyMessage).FullName, successType);
- Assert.AreEqual(typeof(EndpointWithMetrics.ComplexMessageHandler).FullName, successHandlerType);
+ Assert.Multiple(() =>
+ {
+ Assert.That(successEndpoint, Is.EqualTo(Conventions.EndpointNamingConvention(typeof(EndpointWithMetrics))));
+ Assert.That(fetchedEndpoint, Is.EqualTo(Conventions.EndpointNamingConvention(typeof(EndpointWithMetrics))));
+ Assert.That(successType, Is.EqualTo(typeof(OutgoingWithComplexHierarchyMessage).FullName));
+ Assert.That(successHandlerType, Is.EqualTo(typeof(EndpointWithMetrics.ComplexMessageHandler).FullName));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/TestingActivityListener.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/TestingActivityListener.cs
index 74725568e3c..a5fdb5ce06a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/TestingActivityListener.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/TestingActivityListener.cs
@@ -48,7 +48,7 @@ public void Dispose()
public void VerifyAllActivitiesCompleted()
{
- Assert.AreEqual(StartedActivities.Count, CompletedActivities.Count, "all started activities should be completed");
+ Assert.That(CompletedActivities, Has.Count.EqualTo(StartedActivities.Count), "all started activities should be completed");
}
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_ambient_trace_in_message_session.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_ambient_trace_in_message_session.cs
index 10263f4a09b..324d18a7a68 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_ambient_trace_in_message_session.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_ambient_trace_in_message_session.cs
@@ -37,12 +37,15 @@ public async Task Should_attach_to_ambient_trace()
var outgoingMessageActivity = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities().Single();
var incomingMessageActivity = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities().Single();
- Assert.AreEqual(context.WrapperActivityId, outgoingMessageActivity.ParentId, "outgoing message should be connected to the ambient span");
- Assert.AreEqual(context.WrapperActivityRootId, outgoingMessageActivity.RootId, "outgoing message should be connected to the ambient trace");
- Assert.AreEqual(wrapperActivityTraceState, outgoingMessageActivity.TraceStateString, "ambient trace state should be floated to outgoing message span");
- Assert.AreEqual(outgoingMessageActivity.Id, incomingMessageActivity.ParentId, "received message should be connected to send operation span");
- Assert.AreEqual(context.WrapperActivityRootId, incomingMessageActivity.RootId, "received message should be connected to the ambient trace");
- Assert.AreEqual(wrapperActivityTraceState, incomingMessageActivity.TraceStateString, "ambient trace state should be floated to incoming message span");
+ Assert.Multiple(() =>
+ {
+ Assert.That(outgoingMessageActivity.ParentId, Is.EqualTo(context.WrapperActivityId), "outgoing message should be connected to the ambient span");
+ Assert.That(outgoingMessageActivity.RootId, Is.EqualTo(context.WrapperActivityRootId), "outgoing message should be connected to the ambient trace");
+ Assert.That(outgoingMessageActivity.TraceStateString, Is.EqualTo(wrapperActivityTraceState), "ambient trace state should be floated to outgoing message span");
+ Assert.That(incomingMessageActivity.ParentId, Is.EqualTo(outgoingMessageActivity.Id), "received message should be connected to send operation span");
+ Assert.That(incomingMessageActivity.RootId, Is.EqualTo(context.WrapperActivityRootId), "received message should be connected to the ambient trace");
+ Assert.That(incomingMessageActivity.TraceStateString, Is.EqualTo(wrapperActivityTraceState), "ambient trace state should be floated to incoming message span");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_ambient_trace_in_pipeline.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_ambient_trace_in_pipeline.cs
index ae739f339f3..e06d25a1f60 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_ambient_trace_in_pipeline.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_ambient_trace_in_pipeline.cs
@@ -24,11 +24,14 @@ public async Task Should_attach_to_ambient_trace()
var handlerActivity = NServicebusActivityListener.CompletedActivities.GetInvokedHandlerActivities().First();
var sendFromHandlerActivity = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities().Last();
- Assert.AreEqual(context.AmbientActivityId, sendFromHandlerActivity.ParentId, "the outgoing message should be connected to the ambient span");
- Assert.AreEqual(context.AmbientActivityRootId, sendFromHandlerActivity.RootId, "outgoing and ambient activity should belong to same trace");
- Assert.AreEqual(ExpectedTraceState, sendFromHandlerActivity.TraceStateString, "outgoing activity should capture ambient trace state");
- Assert.AreEqual(handlerActivity.Id, context.AmbientActivityParentId, "the ambient activity should be connected to the handler span");
- Assert.AreEqual(handlerActivity.RootId, context.AmbientActivityRootId, "handler and ambient activity should belong to same trace");
+ Assert.Multiple(() =>
+ {
+ Assert.That(sendFromHandlerActivity.ParentId, Is.EqualTo(context.AmbientActivityId), "the outgoing message should be connected to the ambient span");
+ Assert.That(sendFromHandlerActivity.RootId, Is.EqualTo(context.AmbientActivityRootId), "outgoing and ambient activity should belong to same trace");
+ Assert.That(sendFromHandlerActivity.TraceStateString, Is.EqualTo(ExpectedTraceState), "outgoing activity should capture ambient trace state");
+ Assert.That(context.AmbientActivityParentId, Is.EqualTo(handlerActivity.Id), "the ambient activity should be connected to the handler span");
+ Assert.That(context.AmbientActivityRootId, Is.EqualTo(handlerActivity.RootId), "handler and ambient activity should belong to same trace");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_event_has_trace.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_event_has_trace.cs
index d9b81ef612b..655d1cfd538 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_event_has_trace.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_event_has_trace.cs
@@ -30,12 +30,15 @@ public async Task Should_correlate_trace_from_publish()
var incomingActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
var outgoingActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(2, incomingActivities.Count, "2 messages are received as part of this test (event + reply)");
- Assert.AreEqual(1, outgoingActivities.Count, "1 message is sent as part of this test (reply)");
- Assert.AreEqual(1, NServicebusActivityListener.CompletedActivities.GetPublishEventActivities().Count, "1 event is published as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(incomingActivities, Has.Count.EqualTo(2), "2 messages are received as part of this test (event + reply)");
+ Assert.That(outgoingActivities, Has.Count.EqualTo(1), "1 message is sent as part of this test (reply)");
+ Assert.That(NServicebusActivityListener.CompletedActivities.GetPublishEventActivities(), Has.Count.EqualTo(1), "1 event is published as part of this test");
- Assert.IsTrue(incomingActivities.Concat(outgoingActivities)
- .All(a => a.RootId == incomingActivities[0].RootId), "all activities should belong to the same trace");
+ Assert.That(incomingActivities.Concat(outgoingActivities)
+ .All(a => a.RootId == incomingActivities[0].RootId), Is.True, "all activities should belong to the same trace");
+ });
}
public class Context : ScenarioContext
{
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_baggage_header.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_baggage_header.cs
index 5a44e3fe769..0e028ad265c 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_baggage_header.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_baggage_header.cs
@@ -24,7 +24,7 @@ public async Task Should_propagate_baggage_to_activity()
.Run();
var incomingMessageTraces = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
- Assert.AreEqual(1, incomingMessageTraces.Count, "There should be 1 message received");
+ Assert.That(incomingMessageTraces, Has.Count.EqualTo(1), "There should be 1 message received");
var incomingMessageTrace = incomingMessageTraces.Single();
VerifyBaggageItem("key1", "value1");
@@ -33,8 +33,8 @@ public async Task Should_propagate_baggage_to_activity()
void VerifyBaggageItem(string key, string expectedValue)
{
var baggageItemValue = incomingMessageTrace.GetBaggageItem(key);
- Assert.IsNotNull(baggageItemValue, $"Baggage item {key} should be populated");
- Assert.AreEqual(expectedValue, baggageItemValue, $"Baggage item {key} is not set correctly");
+ Assert.That(baggageItemValue, Is.Not.Null, $"Baggage item {key} should be populated");
+ Assert.That(baggageItemValue, Is.EqualTo(expectedValue), $"Baggage item {key} is not set correctly");
}
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_no_trace.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_no_trace.cs
index 96a1e71572c..f1068f77b18 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_no_trace.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_no_trace.cs
@@ -20,7 +20,7 @@ public async Task Should_start_new_trace()
.Run();
var incomingMessageActivity = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities().Single();
- Assert.AreEqual(null, incomingMessageActivity.ParentId, "should start a trace when incoming message isn't part of a trace already");
+ Assert.That(incomingMessageActivity.ParentId, Is.EqualTo(null), "should start a trace when incoming message isn't part of a trace already");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_trace.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_trace.cs
index 71761c7f7f1..4446131102d 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_trace.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_has_trace.cs
@@ -22,24 +22,30 @@ public async Task Should_correlate_trace_from_send()
var incomingMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
var outgoingMessageActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(2, incomingMessageActivities.Count, "2 messages are received as part of this test");
- Assert.AreEqual(2, outgoingMessageActivities.Count, "2 messages are sent as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(incomingMessageActivities, Has.Count.EqualTo(2), "2 messages are received as part of this test");
+ Assert.That(outgoingMessageActivities, Has.Count.EqualTo(2), "2 messages are sent as part of this test");
+ });
var sendRequest = outgoingMessageActivities[0];
var receiveRequest = incomingMessageActivities[0];
var sendReply = outgoingMessageActivities[1];
var receiveReply = incomingMessageActivities[1];
- Assert.AreEqual(sendRequest.RootId, receiveRequest.RootId, "first send operation is the root activity");
- Assert.AreEqual(sendRequest.Id, receiveRequest.ParentId, "first incoming message is correlated to the first send operation");
- Assert.AreEqual(sendRequest.RootId, sendReply.RootId, "first send operation is the root activity");
- Assert.AreEqual(sendReply.Id, receiveReply.ParentId, "second incoming message is correlated to the second send operation");
- Assert.AreEqual(sendRequest.RootId, receiveReply.RootId, "first send operation is the root activity");
-
- Assert.AreEqual(context.IncomingMessageId, sendRequest.Tags.ToImmutableDictionary()["nservicebus.message_id"]);
- Assert.AreEqual(context.IncomingMessageId, receiveRequest.Tags.ToImmutableDictionary()["nservicebus.message_id"]);
- Assert.AreEqual(context.ReplyMessageId, sendReply.Tags.ToImmutableDictionary()["nservicebus.message_id"]);
- Assert.AreEqual(context.ReplyMessageId, receiveReply.Tags.ToImmutableDictionary()["nservicebus.message_id"]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(receiveRequest.RootId, Is.EqualTo(sendRequest.RootId), "first send operation is the root activity");
+ Assert.That(receiveRequest.ParentId, Is.EqualTo(sendRequest.Id), "first incoming message is correlated to the first send operation");
+ Assert.That(sendReply.RootId, Is.EqualTo(sendRequest.RootId), "first send operation is the root activity");
+ Assert.That(receiveReply.ParentId, Is.EqualTo(sendReply.Id), "second incoming message is correlated to the second send operation");
+ Assert.That(receiveReply.RootId, Is.EqualTo(sendRequest.RootId), "first send operation is the root activity");
+
+ Assert.That(sendRequest.Tags.ToImmutableDictionary()["nservicebus.message_id"], Is.EqualTo(context.IncomingMessageId));
+ Assert.That(receiveRequest.Tags.ToImmutableDictionary()["nservicebus.message_id"], Is.EqualTo(context.IncomingMessageId));
+ Assert.That(sendReply.Tags.ToImmutableDictionary()["nservicebus.message_id"], Is.EqualTo(context.ReplyMessageId));
+ Assert.That(receiveReply.Tags.ToImmutableDictionary()["nservicebus.message_id"], Is.EqualTo(context.ReplyMessageId));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_moved_to_error_queue.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_moved_to_error_queue.cs
index ac24c594685..f7b04ca90ff 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_moved_to_error_queue.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_moved_to_error_queue.cs
@@ -19,8 +19,11 @@ public async Task Should_add_start_new_trace_header()
.Run();
var failedMessage = context.FailedMessages.First().Value.First();
- Assert.IsTrue(failedMessage.Headers.ContainsKey(Headers.StartNewTrace));
- Assert.AreEqual(bool.TrueString, failedMessage.Headers[Headers.StartNewTrace]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(failedMessage.Headers.ContainsKey(Headers.StartNewTrace), Is.True);
+ Assert.That(failedMessage.Headers[Headers.StartNewTrace], Is.EqualTo(bool.TrueString));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_was_delayed.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_was_delayed.cs
index 5b2c0c65c6d..6fa69c676f0 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_was_delayed.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_incoming_message_was_delayed.cs
@@ -29,23 +29,29 @@ public async Task By_sendoptions_Should_create_new_trace_and_link_to_send()
var incomingMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
var outgoingMessageActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(2, incomingMessageActivities.Count, "2 messages are received as part of this test");
- Assert.AreEqual(2, outgoingMessageActivities.Count, "2 messages are sent as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(incomingMessageActivities, Has.Count.EqualTo(2), "2 messages are received as part of this test");
+ Assert.That(outgoingMessageActivities, Has.Count.EqualTo(2), "2 messages are sent as part of this test");
+ });
var sendRequest = outgoingMessageActivities[0];
var receiveRequest = incomingMessageActivities[0];
var sendReply = outgoingMessageActivities[1];
var receiveReply = incomingMessageActivities[1];
- Assert.AreNotEqual(sendRequest.RootId, receiveRequest.RootId, "send and receive operations are part of different root activities");
- Assert.IsNull(receiveRequest.ParentId, "first incoming message does not have a parent, it's a root");
- Assert.AreNotEqual(sendRequest.RootId, sendReply.RootId, "first send operation is different than the root activity of the reply");
- Assert.AreEqual(sendReply.Id, receiveReply.ParentId, "second incoming message is correlated to the second send operation");
- Assert.AreEqual(sendReply.RootId, receiveReply.RootId, "second incoming message is the root activity");
+ Assert.Multiple(() =>
+ {
+ Assert.That(receiveRequest.RootId, Is.Not.EqualTo(sendRequest.RootId), "send and receive operations are part of different root activities");
+ Assert.That(receiveRequest.ParentId, Is.Null, "first incoming message does not have a parent, it's a root");
+ Assert.That(sendReply.RootId, Is.Not.EqualTo(sendRequest.RootId), "first send operation is different than the root activity of the reply");
+ Assert.That(receiveReply.ParentId, Is.EqualTo(sendReply.Id), "second incoming message is correlated to the second send operation");
+ Assert.That(receiveReply.RootId, Is.EqualTo(sendReply.RootId), "second incoming message is the root activity");
+ });
ActivityLink link = receiveRequest.Links.FirstOrDefault();
- Assert.IsNotNull(link, "second receive has a link");
- Assert.AreEqual(sendRequest.TraceId, link.Context.TraceId, "second receive is linked to send operation");
+ Assert.That(link, Is.Not.EqualTo(default(ActivityLink)), "second receive has a link");
+ Assert.That(link.Context.TraceId, Is.EqualTo(sendRequest.TraceId), "second receive is linked to send operation");
}
[Test]
@@ -61,21 +67,27 @@ public async Task By_retry_Should_create_new_trace_and_link_to_send()
var incomingMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
var outgoingMessageActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(2, incomingMessageActivities.Count, "2 messages are received as part of this test (2 attempts)");
- Assert.AreEqual(1, outgoingMessageActivities.Count, "1 message sent as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(incomingMessageActivities, Has.Count.EqualTo(2), "2 messages are received as part of this test (2 attempts)");
+ Assert.That(outgoingMessageActivities, Has.Count.EqualTo(1), "1 message sent as part of this test");
+ });
var sendRequest = outgoingMessageActivities[0];
var firstAttemptReceiveRequest = incomingMessageActivities[0];
var secondAttemptReceiveRequest = incomingMessageActivities[1];
- Assert.AreEqual(sendRequest.RootId, firstAttemptReceiveRequest.RootId, "first send operation is the root activity");
- Assert.AreEqual(sendRequest.Id, firstAttemptReceiveRequest.ParentId, "first incoming message is correlated to the first send operation");
+ Assert.Multiple(() =>
+ {
+ Assert.That(firstAttemptReceiveRequest.RootId, Is.EqualTo(sendRequest.RootId), "first send operation is the root activity");
+ Assert.That(firstAttemptReceiveRequest.ParentId, Is.EqualTo(sendRequest.Id), "first incoming message is correlated to the first send operation");
- Assert.AreNotEqual(sendRequest.RootId, secondAttemptReceiveRequest.RootId, "send and 2nd receive operations are part of different root activities");
- Assert.IsNull(secondAttemptReceiveRequest.ParentId, "first incoming message does not have a parent, it's a root");
+ Assert.That(secondAttemptReceiveRequest.RootId, Is.Not.EqualTo(sendRequest.RootId), "send and 2nd receive operations are part of different root activities");
+ Assert.That(secondAttemptReceiveRequest.ParentId, Is.Null, "first incoming message does not have a parent, it's a root");
+ });
ActivityLink link = secondAttemptReceiveRequest.Links.FirstOrDefault();
- Assert.IsNotNull(link, "second receive has a link");
- Assert.AreEqual(sendRequest.TraceId, link.Context.TraceId, "second receive is linked to send operation");
+ Assert.That(link, Is.Not.EqualTo(default(ActivityLink)), "second receive has a link");
+ Assert.That(link.Context.TraceId, Is.EqualTo(sendRequest.TraceId), "second receive is linked to send operation");
}
[Test]
@@ -89,8 +101,11 @@ public async Task By_saga_timeout_Should_create_new_trace_and_link_to_send()
var incomingMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
var outgoingMessageActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(3, incomingMessageActivities.Count, "3 messages are received as part of this test");
- Assert.AreEqual(3, outgoingMessageActivities.Count, "3 messages are sent as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(incomingMessageActivities, Has.Count.EqualTo(3), "3 messages are received as part of this test");
+ Assert.That(outgoingMessageActivities, Has.Count.EqualTo(3), "3 messages are sent as part of this test");
+ });
var startSagaSend = outgoingMessageActivities[0];
var startSagaReceive = incomingMessageActivities[0];
@@ -99,19 +114,25 @@ public async Task By_saga_timeout_Should_create_new_trace_and_link_to_send()
var completeSagaSend = outgoingMessageActivities[2];
var completeSagaReceive = incomingMessageActivities[2];
- Assert.AreEqual(startSagaSend.RootId, startSagaReceive.RootId, "send start saga operation is the root activity of the receive start saga operation");
- Assert.AreEqual(startSagaSend.Id, startSagaReceive.ParentId, "start saga receive operation is child of the start saga send operation");
- Assert.AreEqual(startSagaSend.RootId, timeoutSend.RootId, "timeout send operation is part of the start saga operation root");
+ Assert.Multiple(() =>
+ {
+ Assert.That(startSagaReceive.RootId, Is.EqualTo(startSagaSend.RootId), "send start saga operation is the root activity of the receive start saga operation");
+ Assert.That(startSagaReceive.ParentId, Is.EqualTo(startSagaSend.Id), "start saga receive operation is child of the start saga send operation");
+ Assert.That(timeoutSend.RootId, Is.EqualTo(startSagaSend.RootId), "timeout send operation is part of the start saga operation root");
- Assert.AreNotEqual(timeoutSend.RootId, timeoutReceive.RootId, "timeout send and receive operations are part of different root activities");
- Assert.IsNull(timeoutReceive.ParentId, "timeout receive operation does not have a parent, it's a root");
+ Assert.That(timeoutReceive.RootId, Is.Not.EqualTo(timeoutSend.RootId), "timeout send and receive operations are part of different root activities");
+ Assert.That(timeoutReceive.ParentId, Is.Null, "timeout receive operation does not have a parent, it's a root");
+ });
ActivityLink timeoutReceiveLink = timeoutReceive.Links.FirstOrDefault();
- Assert.IsNotNull(timeoutReceiveLink, "timeout receive operation is linked");
- Assert.AreEqual(timeoutSend.TraceId, timeoutReceiveLink.Context.TraceId, "imeout receive operation links to the timeout send operation");
+ Assert.That(timeoutReceiveLink, Is.Not.EqualTo(default(ActivityLink)), "timeout receive operation is linked");
+ Assert.Multiple(() =>
+ {
+ Assert.That(timeoutReceiveLink.Context.TraceId, Is.EqualTo(timeoutSend.TraceId), "imeout receive operation links to the timeout send operation");
- Assert.AreEqual(timeoutReceive.RootId, completeSagaSend.RootId, "timeout receive operation is the root of the complete saga send operation");
- Assert.AreEqual(timeoutReceive.RootId, completeSagaReceive.RootId, "timeout receive operation is the root of the complete saga receive operation");
- Assert.AreEqual(completeSagaSend.Id, completeSagaReceive.ParentId, "complete saga send operation is the parent of the complete saga receive operation");
+ Assert.That(completeSagaSend.RootId, Is.EqualTo(timeoutReceive.RootId), "timeout receive operation is the root of the complete saga send operation");
+ Assert.That(completeSagaReceive.RootId, Is.EqualTo(timeoutReceive.RootId), "timeout receive operation is the root of the complete saga receive operation");
+ Assert.That(completeSagaReceive.ParentId, Is.EqualTo(completeSagaSend.Id), "complete saga send operation is the parent of the complete saga receive operation");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_outgoing_activity_has_baggage.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_outgoing_activity_has_baggage.cs
index 11ad106ad96..ddd458b8bef 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_outgoing_activity_has_baggage.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_outgoing_activity_has_baggage.cs
@@ -34,7 +34,7 @@ public async Task Should_propagate_baggage_to_headers()
.Done(ctx => ctx.MessageReceived)
.Run();
- Assert.AreEqual("key2=value2,key1=value1", context.BaggageHeader);
+ Assert.That(context.BaggageHeader, Is.EqualTo("key2=value2,key1=value1"));
}
class TestEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_fails.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_fails.cs
index 0412972693e..ec404ad1262 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_fails.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_fails.cs
@@ -19,19 +19,25 @@ public async Task Should_mark_span_as_failed()
.When(s => s.SendLocal(new FailingMessage())))
.Done(c => c.HandlerInvoked).Run();
- Assert.AreEqual(1, context.FailedMessages.Count, "the message should have failed");
+ Assert.That(context.FailedMessages, Has.Count.EqualTo(1), "the message should have failed");
Activity failedPipelineActivity = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities().Single();
- Assert.AreEqual(ActivityStatusCode.Error, failedPipelineActivity.Status);
- Assert.AreEqual(ErrorMessage, failedPipelineActivity.StatusDescription);
+ Assert.Multiple(() =>
+ {
+ Assert.That(failedPipelineActivity.Status, Is.EqualTo(ActivityStatusCode.Error));
+ Assert.That(failedPipelineActivity.StatusDescription, Is.EqualTo(ErrorMessage));
+ });
var pipelineActivityTags = failedPipelineActivity.Tags.ToImmutableDictionary();
pipelineActivityTags.VerifyTag("otel.status_code", "ERROR");
pipelineActivityTags.VerifyTag("otel.status_description", ErrorMessage);
Activity failedHandlerActivity = NServicebusActivityListener.CompletedActivities.GetInvokedHandlerActivities().Single();
- Assert.AreEqual(ActivityStatusCode.Error, failedHandlerActivity.Status);
- Assert.AreEqual(ErrorMessage, failedHandlerActivity.StatusDescription);
+ Assert.Multiple(() =>
+ {
+ Assert.That(failedHandlerActivity.Status, Is.EqualTo(ActivityStatusCode.Error));
+ Assert.That(failedHandlerActivity.StatusDescription, Is.EqualTo(ErrorMessage));
+ });
var handlerActivityTags = failedHandlerActivity.Tags.ToImmutableDictionary();
handlerActivityTags.VerifyTag("otel.status_code", "ERROR");
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_incoming_message.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_incoming_message.cs
index 1396b17c391..66109ed6187 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_incoming_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_incoming_message.cs
@@ -20,14 +20,17 @@ public async Task Should_create_incoming_message_span()
.Run();
var incomingMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
- Assert.AreEqual(1, incomingMessageActivities.Count, "1 message is being processed");
+ Assert.That(incomingMessageActivities, Has.Count.EqualTo(1), "1 message is being processed");
var incomingActivity = incomingMessageActivities.Single();
- Assert.AreEqual(ActivityKind.Consumer, incomingActivity.Kind, "asynchronous receivers should use 'Consumer'");
+ Assert.Multiple(() =>
+ {
+ Assert.That(incomingActivity.Kind, Is.EqualTo(ActivityKind.Consumer), "asynchronous receivers should use 'Consumer'");
- Assert.AreEqual(ActivityStatusCode.Ok, incomingActivity.Status);
+ Assert.That(incomingActivity.Status, Is.EqualTo(ActivityStatusCode.Ok));
+ });
var destination = AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(ReceivingEndpoint));
- Assert.AreEqual("process message", incomingActivity.DisplayName);
+ Assert.That(incomingActivity.DisplayName, Is.EqualTo("process message"));
var incomingActivityTags = incomingActivity.Tags.ToImmutableDictionary();
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_message_with_multiple_handlers.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_message_with_multiple_handlers.cs
index 800526ccc2e..2bbffa0dab5 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_message_with_multiple_handlers.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_message_with_multiple_handlers.cs
@@ -21,22 +21,28 @@ public async Task Should_create_message_handler_spans()
var invokedHandlerActivities = NServicebusActivityListener.CompletedActivities.GetInvokedHandlerActivities();
var receivePipelineActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
- Assert.AreEqual(2, invokedHandlerActivities.Count, "a dedicated span for each handler should be created");
- Assert.AreEqual(1, receivePipelineActivities.Count, "the receive pipeline should be invoked once");
+ Assert.Multiple(() =>
+ {
+ Assert.That(invokedHandlerActivities, Has.Count.EqualTo(2), "a dedicated span for each handler should be created");
+ Assert.That(receivePipelineActivities, Has.Count.EqualTo(1), "the receive pipeline should be invoked once");
+ });
var recordedHandlerTypes = new HashSet();
foreach (var invokedHandlerActivity in invokedHandlerActivities)
{
var handlerTypeTag = invokedHandlerActivity.GetTagItem("nservicebus.handler.handler_type") as string;
- Assert.NotNull(handlerTypeTag, "Handler type tag should be set");
+ Assert.That(handlerTypeTag, Is.Not.Null, "Handler type tag should be set");
recordedHandlerTypes.Add(handlerTypeTag);
- Assert.AreEqual(receivePipelineActivities[0].Id, invokedHandlerActivity.ParentId);
- Assert.AreEqual(ActivityStatusCode.Ok, invokedHandlerActivity.Status);
+ Assert.Multiple(() =>
+ {
+ Assert.That(invokedHandlerActivity.ParentId, Is.EqualTo(receivePipelineActivities[0].Id));
+ Assert.That(invokedHandlerActivity.Status, Is.EqualTo(ActivityStatusCode.Ok));
+ });
}
- Assert.True(recordedHandlerTypes.Contains(typeof(ReceivingEndpoint.HandlerOne).FullName), "invocation of handler one should be traced");
- Assert.True(recordedHandlerTypes.Contains(typeof(ReceivingEndpoint.HandlerTwo).FullName), "invocation of handler two should be traced");
+ Assert.That(recordedHandlerTypes, Does.Contain(typeof(ReceivingEndpoint.HandlerOne).FullName), "invocation of handler one should be traced");
+ Assert.That(recordedHandlerTypes, Does.Contain(typeof(ReceivingEndpoint.HandlerTwo).FullName), "invocation of handler two should be traced");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_message_with_saga_handler.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_message_with_saga_handler.cs
index 450bee830c7..4d9c94a6e1a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_message_with_saga_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_processing_message_with_saga_handler.cs
@@ -23,7 +23,7 @@ public async Task Should_trace_saga_id()
var invokedHandlerActivities = NServicebusActivityListener.CompletedActivities.GetInvokedHandlerActivities();
- Assert.AreEqual(1, invokedHandlerActivities.Count, "One handlers should be invoked");
+ Assert.That(invokedHandlerActivities, Has.Count.EqualTo(1), "One handlers should be invoked");
var handlerActivityTags = invokedHandlerActivities.Single().Tags.ToImmutableDictionary();
handlerActivityTags.VerifyTag("nservicebus.handler.handler_type", typeof(TestEndpoint.TracedSaga).FullName);
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_publishing_messages.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_publishing_messages.cs
index 17a353e5c3c..921afaffdd8 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_publishing_messages.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_publishing_messages.cs
@@ -29,17 +29,20 @@ public async Task Should_create_outgoing_event_span()
.Run();
var outgoingEventActivities = NServicebusActivityListener.CompletedActivities.GetPublishEventActivities();
- Assert.AreEqual(1, outgoingEventActivities.Count, "1 event is being published");
+ Assert.That(outgoingEventActivities, Has.Count.EqualTo(1), "1 event is being published");
var publishedMessage = outgoingEventActivities.Single();
publishedMessage.VerifyUniqueTags();
- Assert.AreEqual("publish event", publishedMessage.DisplayName);
- Assert.IsNull(publishedMessage.ParentId, "publishes without ambient span should start a new trace");
+ Assert.Multiple(() =>
+ {
+ Assert.That(publishedMessage.DisplayName, Is.EqualTo("publish event"));
+ Assert.That(publishedMessage.ParentId, Is.Null, "publishes without ambient span should start a new trace");
+ });
var sentMessageTags = publishedMessage.Tags.ToImmutableDictionary();
sentMessageTags.VerifyTag("nservicebus.message_id", context.PublishedMessageId);
- Assert.IsNotNull(context.TraceParentHeader, "tracing header should be set on the published event");
+ Assert.That(context.TraceParentHeader, Is.Not.Null, "tracing header should be set on the published event");
}
[Test]
@@ -67,16 +70,22 @@ public async Task Should_create_child_on_receive_when_requested_via_options()
var publishMessageActivities = NServicebusActivityListener.CompletedActivities.GetPublishEventActivities();
var receiveMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
- Assert.AreEqual(1, publishMessageActivities.Count, "1 message is published as part of this test");
- Assert.AreEqual(1, receiveMessageActivities.Count, "1 message is received as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(publishMessageActivities, Has.Count.EqualTo(1), "1 message is published as part of this test");
+ Assert.That(receiveMessageActivities, Has.Count.EqualTo(1), "1 message is received as part of this test");
+ });
var publishRequest = publishMessageActivities[0];
var receiveRequest = receiveMessageActivities[0];
- Assert.AreEqual(publishRequest.RootId, receiveRequest.RootId, "publish and receive operations are part the same root activity");
- Assert.IsNotNull(receiveRequest.ParentId, "incoming message does have a parent");
+ Assert.Multiple(() =>
+ {
+ Assert.That(receiveRequest.RootId, Is.EqualTo(publishRequest.RootId), "publish and receive operations are part the same root activity");
+ Assert.That(receiveRequest.ParentId, Is.Not.Null, "incoming message does have a parent");
+ });
- CollectionAssert.IsEmpty(receiveRequest.Links, "receive does not have links");
+ Assert.That(receiveRequest.Links, Is.Empty, "receive does not have links");
}
[Test]
@@ -102,18 +111,24 @@ public async Task Should_create_new_linked_trace_on_receive_by_default()
var publishMessageActivities = NServicebusActivityListener.CompletedActivities.GetPublishEventActivities();
var receiveMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
- Assert.AreEqual(1, publishMessageActivities.Count, "1 message is published as part of this test");
- Assert.AreEqual(1, receiveMessageActivities.Count, "1 message is received as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(publishMessageActivities, Has.Count.EqualTo(1), "1 message is published as part of this test");
+ Assert.That(receiveMessageActivities, Has.Count.EqualTo(1), "1 message is received as part of this test");
+ });
var publishRequest = publishMessageActivities[0];
var receiveRequest = receiveMessageActivities[0];
- Assert.AreNotEqual(publishRequest.RootId, receiveRequest.RootId, "publish and receive operations are part of different root activities");
- Assert.IsNull(receiveRequest.ParentId, "incoming message does not have a parent, it's a root");
+ Assert.Multiple(() =>
+ {
+ Assert.That(receiveRequest.RootId, Is.Not.EqualTo(publishRequest.RootId), "publish and receive operations are part of different root activities");
+ Assert.That(receiveRequest.ParentId, Is.Null, "incoming message does not have a parent, it's a root");
+ });
ActivityLink link = receiveRequest.Links.FirstOrDefault();
- Assert.IsNotNull(link, "Receive has a link");
- Assert.AreEqual(publishRequest.TraceId, link.Context.TraceId, "receive is linked to publish operation");
+ Assert.That(link, Is.Not.EqualTo(default(ActivityLink)), "Receive has a link");
+ Assert.That(link.Context.TraceId, Is.EqualTo(publishRequest.TraceId), "receive is linked to publish operation");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_retrying_messages.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_retrying_messages.cs
index cd42887ea2d..3a3feee3722 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_retrying_messages.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_retrying_messages.cs
@@ -22,12 +22,18 @@ await Scenario.Define()
var receiveActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
var sendActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(1, sendActivities.Count);
- Assert.AreEqual(2, receiveActivities.Count, "the message should be processed twice due to one immediate retry");
- Assert.AreEqual(sendActivities[0].Id, receiveActivities[0].ParentId, "should not change parent span");
- Assert.AreEqual(sendActivities[0].Id, receiveActivities[1].ParentId, "should not change parent span");
+ Assert.Multiple(() =>
+ {
+ Assert.That(sendActivities, Has.Count.EqualTo(1));
+ Assert.That(receiveActivities, Has.Count.EqualTo(2), "the message should be processed twice due to one immediate retry");
+ });
+ Assert.Multiple(() =>
+ {
+ Assert.That(receiveActivities[0].ParentId, Is.EqualTo(sendActivities[0].Id), "should not change parent span");
+ Assert.That(receiveActivities[1].ParentId, Is.EqualTo(sendActivities[0].Id), "should not change parent span");
- Assert.IsTrue(sendActivities.Concat(receiveActivities).All(a => a.TraceId == sendActivities[0].TraceId), "all activities should be part of the same trace");
+ Assert.That(sendActivities.Concat(receiveActivities).All(a => a.TraceId == sendActivities[0].TraceId), Is.True, "all activities should be part of the same trace");
+ });
}
[Test]
@@ -46,12 +52,18 @@ await Scenario.Define()
var receiveActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
var sendActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(1, sendActivities.Count);
- Assert.AreEqual(2, receiveActivities.Count, "the message should be processed twice due to one immediate retry");
- Assert.AreEqual(sendActivities[0].Id, receiveActivities[0].ParentId, "should not change parent span");
- Assert.AreEqual(sendActivities[0].Id, receiveActivities[1].ParentId, "should not change parent span");
+ Assert.Multiple(() =>
+ {
+ Assert.That(sendActivities, Has.Count.EqualTo(1));
+ Assert.That(receiveActivities, Has.Count.EqualTo(2), "the message should be processed twice due to one immediate retry");
+ });
+ Assert.Multiple(() =>
+ {
+ Assert.That(receiveActivities[0].ParentId, Is.EqualTo(sendActivities[0].Id), "should not change parent span");
+ Assert.That(receiveActivities[1].ParentId, Is.EqualTo(sendActivities[0].Id), "should not change parent span");
- Assert.IsTrue(sendActivities.Concat(receiveActivities).All(a => a.TraceId == sendActivities[0].TraceId), "all activities should be part of the same trace");
+ Assert.That(sendActivities.Concat(receiveActivities).All(a => a.TraceId == sendActivities[0].TraceId), Is.True, "all activities should be part of the same trace");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_messages.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_messages.cs
index fd8a8bfccf8..c7641d28cc4 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_messages.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_messages.cs
@@ -21,11 +21,14 @@ public async Task Should_create_outgoing_message_span()
.Run();
var outgoingMessageActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(1, outgoingMessageActivities.Count, "1 message is being sent");
+ Assert.That(outgoingMessageActivities, Has.Count.EqualTo(1), "1 message is being sent");
var sentMessage = outgoingMessageActivities.Single();
- Assert.IsNull(sentMessage.ParentId, "sends without ambient span should start a new trace");
- Assert.AreEqual("send message", sentMessage.DisplayName);
+ Assert.Multiple(() =>
+ {
+ Assert.That(sentMessage.ParentId, Is.Null, "sends without ambient span should start a new trace");
+ Assert.That(sentMessage.DisplayName, Is.EqualTo("send message"));
+ });
var sentMessageTags = sentMessage.Tags.ToImmutableDictionary();
sentMessageTags.VerifyTag("nservicebus.message_id", context.SentMessageId);
@@ -54,16 +57,22 @@ public async Task Should_create_new_child_on_receive_by_default()
var sendMessageActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
var receiveMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
- Assert.AreEqual(1, sendMessageActivities.Count, "1 message is sent as part of this test");
- Assert.AreEqual(1, receiveMessageActivities.Count, "1 message is received as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(sendMessageActivities, Has.Count.EqualTo(1), "1 message is sent as part of this test");
+ Assert.That(receiveMessageActivities, Has.Count.EqualTo(1), "1 message is received as part of this test");
+ });
var sendRequest = sendMessageActivities[0];
var receiveRequest = receiveMessageActivities[0];
- Assert.AreEqual(sendRequest.RootId, receiveRequest.RootId, "send and receive operations are part of the same root activity");
- Assert.IsNotNull(receiveRequest.ParentId, "incoming message does have a parent");
+ Assert.Multiple(() =>
+ {
+ Assert.That(receiveRequest.RootId, Is.EqualTo(sendRequest.RootId), "send and receive operations are part of the same root activity");
+ Assert.That(receiveRequest.ParentId, Is.Not.Null, "incoming message does have a parent");
+ });
- CollectionAssert.IsEmpty(receiveRequest.Links, "receive does not have links");
+ Assert.That(receiveRequest.Links, Is.Empty, "receive does not have links");
}
[Test]
@@ -83,18 +92,24 @@ public async Task Should_create_new_linked_trace_on_receive_when_requested_via_o
var sendMessageActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
var receiveMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
- Assert.AreEqual(1, sendMessageActivities.Count, "1 message is sent as part of this test");
- Assert.AreEqual(1, receiveMessageActivities.Count, "1 message is received as part of this test");
+ Assert.Multiple(() =>
+ {
+ Assert.That(sendMessageActivities, Has.Count.EqualTo(1), "1 message is sent as part of this test");
+ Assert.That(receiveMessageActivities, Has.Count.EqualTo(1), "1 message is received as part of this test");
+ });
var sendRequest = sendMessageActivities[0];
var receiveRequest = receiveMessageActivities[0];
- Assert.AreNotEqual(sendRequest.RootId, receiveRequest.RootId, "send and receive operations are part of different root activities");
- Assert.IsNull(receiveRequest.ParentId, "incoming message does not have a parent, it's a root");
+ Assert.Multiple(() =>
+ {
+ Assert.That(receiveRequest.RootId, Is.Not.EqualTo(sendRequest.RootId), "send and receive operations are part of different root activities");
+ Assert.That(receiveRequest.ParentId, Is.Null, "incoming message does not have a parent, it's a root");
+ });
ActivityLink link = receiveRequest.Links.FirstOrDefault();
- Assert.IsNotNull(link, "Receive has a link");
- Assert.AreEqual(sendRequest.TraceId, link.Context.TraceId, "receive is linked to send operation");
+ Assert.That(link, Is.Not.EqualTo(default(ActivityLink)), "Receive has a link");
+ Assert.That(link.Context.TraceId, Is.EqualTo(sendRequest.TraceId), "receive is linked to send operation");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_messages_from_pipeline.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_messages_from_pipeline.cs
index 0fee98c8c34..743d3480c0d 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_messages_from_pipeline.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_messages_from_pipeline.cs
@@ -20,11 +20,11 @@ public async Task Should_add_batch_dispatch_events()
var outgoingMessageActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities();
var sentMessage = outgoingMessageActivities.First();
- Assert.IsNotEmpty(sentMessage.Events);
+ Assert.That(sentMessage.Events, Is.Not.Empty);
var startDispatchingEvents = sentMessage.Events.Where(e => e.Name == "Start dispatching").ToArray();
- Assert.AreEqual(1, startDispatchingEvents.Length, "should raise dispatch start event");
- Assert.AreEqual(1, startDispatchingEvents.Single().Tags.ToImmutableDictionary()["message-count"]);
- Assert.AreEqual(1, sentMessage.Events.Count(e => e.Name == "Finished dispatching"), "should raise dispatch completed event");
+ Assert.That(startDispatchingEvents.Length, Is.EqualTo(1), "should raise dispatch start event");
+ Assert.That(startDispatchingEvents.Single().Tags.ToImmutableDictionary()["message-count"], Is.EqualTo(1));
+ Assert.That(sentMessage.Events.Count(e => e.Name == "Finished dispatching"), Is.EqualTo(1), "should raise dispatch completed event");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_replies.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_replies.cs
index fd53c0b2381..9c4e114a3e6 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_replies.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_sending_replies.cs
@@ -16,12 +16,15 @@ public async Task Should_create_outgoing_message_span()
.Run();
var outgoingMessageActivities = NServicebusActivityListener.CompletedActivities.GetSendMessageActivities();
- Assert.AreEqual(2, outgoingMessageActivities.Count, "2 messages are being sent");
+ Assert.That(outgoingMessageActivities, Has.Count.EqualTo(2), "2 messages are being sent");
var replyMessage = outgoingMessageActivities[1];
- Assert.AreEqual("reply", replyMessage.DisplayName);
- Assert.AreEqual(outgoingMessageActivities[0].RootId, replyMessage.RootId, "reply should belong to same trace as the triggering message");
- Assert.IsNotNull(replyMessage.ParentId, "reply should have ambient span");
+ Assert.Multiple(() =>
+ {
+ Assert.That(replyMessage.DisplayName, Is.EqualTo("reply"));
+ Assert.That(replyMessage.RootId, Is.EqualTo(outgoingMessageActivities[0].RootId), "reply should belong to same trace as the triggering message");
+ Assert.That(replyMessage.ParentId, Is.Not.Null, "reply should have ambient span");
+ });
replyMessage.VerifyUniqueTags();
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_subscribing.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_subscribing.cs
index 9b1772f2676..85a426deb73 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_subscribing.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_subscribing.cs
@@ -24,17 +24,17 @@ public async Task Should_create_subscription_span_when_mdps()
var subscribeActivities = NServicebusActivityListener.CompletedActivities.Where(a => a.OperationName == "NServiceBus.Diagnostics.Subscribe")
.ToArray();
- Assert.AreEqual(1, subscribeActivities.Length, "the subscriber should subscribe to the event");
+ Assert.That(subscribeActivities.Length, Is.EqualTo(1), "the subscriber should subscribe to the event");
var subscribeActivity = subscribeActivities.Single();
subscribeActivity.VerifyUniqueTags();
- Assert.AreEqual("subscribe event", subscribeActivity.DisplayName);
+ Assert.That(subscribeActivity.DisplayName, Is.EqualTo("subscribe event"));
var subscribeActivityTags = subscribeActivity.Tags.ToImmutableDictionary();
subscribeActivityTags.VerifyTag("nservicebus.event_types", typeof(DemoEvent).FullName);
var receiveActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities(includeControlMessages: true).ToArray();
- Assert.AreEqual(1, receiveActivities.Length, "the subscription message should be received by the publisher");
- Assert.AreEqual(subscribeActivities[0].Id, receiveActivities[0].ParentId, "the received subscription message should connect to the subscribe operation");
+ Assert.That(receiveActivities.Length, Is.EqualTo(1), "the subscription message should be received by the publisher");
+ Assert.That(receiveActivities[0].ParentId, Is.EqualTo(subscribeActivities[0].Id), "the received subscription message should connect to the subscribe operation");
}
[Test]
@@ -52,16 +52,16 @@ public async Task Should_create_subscription_span_when_native_pubsub()
var subscribeActivities = NServicebusActivityListener.CompletedActivities.Where(a => a.OperationName == "NServiceBus.Diagnostics.Subscribe")
.ToArray();
- Assert.AreEqual(1, subscribeActivities.Length, "the subscriber should subscribe to the event");
+ Assert.That(subscribeActivities.Length, Is.EqualTo(1), "the subscriber should subscribe to the event");
var subscribeActivity = subscribeActivities.Single();
subscribeActivity.VerifyUniqueTags();
- Assert.AreEqual("subscribe event", subscribeActivity.DisplayName);
+ Assert.That(subscribeActivity.DisplayName, Is.EqualTo("subscribe event"));
var subscribeActivityTags = subscribeActivity.Tags.ToImmutableDictionary();
subscribeActivityTags.VerifyTag("nservicebus.event_types", typeof(DemoEvent).FullName);
var subscriptionReceiveActivity = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities(includeControlMessages: true);
- Assert.IsEmpty(subscriptionReceiveActivity, "native pubsub should not produce a message");
+ Assert.That(subscriptionReceiveActivity, Is.Empty, "native pubsub should not produce a message");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_unsubscribing.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_unsubscribing.cs
index 5e4734155f1..2529a91bc9b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_unsubscribing.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/Traces/When_unsubscribing.cs
@@ -23,18 +23,18 @@ public async Task Should_create_unsubscribe_span_when_mdps()
var unsubscribeActivities = NServicebusActivityListener.CompletedActivities.Where(a => a.OperationName == "NServiceBus.Diagnostics.Unsubscribe")
.ToArray();
- Assert.AreEqual(1, unsubscribeActivities.Length, "the subscriber should unsubscribe to the event");
+ Assert.That(unsubscribeActivities.Length, Is.EqualTo(1), "the subscriber should unsubscribe to the event");
var unsubscribeActivity = unsubscribeActivities.Single();
unsubscribeActivity.VerifyUniqueTags();
- Assert.AreEqual("unsubscribe event", unsubscribeActivity.DisplayName);
+ Assert.That(unsubscribeActivity.DisplayName, Is.EqualTo("unsubscribe event"));
var unsubscribeActivityTags = unsubscribeActivity.Tags.ToImmutableDictionary();
unsubscribeActivityTags.VerifyTag("nservicebus.event_types", typeof(DemoEvent).FullName);
var receiveActivities = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities(includeControlMessages: true).ToArray();
- Assert.AreEqual(1, receiveActivities.Length, "the unsubscribe message should be received by the publisher");
- Assert.AreEqual(unsubscribeActivities[0].Id, receiveActivities[0].ParentId, "the received unsubscribe message should connect to the subscribe operation");
+ Assert.That(receiveActivities.Length, Is.EqualTo(1), "the unsubscribe message should be received by the publisher");
+ Assert.That(receiveActivities[0].ParentId, Is.EqualTo(unsubscribeActivities[0].Id), "the received unsubscribe message should connect to the subscribe operation");
}
[Test]
@@ -50,17 +50,17 @@ public async Task Should_create_unsubscribe_span_when_native_pubsub()
.Run();
var unsubscribeActivities = NServicebusActivityListener.CompletedActivities.Where(a => a.OperationName == "NServiceBus.Diagnostics.Unsubscribe").ToArray();
- Assert.AreEqual(1, unsubscribeActivities.Length, "the subscriber should unsubscribe to the event");
+ Assert.That(unsubscribeActivities.Length, Is.EqualTo(1), "the subscriber should unsubscribe to the event");
var unsubscribeActivity = unsubscribeActivities.Single();
unsubscribeActivity.VerifyUniqueTags();
- Assert.AreEqual("unsubscribe event", unsubscribeActivity.DisplayName);
+ Assert.That(unsubscribeActivity.DisplayName, Is.EqualTo("unsubscribe event"));
var unsubscribeActivityTags = unsubscribeActivity.Tags.ToImmutableDictionary();
unsubscribeActivityTags.VerifyTag("nservicebus.event_types", typeof(DemoEvent).FullName);
var subscriptionReceiveActivity = NServicebusActivityListener.CompletedActivities.GetReceiveMessageActivities(includeControlMessages: true);
- Assert.IsEmpty(subscriptionReceiveActivity, "native pubsub should not produce a message");
+ Assert.That(subscriptionReceiveActivity, Is.Empty, "native pubsub should not produce a message");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/When_incoming_message_handled.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/When_incoming_message_handled.cs
index a6ed79faec3..e9b43ef3de2 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/When_incoming_message_handled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/When_incoming_message_handled.cs
@@ -28,9 +28,9 @@ public async Task Should_record_success_handling_time()
metricsListener.AssertMetric(HandlerTimeMetricName, 5);
AssertMandatoryTags(metricsListener, HandlerTimeMetricName, typeof(MyMessage));
var handlerType = metricsListener.AssertTagKeyExists(HandlerTimeMetricName, "nservicebus.message_handler_type");
- Assert.AreEqual(typeof(MyMessageHandler).FullName, handlerType);
+ Assert.That(handlerType, Is.EqualTo(typeof(MyMessageHandler).FullName));
var result = metricsListener.AssertTagKeyExists(HandlerTimeMetricName, "execution.result");
- Assert.AreEqual("success", result);
+ Assert.That(result, Is.EqualTo("success"));
}
[Test]
@@ -40,11 +40,11 @@ public async Task Should_record_failure_handling_time()
metricsListener.AssertMetric(HandlerTimeMetricName, 5);
AssertMandatoryTags(metricsListener, HandlerTimeMetricName, typeof(MyExceptionalMessage));
var handlerType = metricsListener.AssertTagKeyExists(HandlerTimeMetricName, "nservicebus.message_handler_type");
- Assert.AreEqual(typeof(MyExceptionalHandler).FullName, handlerType);
+ Assert.That(handlerType, Is.EqualTo(typeof(MyExceptionalHandler).FullName));
var error = metricsListener.AssertTagKeyExists(HandlerTimeMetricName, "error.type");
- Assert.AreEqual(typeof(Exception).FullName, error);
+ Assert.That(error, Is.EqualTo(typeof(Exception).FullName));
var result = metricsListener.AssertTagKeyExists(HandlerTimeMetricName, "execution.result");
- Assert.AreEqual("failure", result);
+ Assert.That(result, Is.EqualTo("failure"));
}
[Test]
@@ -97,11 +97,11 @@ static void AssertMandatoryTags(
Type expectedMessageType)
{
var messageType = metricsListener.AssertTagKeyExists(metricName, "nservicebus.message_type");
- Assert.AreEqual(expectedMessageType.FullName, messageType);
+ Assert.That(messageType, Is.EqualTo(expectedMessageType.FullName));
var endpoint = metricsListener.AssertTagKeyExists(metricName, "nservicebus.queue");
- Assert.AreEqual(Conventions.EndpointNamingConvention(typeof(EndpointWithMetrics)), endpoint);
+ Assert.That(endpoint, Is.EqualTo(Conventions.EndpointNamingConvention(typeof(EndpointWithMetrics))));
var discriminator = metricsListener.AssertTagKeyExists(metricName, "nservicebus.discriminator");
- Assert.AreEqual("discriminator", discriminator);
+ Assert.That(discriminator, Is.EqualTo("discriminator"));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/When_incoming_message_handled_successfully.cs b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/When_incoming_message_handled_successfully.cs
index cd5fd6e9e1f..e8beb4e0afe 100644
--- a/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/When_incoming_message_handled_successfully.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/OpenTelemetry/When_incoming_message_handled_successfully.cs
@@ -30,11 +30,11 @@ public async Task Should_record_handling_time()
string handlingTime = "nservicebus.messaging.handler_time";
metricsListener.AssertMetric(handlingTime, 5);
var messageType = metricsListener.AssertTagKeyExists(handlingTime, "nservicebus.message_type");
- Assert.AreEqual(typeof(MyMessage).FullName, messageType);
+ Assert.That(messageType, Is.EqualTo(typeof(MyMessage).FullName));
var handlerType = metricsListener.AssertTagKeyExists(handlingTime, "nservicebus.message_handler_type");
- Assert.AreEqual(typeof(MyMessageHandler).FullName, handlerType);
+ Assert.That(handlerType, Is.EqualTo(typeof(MyMessageHandler).FullName));
var endpoint = metricsListener.AssertTagKeyExists(handlingTime, "nservicebus.queue");
- Assert.AreEqual(Conventions.EndpointNamingConvention(typeof(EndpointWithMetrics)), endpoint);
+ Assert.That(endpoint, Is.EqualTo(Conventions.EndpointNamingConvention(typeof(EndpointWithMetrics))));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_for_send_only.cs b/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_for_send_only.cs
index 4469a79a36e..0775aa5fe53 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_for_send_only.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_for_send_only.cs
@@ -16,7 +16,7 @@ public async Task Should_fail_prerequisites_check()
.Done(c => c.EndpointsStarted)
.Run();
- StringAssert.Contains("Outbox is only relevant for endpoints receiving messages.", startupDiagnostics);
+ Assert.That(startupDiagnostics, Does.Contain("Outbox is only relevant for endpoints receiving messages."));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_with_transaction_mode_above_receive_only.cs b/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_with_transaction_mode_above_receive_only.cs
index 04739a5c9a3..dbb44190ea6 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_with_transaction_mode_above_receive_only.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_with_transaction_mode_above_receive_only.cs
@@ -15,7 +15,7 @@ public void Should_fail_to_start()
.Done(_ => false)
.Run());
- StringAssert.Contains($"Outbox requires transport to be running in `{nameof(TransportTransactionMode.ReceiveOnly)}` mode", exception.Message);
+ Assert.That(exception.Message, Does.Contain($"Outbox requires transport to be running in `{nameof(TransportTransactionMode.ReceiveOnly)}` mode"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_with_transactions_off.cs b/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_with_transactions_off.cs
index 042b1c22ec3..3154e900b65 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_with_transactions_off.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_with_transactions_off.cs
@@ -27,8 +27,11 @@ public async Task Should_fail_prerequisites_check()
var satisfied = outboxFeature["PrerequisiteStatus"]["IsSatisfied"].GetValue();
var reason = (outboxFeature["PrerequisiteStatus"]["Reasons"] as JsonArray).Single().GetValue();
- Assert.IsFalse(satisfied);
- Assert.AreEqual("Outbox isn't needed since the receive transactions have been turned off", reason);
+ Assert.Multiple(() =>
+ {
+ Assert.That(satisfied, Is.False);
+ Assert.That(reason, Is.EqualTo("Outbox isn't needed since the receive transactions have been turned off"));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_without_persister_supporting_it.cs b/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_without_persister_supporting_it.cs
index 2d8635b1dd5..a8dadf92f58 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_without_persister_supporting_it.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Outbox/When_outbox_enabled_without_persister_supporting_it.cs
@@ -16,7 +16,7 @@ public void Should_fail_to_start()
.Done(_ => false)
.Run());
- StringAssert.Contains("The selected persistence doesn't have support for outbox storage", exception.Message);
+ Assert.That(exception.Message, Does.Contain("The selected persistence doesn't have support for outbox storage"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Persistence/When_a_persistence_provides_synchronized_session.cs b/src/NServiceBus.AcceptanceTests/Core/Persistence/When_a_persistence_provides_synchronized_session.cs
index 4f645185c1f..34c2099c833 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Persistence/When_a_persistence_provides_synchronized_session.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Persistence/When_a_persistence_provides_synchronized_session.cs
@@ -16,9 +16,12 @@ public async Task Synchronized_session_should_be_of_exact_type_provided_by_persi
.Done(c => c.MessageReceived)
.Run();
- Assert.IsNotNull(result.SynchronizedStorageSessionInstanceInContainer);
- Assert.IsNotNull(result.SynchronizedStorageSessionInstanceInHandlingContext);
- Assert.AreSame(result.SynchronizedStorageSessionInstanceInContainer, result.SynchronizedStorageSessionInstanceInHandlingContext);
+ Assert.Multiple(() =>
+ {
+ Assert.That(result.SynchronizedStorageSessionInstanceInContainer, Is.Not.Null);
+ Assert.That(result.SynchronizedStorageSessionInstanceInHandlingContext, Is.Not.Null);
+ });
+ Assert.That(result.SynchronizedStorageSessionInstanceInHandlingContext, Is.SameAs(result.SynchronizedStorageSessionInstanceInContainer));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_aborting_the_behavior_chain.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_aborting_the_behavior_chain.cs
index 798c50ed79e..08eb6b18bbd 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_aborting_the_behavior_chain.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_aborting_the_behavior_chain.cs
@@ -15,8 +15,11 @@ public async Task Subsequent_handlers_will_not_be_invoked()
.Done(c => c.FirstHandlerInvoked)
.Run();
- Assert.That(context.FirstHandlerInvoked, Is.True);
- Assert.That(context.SecondHandlerInvoked, Is.False);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.FirstHandlerInvoked, Is.True);
+ Assert.That(context.SecondHandlerInvoked, Is.False);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_discontinuing_message_dispatch.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_discontinuing_message_dispatch.cs
index 290db127af9..d3a4bb66719 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_discontinuing_message_dispatch.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_discontinuing_message_dispatch.cs
@@ -19,8 +19,11 @@ public async Task Should_not_continue_to_dispatch_the_message()
.Done(c => c.InterceptingHandlerCalled)
.Run();
- Assert.True(context.InterceptingHandlerCalled, "The intercepting handler should be called");
- Assert.False(context.SagaStarted, "The saga should not have been started since the intercepting handler stops the pipeline");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.InterceptingHandlerCalled, Is.True, "The intercepting handler should be called");
+ Assert.That(context.SagaStarted, Is.False, "The saga should not have been started since the intercepting handler stops the pipeline");
+ });
}
public class SagaEndpointContext : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_behavior_context.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_behavior_context.cs
index 1d8962e22aa..bb05abb326b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_behavior_context.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_behavior_context.cs
@@ -20,8 +20,11 @@ public async Task Should_be_available_in_handler_context()
.Done(c => c.HandlerAExtensionValue != null && c.HandlerBExtensionValue != null)
.Run();
- Assert.AreEqual(ExtensionValue, context.HandlerAExtensionValue);
- Assert.AreEqual(ExtensionValue, context.HandlerBExtensionValue);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HandlerAExtensionValue, Is.EqualTo(ExtensionValue));
+ Assert.That(context.HandlerBExtensionValue, Is.EqualTo(ExtensionValue));
+ });
}
static string ExtensionValue;
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_sendoptions.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_sendoptions.cs
index 41f09f4b4c5..13b8fd46395 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_sendoptions.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_sendoptions.cs
@@ -29,7 +29,7 @@ public async Task Should_be_able_to_set_context_items_and_retrieve_it_via_a_beha
.Done(c => c.WasCalled)
.Run();
- Assert.AreEqual("I did it", context.Secret);
+ Assert.That(context.Secret, Is.EqualTo("I did it"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_the_publish_api.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_the_publish_api.cs
index 342605a0975..a66098438f1 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_the_publish_api.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_extending_the_publish_api.cs
@@ -40,7 +40,7 @@ public async Task Should_make_the_context_available_to_behaviors()
.Done(c => c.Subscriber1GotTheEvent)
.Run();
- Assert.True(context.Subscriber1GotTheEvent);
+ Assert.That(context.Subscriber1GotTheEvent, Is.True);
}
public class Context : ScenarioContext
@@ -67,7 +67,7 @@ public Task Invoke(IOutgoingLogicalMessageContext context, Func c.FirstHandlerWasCalled)
.Run();
- Assert.True(context.FirstHandlerWasCalled);
- Assert.True(context.SecondHandlerWasCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.FirstHandlerWasCalled, Is.True);
+ Assert.That(context.SecondHandlerWasCalled, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_overwriting_conversation_id.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_overwriting_conversation_id.cs
index 6a482588a2a..e314eaba923 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_overwriting_conversation_id.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_overwriting_conversation_id.cs
@@ -26,8 +26,8 @@ public void Should_throw_when_incoming_conversation_id_available()
.Done(c => c.ReceivedMessage)
.Run());
- StringAssert.Contains($"Cannot set the {Headers.ConversationId} header to 'intermediate message header' as it cannot override the incoming header value ('{initialConversationId}').", exception.InnerException.Message);
- Assert.IsFalse(((Context)exception.ScenarioContext).SentOutgoingMessage, "because send should fail");
+ Assert.That(exception.InnerException.Message, Does.Contain($"Cannot set the {Headers.ConversationId} header to 'intermediate message header' as it cannot override the incoming header value ('{initialConversationId}')."));
+ Assert.That(((Context)exception.ScenarioContext).SentOutgoingMessage, Is.False, "because send should fail");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_providing_custom_handler_registry.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_providing_custom_handler_registry.cs
index f2430dd5ba1..317f8644bc2 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_providing_custom_handler_registry.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_providing_custom_handler_registry.cs
@@ -26,10 +26,13 @@ public async Task Should_invoke_manually_registered_handlers()
&& c.ManuallyRegisteredEventHandlerInvoked)
.Run(TimeSpan.FromSeconds(10));
- Assert.IsTrue(context.RegularCommandHandlerInvoked);
- Assert.IsTrue(context.ManuallyRegisteredCommandHandlerInvoked);
- Assert.IsTrue(context.RegularEventHandlerInvoked);
- Assert.IsTrue(context.ManuallyRegisteredEventHandlerInvoked);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.RegularCommandHandlerInvoked, Is.True);
+ Assert.That(context.ManuallyRegisteredCommandHandlerInvoked, Is.True);
+ Assert.That(context.RegularEventHandlerInvoked, Is.True);
+ Assert.That(context.ManuallyRegisteredEventHandlerInvoked, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_receiving_with_catch_all_handlers_registered.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_receiving_with_catch_all_handlers_registered.cs
index dc835c43966..a52d000f4af 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_receiving_with_catch_all_handlers_registered.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_receiving_with_catch_all_handlers_registered.cs
@@ -19,9 +19,12 @@ public async Task Should_call_catch_all_handlers()
.Done(c => c.ObjectHandlerWasCalled && c.DynamicHandlerWasCalled && c.IMessageHandlerWasCalled)
.Run();
- Assert.True(context.ObjectHandlerWasCalled);
- Assert.True(context.DynamicHandlerWasCalled);
- Assert.True(context.IMessageHandlerWasCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ObjectHandlerWasCalled, Is.True);
+ Assert.That(context.DynamicHandlerWasCalled, Is.True);
+ Assert.That(context.IMessageHandlerWasCalled, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_registering_handlers_explicitly.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_registering_handlers_explicitly.cs
index 0fbd8d9253a..cb7f24ed585 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_registering_handlers_explicitly.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_registering_handlers_explicitly.cs
@@ -17,7 +17,7 @@ public async Task Should_enable_properties_to_be_set()
.Done(c => c.WasCalled)
.Run();
- Assert.AreEqual(simpleValue, context.PropertyValue);
+ Assert.That(context.PropertyValue, Is.EqualTo(simpleValue));
}
static string simpleValue = "SomeValue";
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_replacing_behavior.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_replacing_behavior.cs
index 09b3157c208..4b99e48178c 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_replacing_behavior.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_replacing_behavior.cs
@@ -18,8 +18,11 @@ public async Task Should_invoke_replacement_in_pipeline()
.Done(c => c.MessageHandled)
.Run();
- Assert.IsFalse(context.OriginalBehaviorInvoked);
- Assert.IsTrue(context.ReplacementBehaviorInvoked);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.OriginalBehaviorInvoked, Is.False);
+ Assert.That(context.ReplacementBehaviorInvoked, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_reusing_sendoptions.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_reusing_sendoptions.cs
index 083521816be..1b44817712c 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_reusing_sendoptions.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_reusing_sendoptions.cs
@@ -25,8 +25,8 @@ public async Task Should_generate_new_message_id_for_every_message()
.Done(c => c.ReceivedMessageIds.Count >= 3)
.Run();
- Assert.AreEqual(3, context.ReceivedMessageIds.Count);
- Assert.AreEqual(3, context.ReceivedMessageIds.Distinct().Count(), "the message ids should be distinct");
+ Assert.That(context.ReceivedMessageIds, Has.Count.EqualTo(3));
+ Assert.That(context.ReceivedMessageIds.Distinct().Count(), Is.EqualTo(3), "the message ids should be distinct");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_sending_from_a_send_only.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_sending_from_a_send_only.cs
index 134684e5571..31a5c12b917 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_sending_from_a_send_only.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_sending_from_a_send_only.cs
@@ -21,7 +21,7 @@ public async Task Should_send_the_message()
.Done(c => c.WasCalled)
.Run();
- Assert.True(context.WasCalled, "The message handler should be called");
+ Assert.That(context.WasCalled, Is.True, "The message handler should be called");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_setting_handler_execution_order.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_setting_handler_execution_order.cs
index 74e2fa479b8..41f7a88cff6 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_setting_handler_execution_order.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_setting_handler_execution_order.cs
@@ -19,7 +19,7 @@ public async Task Should_call_designated_handler_first()
.Done(c => c.InterceptingHandlerCalled && c.SagaStarted)
.Run();
- Assert.True(context.InterceptingHandlerCalledFirst, "The intercepting message handler should be called first");
+ Assert.That(context.InterceptingHandlerCalledFirst, Is.True, "The intercepting message handler should be called first");
}
public class SagaEndpointContext : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_setting_ttbr_in_outer_publish.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_setting_ttbr_in_outer_publish.cs
index cc83c7e8404..9b4dfb545b1 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_setting_ttbr_in_outer_publish.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_setting_ttbr_in_outer_publish.cs
@@ -23,8 +23,11 @@ public async Task Should_not_apply_ttbr_to_inner_publish()
.Done(c => c.OuterEventReceived && c.InnerEventReceived)
.Run();
- Assert.IsNotNull(context.OuterEventTtbr, "Outer event should have TTBR settings applied");
- Assert.IsNull(context.InnerEventTtbr, "Inner event should not have TTBR settings applied");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.OuterEventTtbr, Is.Not.Null, "Outer event should have TTBR settings applied");
+ Assert.That(context.InnerEventTtbr, Is.Null, "Inner event should not have TTBR settings applied");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_skipping_serialization_with_nested_send.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_skipping_serialization_with_nested_send.cs
index e104d9886ae..49d9a39c0fa 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_skipping_serialization_with_nested_send.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_skipping_serialization_with_nested_send.cs
@@ -20,9 +20,12 @@ public async Task Should_not_skip_serialization_for_nested_send()
.Done(c => c.NestedMessageReceived)
.Run(TimeSpan.FromSeconds(15));
- Assert.IsTrue(context.NestedMessageReceived, "the serialization should the nested message should not be skipped");
- Assert.AreEqual("Some property value for NestedMessage", context.NestedMessagePropertyValue, "the message sould be correctly serialized");
- Assert.IsFalse(context.MessageWithSkippedSerializationReceived, "NServiceBus should discard messages without a body");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.NestedMessageReceived, Is.True, "the serialization should the nested message should not be skipped");
+ Assert.That(context.NestedMessagePropertyValue, Is.EqualTo("Some property value for NestedMessage"), "the message sould be correctly serialized");
+ Assert.That(context.MessageWithSkippedSerializationReceived, Is.False, "NServiceBus should discard messages without a body");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_subscribed_to_ReceivePipelineCompleted.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_subscribed_to_ReceivePipelineCompleted.cs
index 265b5323743..9395b62af81 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_subscribed_to_ReceivePipelineCompleted.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_subscribed_to_ReceivePipelineCompleted.cs
@@ -17,10 +17,13 @@ public async Task Should_receive_notifications()
.Done(c => c.NotificationEventFired)
.Run();
- Assert.True(context.NotificationEventFired, "ReceivePipelineCompleted was not raised");
- Assert.AreEqual(context.MessageId, context.ReceivePipelineCompletedMessage.ProcessedMessage.MessageId, "MessageId mismatch");
- Assert.AreNotEqual(DateTime.MinValue, context.ReceivePipelineCompletedMessage.StartedAt, "StartedAt was not set");
- Assert.AreNotEqual(DateTime.MinValue, context.ReceivePipelineCompletedMessage.CompletedAt, "CompletedAt was not set");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.NotificationEventFired, Is.True, "ReceivePipelineCompleted was not raised");
+ Assert.That(context.ReceivePipelineCompletedMessage.ProcessedMessage.MessageId, Is.EqualTo(context.MessageId), "MessageId mismatch");
+ Assert.That(context.ReceivePipelineCompletedMessage.StartedAt, Is.Not.EqualTo(DateTimeOffset.MinValue), "StartedAt was not set");
+ Assert.That(context.ReceivePipelineCompletedMessage.CompletedAt, Is.Not.EqualTo(DateTimeOffset.MinValue), "CompletedAt was not set");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_transport_transaction_provided.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_transport_transaction_provided.cs
index 43623381c0e..a60bbc19f1a 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_transport_transaction_provided.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_transport_transaction_provided.cs
@@ -20,7 +20,7 @@ public async Task Should_be_available_during_dispatch()
.Done(c => c.AnotherMessageReceived)
.Run();
- Assert.AreSame(context.IncomingPipelineTransportTransaction, context.DispatchPipelineTransportTransaction, "Transport Transaction was not the same");
+ Assert.That(context.DispatchPipelineTransportTransaction, Is.SameAs(context.IncomingPipelineTransportTransaction), "Transport Transaction was not the same");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_custom_conversation_id.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_custom_conversation_id.cs
index 4b0837fbdba..7f8bc13d2b8 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_custom_conversation_id.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_custom_conversation_id.cs
@@ -25,7 +25,7 @@ public async Task Should_apply_custom_conversation_id_when_no_incoming_message()
.Done(c => !string.IsNullOrEmpty(c.ReceivedConversationId))
.Run();
- Assert.AreEqual(customConversationId, context.ReceivedConversationId);
+ Assert.That(context.ReceivedConversationId, Is.EqualTo(customConversationId));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_per_uow_component_in_the_pipeline.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_per_uow_component_in_the_pipeline.cs
index bca9713531b..6c66eb3591b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_per_uow_component_in_the_pipeline.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_per_uow_component_in_the_pipeline.cs
@@ -24,8 +24,11 @@ public async Task It_should_be_scoped_to_uow_both_in_behavior_and_in_the_handler
.Done(c => c.MessagesProcessed >= 2)
.Run();
- Assert.IsFalse(context.ValueEmpty, "Empty value in the UoW component meaning the UoW component has been registered as per-call");
- Assert.IsFalse(context.ValueAlreadyInitialized, "Value in the UoW has already been initialized when it was resolved for the first time in a given pipeline meaning the UoW component has been registered as a singleton.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ValueEmpty, Is.False, "Empty value in the UoW component meaning the UoW component has been registered as per-call");
+ Assert.That(context.ValueAlreadyInitialized, Is.False, "Value in the UoW has already been initialized when it was resolved for the first time in a given pipeline meaning the UoW component has been registered as a singleton.");
+ });
}
static Task SendMessage(IMessageSession s)
diff --git a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_polymorphic_message_handlers.cs b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_polymorphic_message_handlers.cs
index 37b1d53a0c4..ef0480eefc1 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_polymorphic_message_handlers.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Pipeline/When_using_polymorphic_message_handlers.cs
@@ -18,8 +18,11 @@ public async Task Should_invoke_all_compatible_handlers()
.Done(c => c.SpecificHandlerInvoked && c.CatchAllHandlerInvoked)
.Run();
- Assert.True(context.SpecificHandlerInvoked);
- Assert.True(context.CatchAllHandlerInvoked);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SpecificHandlerInvoked, Is.True);
+ Assert.That(context.CatchAllHandlerInvoked, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_configuring_subscription_authorizer.cs b/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_configuring_subscription_authorizer.cs
index e24c895ce7a..bba302659f7 100644
--- a/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_configuring_subscription_authorizer.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_configuring_subscription_authorizer.cs
@@ -33,8 +33,8 @@ public async Task Should_apply_authorizer_on_subscriptions()
.Done(c => c.ReceivedAllowedEventSubscriptionMessage && c.ReceivedForbiddenEventSubscriptionMessage)
.Run();
- Assert.AreEqual(1, context.SubscriptionStorage.SubscribedEvents.Count);
- Assert.AreEqual(typeof(AllowedEvent).FullName, context.SubscriptionStorage.SubscribedEvents.Single());
+ Assert.That(context.SubscriptionStorage.SubscribedEvents, Has.Count.EqualTo(1));
+ Assert.That(context.SubscriptionStorage.SubscribedEvents.Single(), Is.EqualTo(typeof(AllowedEvent).FullName));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_disabling_publishing.cs b/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_disabling_publishing.cs
index 80e3eccc5d2..249fab79035 100644
--- a/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_disabling_publishing.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_disabling_publishing.cs
@@ -37,7 +37,7 @@ public void Should_throw_when_publishing()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Publishing has been explicitly disabled on this endpoint", exception.Message);
+ Assert.That(exception.Message, Does.Contain("Publishing has been explicitly disabled on this endpoint"));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_subscribing_on_send_only_endpoint.cs b/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_subscribing_on_send_only_endpoint.cs
index 803af016e8f..958d0350073 100644
--- a/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_subscribing_on_send_only_endpoint.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_subscribing_on_send_only_endpoint.cs
@@ -16,7 +16,7 @@ public void Should_throw_InvalidOperationException_on_native_pubsub()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Send-only endpoints cannot subscribe to events", exception.Message);
+ Assert.That(exception.Message, Does.Contain("Send-only endpoints cannot subscribe to events"));
}
[Test]
@@ -28,7 +28,7 @@ public void Should_throw_InvalidOperationException_on_message_driven_pubsub()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Send-only endpoints cannot subscribe to events", exception.Message);
+ Assert.That(exception.Message, Does.Contain("Send-only endpoints cannot subscribe to events"));
}
class NativePubSubSendOnlyEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_unsubscribing_on_send_only_endpoint.cs b/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_unsubscribing_on_send_only_endpoint.cs
index 2e425631748..b2c6909b3e0 100644
--- a/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_unsubscribing_on_send_only_endpoint.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/PublishSubscribe/When_unsubscribing_on_send_only_endpoint.cs
@@ -16,7 +16,7 @@ public void Should_throw_InvalidOperationException_on_native_pubsub()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Send-only endpoints cannot unsubscribe to events", exception.Message);
+ Assert.That(exception.Message, Does.Contain("Send-only endpoints cannot unsubscribe to events"));
}
[Test]
@@ -28,7 +28,7 @@ public void Should_throw_InvalidOperationException_on_message_driven_pubsub()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Send-only endpoints cannot unsubscribe to events", exception.Message);
+ Assert.That(exception.Message, Does.Contain("Send-only endpoints cannot unsubscribe to events"));
}
class NativePubSubSendOnlyEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_applying_message_recoverability.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_applying_message_recoverability.cs
index 597496bcb2d..479f1279a4b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_applying_message_recoverability.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_applying_message_recoverability.cs
@@ -33,8 +33,11 @@ public async Task Should_allow_for_alternate_move_to_error_action()
.Done(c => c.MessageMovedToErrorQueue)
.Run();
- Assert.True(context.MessageBodyWasEmpty);
- Assert.True(onMessageSentToErrorQueueTriggered);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageBodyWasEmpty, Is.True);
+ Assert.That(onMessageSentToErrorQueueTriggered, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_configuring_unrecoverable_exception.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_configuring_unrecoverable_exception.cs
index 7fc6f4a1ec1..cb48d8160b3 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_configuring_unrecoverable_exception.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_configuring_unrecoverable_exception.cs
@@ -30,9 +30,12 @@ await Scenario.Define(ctx => context = ctx)
.Run();
});
- Assert.That(exception.FailedMessage.Exception, Is.TypeOf());
- Assert.That(exception.ScenarioContext.FailedMessages, Has.Count.EqualTo(1));
- Assert.AreEqual(1, context.HandlerInvoked);
+ Assert.Multiple(() =>
+ {
+ Assert.That(exception.FailedMessage.Exception, Is.TypeOf());
+ Assert.That(exception.ScenarioContext.FailedMessages, Has.Count.EqualTo(1));
+ Assert.That(context.HandlerInvoked, Is.EqualTo(1));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_custom_policy_executed.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_custom_policy_executed.cs
index 9d7a6f6b024..bdb5c7b5af7 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_custom_policy_executed.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_custom_policy_executed.cs
@@ -23,13 +23,16 @@ public async Task Should_provide_error_context_to_policy()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.That(context.ErrorContexts.Count, Is.EqualTo(2), "because the custom policy should have been invoked twice");
- Assert.That(context.ErrorContexts[0].Message, Is.Not.Null);
- Assert.That(context.ErrorContexts[0].Exception, Is.TypeOf());
- Assert.That(context.ErrorContexts[0].DelayedDeliveriesPerformed, Is.EqualTo(0));
- Assert.That(context.ErrorContexts[1].Message, Is.Not.Null);
- Assert.That(context.ErrorContexts[1].Exception, Is.TypeOf());
- Assert.That(context.ErrorContexts[1].DelayedDeliveriesPerformed, Is.EqualTo(1));
+ Assert.That(context.ErrorContexts, Has.Count.EqualTo(2), "because the custom policy should have been invoked twice");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ErrorContexts[0].Message, Is.Not.Null);
+ Assert.That(context.ErrorContexts[0].Exception, Is.TypeOf());
+ Assert.That(context.ErrorContexts[0].DelayedDeliveriesPerformed, Is.EqualTo(0));
+ Assert.That(context.ErrorContexts[1].Message, Is.Not.Null);
+ Assert.That(context.ErrorContexts[1].Exception, Is.TypeOf());
+ Assert.That(context.ErrorContexts[1].DelayedDeliveriesPerformed, Is.EqualTo(1));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_custom_policy_provided.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_custom_policy_provided.cs
index a26575ddd74..921070cddd1 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_custom_policy_provided.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_custom_policy_provided.cs
@@ -21,9 +21,12 @@ public async Task Should_pass_recoverability_configuration()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.That(context.Configuration.Immediate.MaxNumberOfRetries, Is.EqualTo(MaxImmediateRetries));
- Assert.That(context.Configuration.Delayed.MaxNumberOfRetries, Is.EqualTo(MaxDelayedRetries));
- Assert.That(context.Configuration.Delayed.TimeIncrease, Is.EqualTo(DelayedRetryDelayIncrease));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Configuration.Immediate.MaxNumberOfRetries, Is.EqualTo(MaxImmediateRetries));
+ Assert.That(context.Configuration.Delayed.MaxNumberOfRetries, Is.EqualTo(MaxDelayedRetries));
+ Assert.That(context.Configuration.Delayed.TimeIncrease, Is.EqualTo(DelayedRetryDelayIncrease));
+ });
}
static TimeSpan DelayedRetryDelayIncrease = TimeSpan.FromMinutes(1);
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_enabled_with_no_support.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_enabled_with_no_support.cs
index 5e7c26aa94d..3c64b26bfbe 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_enabled_with_no_support.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_enabled_with_no_support.cs
@@ -20,7 +20,7 @@ public void Should_throw_on_startup()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Delayed retries are not supported when the transport does not support delayed delivery. Disable delayed retries using 'endpointConfiguration.Recoverability().Delayed(settings => settings.NumberOfRetries(0))'.", exception.ToString());
+ Assert.That(exception.ToString(), Does.Contain("Delayed retries are not supported when the transport does not support delayed delivery. Disable delayed retries using 'endpointConfiguration.Recoverability().Delayed(settings => settings.NumberOfRetries(0))'."));
}
public class StartedEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_with_regular_exception.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_with_regular_exception.cs
index 0ebeffb7430..c40990c594d 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_with_regular_exception.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_with_regular_exception.cs
@@ -24,7 +24,7 @@ public async Task Should_preserve_the_original_body_for_regular_exceptions()
var delayedRetryBody = context.FailedMessages.Single().Value.Single().Body;
- CollectionAssert.AreEqual(context.OriginalBody.ToArray(), delayedRetryBody.ToArray(), "The body of the message sent to Delayed Retry should be the same as the original message coming off the queue");
+ Assert.That(delayedRetryBody.ToArray(), Is.EqualTo(context.OriginalBody.ToArray()).AsCollection, "The body of the message sent to Delayed Retry should be the same as the original message coming off the queue");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_failing_mutated_message.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_failing_mutated_message.cs
index 3140543f55f..ff4874f05a5 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_failing_mutated_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_failing_mutated_message.cs
@@ -24,7 +24,7 @@ public async Task Should_preserve_the_original_body()
var errorBody = context.FailedMessages.Single().Value.Single().Body;
- CollectionAssert.AreEqual(context.OriginalBody, errorBody.ToArray(), "The body of the message sent to delayed retry should be the same as the original message coming off the queue");
+ Assert.That(errorBody.ToArray(), Is.EqualTo(context.OriginalBody).AsCollection, "The body of the message sent to delayed retry should be the same as the original message coming off the queue");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_message_is_dispatched_to_error_queue.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_message_is_dispatched_to_error_queue.cs
index 5fa716b954e..ef50c9c823c 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_message_is_dispatched_to_error_queue.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_message_is_dispatched_to_error_queue.cs
@@ -23,7 +23,7 @@ public async Task Should_allow_body_to_be_manipulated()
.Done(c => c.MessageMovedToErrorQueue)
.Run();
- Assert.True(context.MessageBodyWasEmpty);
+ Assert.That(context.MessageBodyWasEmpty, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_message_is_moved_to_error_queue_with_header_customizations.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_message_is_moved_to_error_queue_with_header_customizations.cs
index c5853bc5285..c29839bddbc 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_message_is_moved_to_error_queue_with_header_customizations.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_message_is_moved_to_error_queue_with_header_customizations.cs
@@ -26,9 +26,12 @@ public async Task Should_apply_header_customizations()
.Done(c => c.MessageMovedToErrorQueue)
.Run();
- Assert.IsFalse(context.Headers.ContainsKey("NServiceBus.ExceptionInfo.ExceptionType"));
- Assert.AreEqual("this is a large message", context.Headers["NServiceBus.ExceptionInfo.Message"]);
- Assert.AreEqual("NotInventedHere", context.Headers["NServiceBus.ExceptionInfo.NotInventedHere"]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Headers.ContainsKey("NServiceBus.ExceptionInfo.ExceptionType"), Is.False);
+ Assert.That(context.Headers["NServiceBus.ExceptionInfo.Message"], Is.EqualTo("this is a large message"));
+ Assert.That(context.Headers["NServiceBus.ExceptionInfo.NotInventedHere"], Is.EqualTo("NotInventedHere"));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_delayed_retries_notifications.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_delayed_retries_notifications.cs
index 9ebcc94619c..34ba5c5e995 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_delayed_retries_notifications.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_delayed_retries_notifications.cs
@@ -26,11 +26,14 @@ public async Task Should_trigger_notification_on_delayed_retry()
.Done(c => c.MessageSentToError)
.Run();
- Assert.IsInstanceOf(context.LastDelayedRetryInfo?.Exception);
- // Immediate Retries max retries = 3 means we will be processing 4 times. Delayed Retries max retries = 2 means we will do 3 * Immediate Retries
- Assert.AreEqual(4 * 3, context.TotalNumberOfHandlerInvocations);
- Assert.AreEqual(2, context.NumberOfDelayedRetriesPerformed);
- Assert.AreEqual(2, context.LastDelayedRetryInfo.RetryAttempt);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.LastDelayedRetryInfo?.Exception, Is.InstanceOf());
+ // Immediate Retries max retries = 3 means we will be processing 4 times. Delayed Retries max retries = 2 means we will do 3 * Immediate Retries
+ Assert.That(context.TotalNumberOfHandlerInvocations, Is.EqualTo(4 * 3));
+ Assert.That(context.NumberOfDelayedRetriesPerformed, Is.EqualTo(2));
+ Assert.That(context.LastDelayedRetryInfo.RetryAttempt, Is.EqualTo(2));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_error_notifications.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_error_notifications.cs
index 71ac06d999c..fb27e829fde 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_error_notifications.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_error_notifications.cs
@@ -27,13 +27,16 @@ public async Task Should_retain_exception_details_over_immediate_and_delayed_ret
.Done(c => c.MessageSentToError)
.Run();
- Assert.IsInstanceOf(context.MessageSentToErrorException);
- Assert.True(context.Logs.Any(l => l.Level == LogLevel.Error && l.Message.Contains("Simulated exception message")), "The last exception should be logged as `error` before sending it to the error queue");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageSentToErrorException, Is.InstanceOf());
+ Assert.That(context.Logs.Any(l => l.Level == LogLevel.Error && l.Message.Contains("Simulated exception message")), Is.True, "The last exception should be logged as `error` before sending it to the error queue");
- // Immediate Retries max retries = 3 means we will be processing 4 times. Delayed Retries max retries = 2 means we will do 3 * Immediate Retries
- Assert.AreEqual(4 * 3, context.TotalNumberOfHandlerInvocations);
- Assert.AreEqual(3 * 3, context.TotalNumberOfImmediateRetriesEventInvocations);
- Assert.AreEqual(2, context.NumberOfDelayedRetriesPerformed);
+ // Immediate Retries max retries = 3 means we will be processing 4 times. Delayed Retries max retries = 2 means we will do 3 * Immediate Retries
+ Assert.That(context.TotalNumberOfHandlerInvocations, Is.EqualTo(4 * 3));
+ Assert.That(context.TotalNumberOfImmediateRetriesEventInvocations, Is.EqualTo(3 * 3));
+ Assert.That(context.NumberOfDelayedRetriesPerformed, Is.EqualTo(2));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_immediate_retries_notifications.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_immediate_retries_notifications.cs
index 04d2bd7ffb4..9abc9401bb4 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_immediate_retries_notifications.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_subscribing_to_immediate_retries_notifications.cs
@@ -21,11 +21,14 @@ public async Task Should_trigger_notification_on_immediate_retry()
.Done(c => c.MessageSentToError)
.Run();
- Assert.IsInstanceOf(context.LastImmediateRetryInfo.Exception);
- // Immediate Retries max retries = 3 means we will be processing 4 times. Delayed Retries max retries = 2 means we will do 3 * Immediate Retries
- Assert.AreEqual(4, context.TotalNumberOfHandlerInvocations);
- Assert.AreEqual(3, context.TotalNumberOfImmediateRetriesEventInvocations);
- Assert.AreEqual(2, context.LastImmediateRetryInfo.RetryAttempt);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.LastImmediateRetryInfo.Exception, Is.InstanceOf());
+ // Immediate Retries max retries = 3 means we will be processing 4 times. Delayed Retries max retries = 2 means we will do 3 * Immediate Retries
+ Assert.That(context.TotalNumberOfHandlerInvocations, Is.EqualTo(4));
+ Assert.That(context.TotalNumberOfImmediateRetriesEventInvocations, Is.EqualTo(3));
+ Assert.That(context.LastImmediateRetryInfo.RetryAttempt, Is.EqualTo(2));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transactions_off_and_delayed_retries_enabled.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transactions_off_and_delayed_retries_enabled.cs
index 680b77d00f6..7d3b2578882 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transactions_off_and_delayed_retries_enabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transactions_off_and_delayed_retries_enabled.cs
@@ -17,7 +17,7 @@ public void Should_throw_on_startup()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Delayed retries are not supported when running with TransportTransactionMode.None. Disable delayed retries using 'endpointConfiguration.Recoverability().Delayed(settings => settings.NumberOfRetries(0))' or select a different TransportTransactionMode.", exception.ToString());
+ Assert.That(exception.ToString(), Does.Contain("Delayed retries are not supported when running with TransportTransactionMode.None. Disable delayed retries using 'endpointConfiguration.Recoverability().Delayed(settings => settings.NumberOfRetries(0))' or select a different TransportTransactionMode."));
}
public class StartedEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transactions_off_and_immediate_retries_enabled.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transactions_off_and_immediate_retries_enabled.cs
index 8ae6772af0f..aefdd5b44ae 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transactions_off_and_immediate_retries_enabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transactions_off_and_immediate_retries_enabled.cs
@@ -15,7 +15,7 @@ public void Should_throw_on_startup()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Immediate retries are not supported", exception.ToString());
+ Assert.That(exception.ToString(), Does.Contain("Immediate retries are not supported"));
}
public class StartedEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transport_transaction_provided.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transport_transaction_provided.cs
index 91c143da690..6ced1014585 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transport_transaction_provided.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_transport_transaction_provided.cs
@@ -26,7 +26,7 @@ public async Task Should_be_available_in_pipeline()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.AreSame(context.IncomingPipelineTransportTransaction, context.DispatchPipelineTransportTransaction, "Transport Transaction was not the same");
+ Assert.That(context.DispatchPipelineTransportTransaction, Is.SameAs(context.IncomingPipelineTransportTransaction), "Transport Transaction was not the same");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Reliability/SynchronizedStorage/When_opening_storage_session_outside_pipeline.cs b/src/NServiceBus.AcceptanceTests/Core/Reliability/SynchronizedStorage/When_opening_storage_session_outside_pipeline.cs
index dd531da9386..ec1c9ded72d 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Reliability/SynchronizedStorage/When_opening_storage_session_outside_pipeline.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Reliability/SynchronizedStorage/When_opening_storage_session_outside_pipeline.cs
@@ -35,12 +35,15 @@ public async Task Should_provide_adapted_session_with_same_scope([Values(true, f
.Done(c => c.Done)
.Run();
- Assert.True(context.SessionNotNullAfterOpening, "The adapted session was null after opening the session.");
- Assert.True(context.StorageSessionEqual, "The scoped storage session should be equal.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SessionNotNullAfterOpening, Is.True, "The adapted session was null after opening the session.");
+ Assert.That(context.StorageSessionEqual, Is.True, "The scoped storage session should be equal.");
+ });
if (useOutbox)
{
- Assert.True(context.OutboxNotNullAfterOpening, "The scoped storage session should be equal.");
+ Assert.That(context.OutboxNotNullAfterOpening, Is.True, "The scoped storage session should be equal.");
}
}
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/AutomaticSubscriptions/When_handling_local_event.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/AutomaticSubscriptions/When_handling_local_event.cs
index 373aa24b400..38fde3ce95d 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/AutomaticSubscriptions/When_handling_local_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/AutomaticSubscriptions/When_handling_local_event.cs
@@ -25,7 +25,7 @@ public async Task Should_autosubscribe_to_event()
.Done(c => c.GotEvent)
.Run().ConfigureAwait(false);
- Assert.True(ctx.GotEvent);
+ Assert.That(ctx.GotEvent, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_callbacks_are_used_to_reply_with_int_or_enum.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_callbacks_are_used_to_reply_with_int_or_enum.cs
index 8ad630b0001..3ce8556704e 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_callbacks_are_used_to_reply_with_int_or_enum.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_callbacks_are_used_to_reply_with_int_or_enum.cs
@@ -17,11 +17,14 @@ public async Task Should_throw_late_enough_to_allow_intercept()
.Done(c => c.GotTheRequest)
.Run();
- Assert.True(context.GotExceptionFromReply);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.GotExceptionFromReply, Is.True);
- //this verifies a callbacks assumption that core won't throw until after the `IOutgoingLogicalMessageContext` stage
- // See https://github.com/Particular/NServiceBus.Callbacks/blob/develop/src/NServiceBus.Callbacks/Reply/SetCallbackResponseReturnCodeBehavior.cs#L7
- Assert.True(context.WasAbleToInterceptBeforeCoreThrows, "Callbacks needs to be able to intercept the pipeline before core throws");
+ //this verifies a callbacks assumption that core won't throw until after the `IOutgoingLogicalMessageContext` stage
+ // See https://github.com/Particular/NServiceBus.Callbacks/blob/develop/src/NServiceBus.Callbacks/Reply/SetCallbackResponseReturnCodeBehavior.cs#L7
+ Assert.That(context.WasAbleToInterceptBeforeCoreThrows, Is.True, "Callbacks needs to be able to intercept the pipeline before core throws");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_extending_command_routing_with_thisinstance.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_extending_command_routing_with_thisinstance.cs
index 03118f48af7..2419283e51f 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_extending_command_routing_with_thisinstance.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_extending_command_routing_with_thisinstance.cs
@@ -30,8 +30,11 @@ public async Task Should_route_according_to_distribution_strategy()
.Done(c => c.MessageDelivered >= 1)
.Run();
- Assert.AreEqual(1, ctx.MessageDelivered);
- Assert.IsTrue(ctx.StrategyCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ctx.MessageDelivered, Is.EqualTo(1));
+ Assert.That(ctx.StrategyCalled, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_inner_send_with_outer_immediate_dispatch.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_inner_send_with_outer_immediate_dispatch.cs
index 16f67881be1..5910f155122 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_inner_send_with_outer_immediate_dispatch.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_inner_send_with_outer_immediate_dispatch.cs
@@ -22,8 +22,11 @@ public async Task Should_not_apply_immediate_dispatch_to_inner_send()
.Done(c => c.MessageBReceived)
.Run(TimeSpan.FromSeconds(15));
- Assert.IsTrue(context.MessageBReceived);
- Assert.IsFalse(context.MessageCReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageBReceived, Is.True);
+ Assert.That(context.MessageCReceived, Is.False);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_nested_send_with_outer_replyTo_routing.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_nested_send_with_outer_replyTo_routing.cs
index bd986f06265..ca76f3d20d8 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_nested_send_with_outer_replyTo_routing.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_nested_send_with_outer_replyTo_routing.cs
@@ -28,8 +28,11 @@ public async Task Should_apply_default_reply_in_inner_send()
.Done(c => c.OuterMessageReceived && c.InnerMessageReceived)
.Run();
- Assert.AreEqual(customReplyAddress, context.OuterMessageReplyAddress);
- Assert.AreEqual(Conventions.EndpointNamingConvention(typeof(SenderEndpoint)), context.InnerMessageReplyAddress);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.OuterMessageReplyAddress, Is.EqualTo(customReplyAddress));
+ Assert.That(context.InnerMessageReplyAddress, Is.EqualTo(Conventions.EndpointNamingConvention(typeof(SenderEndpoint))));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs
index 64fa37a455d..16582328b63 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs
@@ -17,8 +17,11 @@ public async Task Should_route_to_sender()
.Done(c => c.GotTheReply)
.Run();
- Assert.True(context.GotTheReply);
- Assert.AreEqual(typeof(IMyReply), context.MessageTypeInPipeline);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.GotTheReply, Is.True);
+ Assert.That(context.MessageTypeInPipeline, Is.EqualTo(typeof(IMyReply)));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_routing_interface_message.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_routing_interface_message.cs
index b7409f2cc14..54ac411f3ca 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_routing_interface_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_routing_interface_message.cs
@@ -16,7 +16,7 @@ public async Task Should_use_interface_types_route()
.Done(c => c.GotTheMessage)
.Run();
- Assert.True(context.GotTheMessage);
+ Assert.That(context.GotTheMessage, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_from_outgoing_pipeline.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_from_outgoing_pipeline.cs
index ce47f64a432..d85049a720b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_from_outgoing_pipeline.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_from_outgoing_pipeline.cs
@@ -25,8 +25,11 @@ public async Task Should_use_default_routing_when_empty_send_options()
.Done(c => c.LocalMessageReceived && c.BehaviorMessageReceived)
.Run(TimeSpan.FromSeconds(15));
- Assert.True(context.LocalMessageReceived);
- Assert.True(context.BehaviorMessageReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.LocalMessageReceived, Is.True);
+ Assert.That(context.BehaviorMessageReceived, Is.True);
+ });
}
[Test]
@@ -43,8 +46,11 @@ public async Task Should_apply_send_options_routing()
.Done(c => c.LocalMessageReceived && c.BehaviorMessageReceived)
.Run(TimeSpan.FromSeconds(15));
- Assert.True(context.LocalMessageReceived);
- Assert.True(context.BehaviorMessageReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.LocalMessageReceived, Is.True);
+ Assert.That(context.BehaviorMessageReceived, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_non_message_with_routing_configured_by_assembly.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_non_message_with_routing_configured_by_assembly.cs
index e8c7800a9da..fb197d34da9 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_non_message_with_routing_configured_by_assembly.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_non_message_with_routing_configured_by_assembly.cs
@@ -27,7 +27,7 @@ public async Task Should_throw_when_sending()
.Done(c => c.GotTheException)
.Run();
- StringAssert.Contains("No destination specified for message", context.Exception.ToString());
+ Assert.That(context.Exception.ToString(), Does.Contain("No destination specified for message"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_non_message_with_routing_configured_by_type.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_non_message_with_routing_configured_by_type.cs
index 75e4c4f465f..6e204454d42 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_non_message_with_routing_configured_by_type.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_sending_non_message_with_routing_configured_by_type.cs
@@ -17,7 +17,7 @@ public void Should_throw_when_configuring_routing()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Cannot configure routing for type", exception.ToString());
+ Assert.That(exception.ToString(), Does.Contain("Cannot configure routing for type"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_a_saga_is_completed.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_a_saga_is_completed.cs
index 27e42340ed5..9db727f674e 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_a_saga_is_completed.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_a_saga_is_completed.cs
@@ -30,8 +30,11 @@ public async Task Saga_should_not_handle_subsequent_messages_for_that_sagadata()
.Done(c => c.AnotherMessageReceived)
.Run();
- Assert.True(context.AnotherMessageReceived, "AnotherMessage should have been delivered to the handler outside the saga");
- Assert.False(context.SagaReceivedAnotherMessage, "AnotherMessage should not be delivered to the saga after completion");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.AnotherMessageReceived, Is.True, "AnotherMessage should have been delivered to the handler outside the saga");
+ Assert.That(context.SagaReceivedAnotherMessage, Is.False, "AnotherMessage should not be delivered to the saga after completion");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_adding_state_to_context.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_adding_state_to_context.cs
index 55ada3de3d4..039d944d271 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_adding_state_to_context.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_adding_state_to_context.cs
@@ -24,8 +24,11 @@ public async Task Should_make_state_available_to_finder_context()
.Done(c => c.FinderUsed)
.Run();
- Assert.True(context.FinderUsed);
- Assert.AreEqual("SomeData", context.ContextBag.Get().SomeData);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.FinderUsed, Is.True);
+ Assert.That(context.ContextBag.Get().SomeData, Is.EqualTo("SomeData"));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_completing_a_saga.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_completing_a_saga.cs
index 62de9b130ed..9ab4bafc4c6 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_completing_a_saga.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_completing_a_saga.cs
@@ -26,7 +26,7 @@ public async Task Should_hydrate_and_complete_the_existing_instance()
.Done(c => c.SagaCompleted)
.Run();
- Assert.True(context.SagaCompleted);
+ Assert.That(context.SagaCompleted, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_finder_cant_find_saga_instance.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_finder_cant_find_saga_instance.cs
index 64713bfe4fe..8828c02b18b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_finder_cant_find_saga_instance.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_finder_cant_find_saga_instance.cs
@@ -21,8 +21,11 @@ public async Task Should_start_new_saga()
.Done(c => c.SagaStarted)
.Run();
- Assert.True(context.FinderUsed);
- Assert.True(context.SagaStarted);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.FinderUsed, Is.True);
+ Assert.That(context.SagaStarted, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_finder_returns_existing_saga.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_finder_returns_existing_saga.cs
index f8f0cd4c4d1..be2569b0e50 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_finder_returns_existing_saga.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_finder_returns_existing_saga.cs
@@ -26,7 +26,7 @@ public async Task Should_use_existing_saga()
.Done(c => c.HandledOtherMessage)
.Run();
- Assert.True(context.FinderUsed);
+ Assert.That(context.FinderUsed, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_handling_message_with_handler_and_timeout_handler.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_handling_message_with_handler_and_timeout_handler.cs
index 41fa5764de7..22955e63ac1 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_handling_message_with_handler_and_timeout_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_handling_message_with_handler_and_timeout_handler.cs
@@ -19,8 +19,11 @@ public async Task Should_not_invoke_timeout_handler()
.Done(c => c.HandlerInvoked || c.TimeoutHandlerInvoked)
.Run();
- Assert.True(context.HandlerInvoked, "Regular handler should be invoked");
- Assert.False(context.TimeoutHandlerInvoked, "Timeout handler should not be invoked");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HandlerInvoked, Is.True, "Regular handler should be invoked");
+ Assert.That(context.TimeoutHandlerInvoked, Is.False, "Timeout handler should not be invoked");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_mapping_saga_messages_using_base_classes.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_mapping_saga_messages_using_base_classes.cs
index 5a01f48ba5d..a0b6c8bd339 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_mapping_saga_messages_using_base_classes.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_mapping_saga_messages_using_base_classes.cs
@@ -25,7 +25,7 @@ public async Task Should_apply_base_class_mapping_to_sub_classes()
.Done(c => c.SecondMessageFoundExistingSaga)
.Run(TimeSpan.FromSeconds(20));
- Assert.True(context.SecondMessageFoundExistingSaga);
+ Assert.That(context.SecondMessageFoundExistingSaga, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_overriding_saga_id_creation.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_overriding_saga_id_creation.cs
index a54a2d2a8fd..89a5b38a493 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_overriding_saga_id_creation.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_overriding_saga_id_creation.cs
@@ -24,7 +24,7 @@ public async Task Should_generate_saga_id_accordingly()
.Done(c => c.SagaId.HasValue)
.Run();
- Assert.AreEqual(new Guid("1d99288a-418d-9e4d-46e4-d49a27908fc8"), context.SagaId);
+ Assert.That(context.SagaId, Is.EqualTo(new Guid("1d99288a-418d-9e4d-46e4-d49a27908fc8")));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_starting_a_new_saga.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_starting_a_new_saga.cs
index 752d493c0aa..247909c4551 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_starting_a_new_saga.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_starting_a_new_saga.cs
@@ -21,7 +21,7 @@ public async Task Should_automatically_assign_correlation_property_value()
.Done(c => c.SomeId != Guid.Empty)
.Run();
- Assert.AreEqual(context.SomeId, id);
+ Assert.That(id, Is.EqualTo(context.SomeId));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator.cs
index 47c8b21eaf9..945511ca70b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator.cs
@@ -30,8 +30,11 @@ public async Task Should_preserve_correlation_context()
.Done(c => c.CorrelationIdOnReply != null)
.Run();
- Assert.AreEqual(MessageIntent.Reply, context.Intent);
- Assert.AreEqual(context.OriginalCorrelationId, context.CorrelationIdOnReply, "Correlation id should be preserved so that things like callbacks work properly");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Intent, Is.EqualTo(MessageIntent.Reply));
+ Assert.That(context.CorrelationIdOnReply, Is.EqualTo(context.OriginalCorrelationId), "Correlation id should be preserved so that things like callbacks work properly");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator_and_outgoing_behavior.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator_and_outgoing_behavior.cs
index 5627d3d9ceb..6781e681f94 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator_and_outgoing_behavior.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator_and_outgoing_behavior.cs
@@ -30,9 +30,12 @@ public async Task Should_not_leak_correlation_context()
.Done(c => c.SagaContinued && c.ReplyToOriginatorReceived && c.BehaviorMessageReceived && c.BehaviorEventReceived)
.Run();
- Assert.AreEqual(context.StartingSagaCorrId, context.ReplyToOriginatorReceivedCorrId, "When using ReplyToOriginator, the correlationId should be the same of the message that originally started the saga");
- Assert.AreEqual(context.ContinueSagaMessageCorrId, context.HandlingBehaviorMessageCorrId, "When ReplyToOriginator is used, it shouldn't leak the CorrId to new messages sent from a behavior");
- Assert.AreEqual(context.ContinueSagaMessageCorrId, context.HandlingBehaviorEventCorrId, "When ReplyToOriginator is used, it shouldn't leak the CorrId to new events published from a behavior");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ReplyToOriginatorReceivedCorrId, Is.EqualTo(context.StartingSagaCorrId), "When using ReplyToOriginator, the correlationId should be the same of the message that originally started the saga");
+ Assert.That(context.HandlingBehaviorMessageCorrId, Is.EqualTo(context.ContinueSagaMessageCorrId), "When ReplyToOriginator is used, it shouldn't leak the CorrId to new messages sent from a behavior");
+ Assert.That(context.HandlingBehaviorEventCorrId, Is.EqualTo(context.ContinueSagaMessageCorrId), "When ReplyToOriginator is used, it shouldn't leak the CorrId to new events published from a behavior");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator_with_headers.cs b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator_with_headers.cs
index 3237c5e004a..f8a1c8d2bba 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator_with_headers.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Sagas/When_using_ReplyToOriginator_with_headers.cs
@@ -22,7 +22,7 @@ public async Task Should_send_headers()
.Done(c => c.CustomHeaderOnReply != null)
.Run();
- Assert.AreEqual(customHeaderValue.ToString(), context.CustomHeaderOnReply, "Header values should be forwarded");
+ Assert.That(context.CustomHeaderOnReply, Is.EqualTo(customHeaderValue.ToString()), "Header values should be forwarded");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/SelfVerification/ConventionEnforcementTests.cs b/src/NServiceBus.AcceptanceTests/Core/SelfVerification/ConventionEnforcementTests.cs
index 5d50fb481f6..68477fa9496 100644
--- a/src/NServiceBus.AcceptanceTests/Core/SelfVerification/ConventionEnforcementTests.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/SelfVerification/ConventionEnforcementTests.cs
@@ -18,7 +18,7 @@ public void Ensure_all_tests_derive_from_a_common_base_class()
.Where(t => t.BaseType == null || !typeof(NServiceBusAcceptanceTest).IsAssignableFrom(t))
.ToList();
- CollectionAssert.IsEmpty(missingBaseClass, string.Join(",", missingBaseClass));
+ Assert.That(missingBaseClass, Is.Empty, string.Join(",", missingBaseClass));
}
[Test]
@@ -35,7 +35,7 @@ public void Ensure_all_messages_are_public()
)
.ToList();
- CollectionAssert.IsEmpty(missingBaseClass, string.Join(",", missingBaseClass));
+ Assert.That(missingBaseClass, Is.Empty, string.Join(",", missingBaseClass));
}
[Test]
@@ -50,8 +50,8 @@ public void Ensure_all_diagnostics_tests_are_run_sequentially()
var diagnosticTestsWithoutNonParallelizableAttribute =
diagnosticTests.Where(t => t.GetCustomAttribute() == null);
- CollectionAssert.IsNotEmpty(diagnosticTests);
- CollectionAssert.IsEmpty(diagnosticTestsWithoutNonParallelizableAttribute, string.Join(",", diagnosticTests));
+ Assert.That(diagnosticTests, Is.Not.Empty);
+ Assert.That(diagnosticTestsWithoutNonParallelizableAttribute, Is.Empty, string.Join(",", diagnosticTests));
}
[Test]
@@ -64,7 +64,7 @@ public void Ensure_all_sagadatas_are_public()
.Where(t => typeof(IContainSagaData).IsAssignableFrom(t))
.ToList();
- CollectionAssert.IsEmpty(sagaDatas, string.Join(",", sagaDatas));
+ Assert.That(sagaDatas, Is.Empty, string.Join(",", sagaDatas));
}
static bool HasTestMethod(Type t)
diff --git a/src/NServiceBus.AcceptanceTests/Core/SelfVerification/EndpointNameEnforcementTests.cs b/src/NServiceBus.AcceptanceTests/Core/SelfVerification/EndpointNameEnforcementTests.cs
index e6f9e2bfd24..5396a7eeb32 100644
--- a/src/NServiceBus.AcceptanceTests/Core/SelfVerification/EndpointNameEnforcementTests.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/SelfVerification/EndpointNameEnforcementTests.cs
@@ -21,7 +21,7 @@ public void EndpointName_should_not_exceed_maximum_length()
.Where(t => AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(t).Length > endpointNameMaxLength)
.ToList();
- CollectionAssert.IsEmpty(violators, string.Join(",", violators));
+ Assert.That(violators, Is.Empty, string.Join(",", violators));
}
static bool IsEndpointClass(Type t) => endpointConfigurationBuilderType.IsAssignableFrom(t);
diff --git a/src/NServiceBus.AcceptanceTests/Core/SelfVerification/When_running_saga_tests.cs b/src/NServiceBus.AcceptanceTests/Core/SelfVerification/When_running_saga_tests.cs
index 39220b9e58b..2dc44d86538 100644
--- a/src/NServiceBus.AcceptanceTests/Core/SelfVerification/When_running_saga_tests.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/SelfVerification/When_running_saga_tests.cs
@@ -37,7 +37,7 @@ public void All_saga_entities_in_acceptance_tests_should_have_virtual_properties
}
}
- Assert.AreEqual(0, offenders);
+ Assert.That(offenders, Is.EqualTo(0));
}
[Test]
@@ -68,6 +68,6 @@ public void All_sagas_and_entities_should_have_unique_names()
usedNames.Add(cls.Name);
}
- Assert.AreEqual(0, offenders);
+ Assert.That(offenders, Is.EqualTo(0));
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.AcceptanceTests/Core/SelfVerification/When_using_custom_components.cs b/src/NServiceBus.AcceptanceTests/Core/SelfVerification/When_using_custom_components.cs
index f6c6d503fb6..03a9b7190ff 100644
--- a/src/NServiceBus.AcceptanceTests/Core/SelfVerification/When_using_custom_components.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/SelfVerification/When_using_custom_components.cs
@@ -17,9 +17,12 @@ public async Task Should_properly_start_and_stop_them()
.Done(c => c.Starting)
.Run();
- Assert.IsTrue(ctx.Starting);
- Assert.IsTrue(ctx.ComponentsStarted);
- Assert.IsTrue(ctx.Stopped);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ctx.Starting, Is.True);
+ Assert.That(ctx.ComponentsStarted, Is.True);
+ Assert.That(ctx.Stopped, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Stopping/When_feature_startup_task_throws_on_stop.cs b/src/NServiceBus.AcceptanceTests/Core/Stopping/When_feature_startup_task_throws_on_stop.cs
index 8b65aecdf9c..b4f768fa89b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Stopping/When_feature_startup_task_throws_on_stop.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Stopping/When_feature_startup_task_throws_on_stop.cs
@@ -22,8 +22,8 @@ public async Task Should_log_exception()
.Run();
var logItem = context.Logs.FirstOrDefault(item => item.Message.Contains("stopping of feature startup task") && item.Level == LogLevel.Warn);
- Assert.IsNotNull(logItem);
- StringAssert.Contains("Exception occurred during stopping of feature startup task 'CustomTask'. System.InvalidOperationException: CustomTaskThrows", logItem.Message);
+ Assert.That(logItem, Is.Not.Null);
+ Assert.That(logItem.Message, Does.Contain("Exception occurred during stopping of feature startup task 'CustomTask'. System.InvalidOperationException: CustomTaskThrows"));
}
public class EndpointThatThrowsOnInfrastructureStop : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Stopping/When_pump_throws_on_stop.cs b/src/NServiceBus.AcceptanceTests/Core/Stopping/When_pump_throws_on_stop.cs
index 356c16ba178..2f54b2a7429 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Stopping/When_pump_throws_on_stop.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Stopping/When_pump_throws_on_stop.cs
@@ -22,8 +22,8 @@ public async Task Should_not_throw_but_log_exception()
var logEntry = context.Logs.FirstOrDefault(l =>
l.LoggerName == "NServiceBus.ReceiveComponent" && l.Level == LogLevel.Warn);
- Assert.IsNotNull(logEntry);
- StringAssert.StartsWith("Receiver Main threw an exception on stopping. System.InvalidOperationException: ExceptionInPumpStop", logEntry.Message);
+ Assert.That(logEntry, Is.Not.Null);
+ Assert.That(logEntry.Message, Does.StartWith("Receiver Main threw an exception on stopping. System.InvalidOperationException: ExceptionInPumpStop"));
}
public class EndpointThatThrowsOnPumpStop : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/Stopping/When_transport_infrastructure_throws_on_stop.cs b/src/NServiceBus.AcceptanceTests/Core/Stopping/When_transport_infrastructure_throws_on_stop.cs
index 0b3066c9516..6f95f11e980 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Stopping/When_transport_infrastructure_throws_on_stop.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Stopping/When_transport_infrastructure_throws_on_stop.cs
@@ -20,8 +20,8 @@ public async Task Should_log_exception()
.Run();
var logItem = context.Logs.FirstOrDefault(item => item.Message.Contains("Shutdown of the transport") && item.Level == LogLevel.Error);
- Assert.IsNotNull(logItem);
- StringAssert.Contains("Shutdown of the transport infrastructure failed. System.InvalidOperationException: ExceptionInInfrastructureStop", logItem.Message);
+ Assert.That(logItem, Is.Not.Null);
+ Assert.That(logItem.Message, Does.Contain("Shutdown of the transport infrastructure failed. System.InvalidOperationException: ExceptionInInfrastructureStop"));
}
public class EndpointThatThrowsOnInfrastructureStop : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_publisher_has_subscription_migration_mode_enabled.cs b/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_publisher_has_subscription_migration_mode_enabled.cs
index 93c0fbe665f..9bda72d689b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_publisher_has_subscription_migration_mode_enabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_publisher_has_subscription_migration_mode_enabled.cs
@@ -18,8 +18,11 @@ public async Task CanHandleMessageDrivenSubscribers()
.Done(c => c.EventReceived)
.Run();
- Assert.IsTrue(context.EventReceived);
- Assert.AreEqual(Conventions.EndpointNamingConvention(typeof(MessageDrivenSubscriber)), context.Subscriber);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.EventReceived, Is.True);
+ Assert.That(context.Subscriber, Is.EqualTo(Conventions.EndpointNamingConvention(typeof(MessageDrivenSubscriber))));
+ });
}
[Test]
@@ -32,7 +35,7 @@ public async Task CanHandleNativeSubscribers()
.Done(c => c.EventReceived)
.Run();
- Assert.IsTrue(context.EventReceived);
+ Assert.That(context.EventReceived, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_send_only_endpoint_uses_migration_mode.cs b/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_send_only_endpoint_uses_migration_mode.cs
index e380b2278dd..f2ea851bdfd 100644
--- a/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_send_only_endpoint_uses_migration_mode.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_send_only_endpoint_uses_migration_mode.cs
@@ -16,7 +16,7 @@ public void Should_throw_InvalidOperationException_on_subscribe()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Send-only endpoints cannot subscribe to events", exception.Message);
+ Assert.That(exception.Message, Does.Contain("Send-only endpoints cannot subscribe to events"));
}
[Test]
@@ -28,7 +28,7 @@ public void Should_throw_InvalidOperationException_on_unsubscribe()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("Send-only endpoints cannot unsubscribe to events", exception.Message);
+ Assert.That(exception.Message, Does.Contain("Send-only endpoints cannot unsubscribe to events"));
}
class SendOnlyEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_subscriber_has_subscription_migration_mode_enabled.cs b/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_subscriber_has_subscription_migration_mode_enabled.cs
index 92b857ffaec..66263b6f1b4 100644
--- a/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_subscriber_has_subscription_migration_mode_enabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/SubscriptionMigration/When_subscriber_has_subscription_migration_mode_enabled.cs
@@ -19,8 +19,11 @@ public async Task CanSubscribeToMessageDrivenPublishers()
.Done(c => c.EventReceived)
.Run();
- Assert.IsTrue(context.EventReceived);
- Assert.AreEqual(Conventions.EndpointNamingConvention(typeof(MigratedSubscriber)), context.Subscriber);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.EventReceived, Is.True);
+ Assert.That(context.Subscriber, Is.EqualTo(Conventions.EndpointNamingConvention(typeof(MigratedSubscriber))));
+ });
}
[Test]
@@ -33,7 +36,7 @@ public async Task CanSubscribeToNativePublishers()
.Done(c => c.EventReceived)
.Run();
- Assert.IsTrue(context.EventReceived);
+ Assert.That(context.EventReceived, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/Transactions/When_transport_supports_transaction_scope_on_windows.cs b/src/NServiceBus.AcceptanceTests/Core/Transactions/When_transport_supports_transaction_scope_on_windows.cs
index c1c55cc8fad..85467ee3dbb 100644
--- a/src/NServiceBus.AcceptanceTests/Core/Transactions/When_transport_supports_transaction_scope_on_windows.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/Transactions/When_transport_supports_transaction_scope_on_windows.cs
@@ -30,7 +30,7 @@ await Scenario.Define()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.True(fakeTransport.DtcIsAvailable, fakeTransport.DtcCheckException?.Message);
+ Assert.That(fakeTransport.DtcIsAvailable, Is.True, fakeTransport.DtcCheckException?.Message);
}
public class TransactionScopeEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_configuring_transport.cs b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_configuring_transport.cs
index af7b413f3d9..54c4268ad71 100644
--- a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_configuring_transport.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_configuring_transport.cs
@@ -17,7 +17,7 @@ public async Task Should_provide_transport_definition_to_features()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.IsNotNull(context.TransportDefinition);
+ Assert.That(context.TransportDefinition, Is.Not.Null);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_initializing_transport.cs b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_initializing_transport.cs
index 452b8a9f9f7..9e1402d6e4c 100644
--- a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_initializing_transport.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_initializing_transport.cs
@@ -18,14 +18,14 @@ public async Task Should_follow_the_startup_sequence()
.Done(c => c.EndpointsStarted)
.Run();
- CollectionAssert.AreEqual(new List
+ Assert.That(context.StartUpSequence, Is.EqualTo(new List
{
$"{nameof(TransportDefinition)}.{nameof(TransportDefinition.Initialize)}",
$"{nameof(IMessageReceiver)}.{nameof(IMessageReceiver.Initialize)} for receiver Main",
$"{nameof(IMessageReceiver)}.{nameof(IMessageReceiver.StartReceive)} for receiver Main",
$"{nameof(IMessageReceiver)}.{nameof(IMessageReceiver.StopReceive)} for receiver Main",
$"{nameof(TransportInfrastructure)}.{nameof(TransportInfrastructure.Shutdown)}",
- }, context.StartUpSequence);
+ }).AsCollection);
}
[Test]
@@ -36,11 +36,11 @@ public async Task Should_follow_the_startup_sequence_for_send_only_endpoints()
.Done(c => c.EndpointsStarted)
.Run();
- CollectionAssert.AreEqual(new List
+ Assert.That(context.StartUpSequence, Is.EqualTo(new List
{
$"{nameof(TransportDefinition)}.{nameof(TransportDefinition.Initialize)}",
$"{nameof(TransportInfrastructure)}.{nameof(TransportInfrastructure.Shutdown)}",
- }, context.StartUpSequence);
+ }).AsCollection);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_querying_for_transaction_mode.cs b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_querying_for_transaction_mode.cs
index 860961107c7..4641bf0234b 100644
--- a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_querying_for_transaction_mode.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_querying_for_transaction_mode.cs
@@ -17,7 +17,7 @@ public async Task Should_retrieve_value_set_for_transport_transaction_mode()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.AreEqual(TransportTransactionMode.ReceiveOnly, context.TransactionModeFromSettingsExtensions, "Transport transaction mode for the endpoint did not match the expected value.");
+ Assert.That(context.TransactionModeFromSettingsExtensions, Is.EqualTo(TransportTransactionMode.ReceiveOnly), "Transport transaction mode for the endpoint did not match the expected value.");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started.cs b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started.cs
index f1b6a586661..2e75e5073e5 100644
--- a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started.cs
@@ -21,12 +21,15 @@ public async Task Should_provide_access_to_addresses_and_address_resolution()
var endpointName = AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(Endpoint));
- Assert.AreEqual("SomeAddress", context.ResolvedAddress);
- Assert.AreEqual(endpointName, context.ReceiveAddresses.MainReceiveAddress);
- Assert.AreEqual(endpointName + "-MyInstance", context.ReceiveAddresses.InstanceReceiveAddress);
- Assert.AreEqual("MySatellite", context.ReceiveAddresses.SatelliteReceiveAddresses.Single());
- Assert.AreEqual(endpointName, context.LocalQueueAddress.ToString());
- Assert.AreEqual(endpointName + "-MyInstance", context.InstanceSpecificQueueAddress.ToString());
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ResolvedAddress, Is.EqualTo("SomeAddress"));
+ Assert.That(context.ReceiveAddresses.MainReceiveAddress, Is.EqualTo(endpointName));
+ Assert.That(context.ReceiveAddresses.InstanceReceiveAddress, Is.EqualTo(endpointName + "-MyInstance"));
+ Assert.That(context.ReceiveAddresses.SatelliteReceiveAddresses.Single(), Is.EqualTo("MySatellite"));
+ Assert.That(context.LocalQueueAddress.ToString(), Is.EqualTo(endpointName));
+ Assert.That(context.InstanceSpecificQueueAddress.ToString(), Is.EqualTo(endpointName + "-MyInstance"));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started_send_only.cs b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started_send_only.cs
index facbe75f6e5..ba3d76aa475 100644
--- a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started_send_only.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started_send_only.cs
@@ -19,7 +19,7 @@ public async Task Should_provide_access_to_address_resolution()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.AreEqual("SomeAddress", context.ResolvedAddress);
+ Assert.That(context.ResolvedAddress, Is.EqualTo("SomeAddress"));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_transactionscope_enabled.cs b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_transactionscope_enabled.cs
index 6062e846713..70c6fbc7901 100644
--- a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_transactionscope_enabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_transactionscope_enabled.cs
@@ -16,8 +16,11 @@ public async Task Should_wrap_the_handlers_in_a_scope()
.Done(c => c.Done)
.Run();
- Assert.True(context.AmbientTransactionPresent, "There should be a ambient transaction present");
- Assert.AreEqual(context.IsolationLevel, IsolationLevel.RepeatableRead, "There should be a ambient transaction present");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.AmbientTransactionPresent, Is.True, "There should be a ambient transaction present");
+ Assert.That(context.IsolationLevel, Is.EqualTo(IsolationLevel.RepeatableRead), "There should be a ambient transaction present");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_used_with_default_transaction_mode.cs b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_used_with_default_transaction_mode.cs
index e8833f50e97..600427e0654 100644
--- a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_used_with_default_transaction_mode.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_used_with_default_transaction_mode.cs
@@ -25,7 +25,7 @@ public async Task Should_work()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.True(context.EndpointsStarted);
+ Assert.That(context.EndpointsStarted, Is.True);
}
public class ScopeEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_used_with_transport_scopes.cs b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_used_with_transport_scopes.cs
index c207004189c..58545991516 100644
--- a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_used_with_transport_scopes.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_used_with_transport_scopes.cs
@@ -27,7 +27,7 @@ await Scenario.Define()
.Run();
});
- Assert.True(exception.Message.Contains("A Transaction scope unit of work can't be used when the transport already uses a scope"));
+ Assert.That(exception.Message, Does.Contain("A Transaction scope unit of work can't be used when the transport already uses a scope"));
}
public class ScopeEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_using_timeout_greater_than_machine_max.cs b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_using_timeout_greater_than_machine_max.cs
index cf04e7b2cf4..820675043ed 100644
--- a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_using_timeout_greater_than_machine_max.cs
+++ b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/TransactionScope/When_using_timeout_greater_than_machine_max.cs
@@ -17,7 +17,7 @@ await Scenario.Define()
.Run();
});
- Assert.True(exception.Message.Contains("Timeout requested is longer than the maximum value for this machine"));
+ Assert.That(exception.Message, Does.Contain("Timeout requested is longer than the maximum value for this machine"));
}
public class ScopeEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Correlation/When_replying_to_received_message_without_correlationid.cs b/src/NServiceBus.AcceptanceTests/Correlation/When_replying_to_received_message_without_correlationid.cs
index 2f5c8f7ea78..bc51f177d0e 100644
--- a/src/NServiceBus.AcceptanceTests/Correlation/When_replying_to_received_message_without_correlationid.cs
+++ b/src/NServiceBus.AcceptanceTests/Correlation/When_replying_to_received_message_without_correlationid.cs
@@ -24,7 +24,7 @@ public async Task Should_use_the_incoming_message_id_as_the_correlation_id()
.Done(c => c.GotResponse)
.Run();
- Assert.AreEqual(mycustomid, context.CorrelationIdReceived, "Correlation id should match MessageId");
+ Assert.That(context.CorrelationIdReceived, Is.EqualTo(mycustomid), "Correlation id should match MessageId");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Correlation/When_sending_with_no_correlation_id.cs b/src/NServiceBus.AcceptanceTests/Correlation/When_sending_with_no_correlation_id.cs
index 4ada0440aa0..753b3b5eaea 100644
--- a/src/NServiceBus.AcceptanceTests/Correlation/When_sending_with_no_correlation_id.cs
+++ b/src/NServiceBus.AcceptanceTests/Correlation/When_sending_with_no_correlation_id.cs
@@ -15,7 +15,7 @@ public async Task Should_use_the_message_id_as_the_correlation_id()
.Done(c => c.GotRequest)
.Run();
- Assert.AreEqual(context.MessageIdReceived, context.CorrelationIdReceived, "Correlation id should match MessageId");
+ Assert.That(context.CorrelationIdReceived, Is.EqualTo(context.MessageIdReceived), "Correlation id should match MessageId");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/DataBus/When_sender_serializer_differ.cs b/src/NServiceBus.AcceptanceTests/DataBus/When_sender_serializer_differ.cs
index ea043790c47..6832c8bc0a8 100644
--- a/src/NServiceBus.AcceptanceTests/DataBus/When_sender_serializer_differ.cs
+++ b/src/NServiceBus.AcceptanceTests/DataBus/When_sender_serializer_differ.cs
@@ -31,7 +31,7 @@ public async Task Should_deserialize_based_on_serializer_used()
.Done(c => c.ReceivedPayload != null)
.Run();
- Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
+ Assert.That(context.ReceivedPayload, Is.EqualTo(payloadToSend), "The large payload should be marshalled correctly using the databus");
}
const int PayloadSize = 500;
diff --git a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_from_different_environments.cs b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_from_different_environments.cs
index cc10f66e86b..51fa6850e43 100644
--- a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_from_different_environments.cs
+++ b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_from_different_environments.cs
@@ -31,7 +31,7 @@ public async Task Should_receive_messages_with_largepayload_correctly_from_windo
.Done(c => c.ReceivedPayload != null)
.Run();
- Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
+ Assert.That(context.ReceivedPayload, Is.EqualTo(payloadToSend), "The large payload should be marshalled correctly using the databus");
}
[Test]
@@ -48,7 +48,7 @@ public async Task Should_receive_messages_with_largepayload_correctly_from_linux
.Done(c => c.ReceivedPayload != null)
.Run();
- Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
+ Assert.That(context.ReceivedPayload, Is.EqualTo(payloadToSend), "The large payload should be marshalled correctly using the databus");
}
const int PayloadSize = 500;
diff --git a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjson_message_serializer.cs b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjson_message_serializer.cs
index 9b0dd00d1ee..33a32e4ec06 100644
--- a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjson_message_serializer.cs
+++ b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjson_message_serializer.cs
@@ -30,7 +30,7 @@ public async Task Should_receive_messages_with_largepayload_correctly()
.Done(c => c.ReceivedPayload != null)
.Run();
- Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
+ Assert.That(context.ReceivedPayload, Is.EqualTo(payloadToSend), "The large payload should be marshalled correctly using the databus");
}
const int PayloadSize = 500;
diff --git a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_xml_message_serializer.cs b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_xml_message_serializer.cs
index bf705167c11..3a9bf69ed81 100644
--- a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_xml_message_serializer.cs
+++ b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_xml_message_serializer.cs
@@ -30,7 +30,7 @@ public async Task Should_receive_messages_with_largepayload_correctly()
.Done(c => c.ReceivedPayload != null)
.Run();
- Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
+ Assert.That(context.ReceivedPayload, Is.EqualTo(payloadToSend), "The large payload should be marshalled correctly using the databus");
}
const int PayloadSize = 500;
diff --git a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_unobtrusive_databus_properties_with_systemjson_message_serializer.cs b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_unobtrusive_databus_properties_with_systemjson_message_serializer.cs
index e60d45c9371..8734d3a0fe1 100644
--- a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_unobtrusive_databus_properties_with_systemjson_message_serializer.cs
+++ b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_unobtrusive_databus_properties_with_systemjson_message_serializer.cs
@@ -30,7 +30,7 @@ public async Task Should_receive_messages_with_largepayload_correctly()
.Done(c => c.ReceivedPayload != null)
.Run();
- Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
+ Assert.That(context.ReceivedPayload, Is.EqualTo(payloadToSend), "The large payload should be marshalled correctly using the databus");
}
const int PayloadSize = 500;
diff --git a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_unobtrusive_databus_properties_with_xml_message_serializer.cs b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_unobtrusive_databus_properties_with_xml_message_serializer.cs
index 541f7e4afed..c4e589b47d4 100644
--- a/src/NServiceBus.AcceptanceTests/DataBus/When_sending_unobtrusive_databus_properties_with_xml_message_serializer.cs
+++ b/src/NServiceBus.AcceptanceTests/DataBus/When_sending_unobtrusive_databus_properties_with_xml_message_serializer.cs
@@ -30,7 +30,7 @@ public async Task Should_receive_messages_with_largepayload_correctly()
.Done(c => c.ReceivedPayload != null)
.Run();
- Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
+ Assert.That(context.ReceivedPayload, Is.EqualTo(payloadToSend), "The large payload should be marshalled correctly using the databus");
}
const int PayloadSize = 500;
diff --git a/src/NServiceBus.AcceptanceTests/DataBus/When_using_custom_IDataBus.cs b/src/NServiceBus.AcceptanceTests/DataBus/When_using_custom_IDataBus.cs
index 9c88448825a..9cbbbd5b74e 100644
--- a/src/NServiceBus.AcceptanceTests/DataBus/When_using_custom_IDataBus.cs
+++ b/src/NServiceBus.AcceptanceTests/DataBus/When_using_custom_IDataBus.cs
@@ -30,7 +30,7 @@ public async Task Should_be_able_to_register_via_fluent()
.Done(c => c.ReceivedPayload != null)
.Run();
- Assert.AreEqual(PayloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
+ Assert.That(context.ReceivedPayload, Is.EqualTo(PayloadToSend), "The large payload should be marshalled correctly using the databus");
}
static byte[] PayloadToSend = new byte[1024 * 10];
diff --git a/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_Deferring_a_message.cs b/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_Deferring_a_message.cs
index a89118afd47..0476531547a 100644
--- a/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_Deferring_a_message.cs
+++ b/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_Deferring_a_message.cs
@@ -31,7 +31,7 @@ public async Task Should_delay_delivery()
.Run();
var sendReceiveDifference = context.ReceivedAt - context.SentAt;
- Assert.GreaterOrEqual(sendReceiveDifference, delay);
+ Assert.That(sendReceiveDifference, Is.GreaterThanOrEqualTo(delay));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_a_message_to_the_past.cs b/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_a_message_to_the_past.cs
index 92ce0e5faf0..260d6c6091f 100644
--- a/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_a_message_to_the_past.cs
+++ b/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_a_message_to_the_past.cs
@@ -26,7 +26,7 @@ public async Task Should_deliver_message()
.Done(c => c.MessageReceived)
.Run();
- Assert.IsTrue(context.MessageReceived);
+ Assert.That(context.MessageReceived, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_outer_send.cs b/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_outer_send.cs
index b94fa8ed903..825d158e58b 100644
--- a/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_outer_send.cs
+++ b/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_outer_send.cs
@@ -27,8 +27,11 @@ public async Task Should_not_defer_inner_send()
.Done(c => c.ReceivedNonDelayedMessage && c.ReceivedDelayedMessage)
.Run();
- Assert.IsTrue(context.DelayedMessageDelayed, "should delay the message sent with 'DelayDeliveryWith'");
- Assert.IsFalse(context.NonDelayedMessageDelayed, "should not delay the message sent with default options");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.DelayedMessageDelayed, Is.True, "should delay the message sent with 'DelayDeliveryWith'");
+ Assert.That(context.NonDelayedMessageDelayed, Is.False, "should not delay the message sent with default options");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_to_non_local.cs b/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_to_non_local.cs
index 9953ed084eb..3e3c8db78fd 100644
--- a/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_to_non_local.cs
+++ b/src/NServiceBus.AcceptanceTests/DelayedDelivery/When_deferring_to_non_local.cs
@@ -31,7 +31,7 @@ public async Task Message_should_be_received()
.Done(c => c.WasCalled)
.Run();
- Assert.GreaterOrEqual(context.ReceivedAt - context.SentAt, delay);
+ Assert.That(context.ReceivedAt - context.SentAt, Is.GreaterThanOrEqualTo(delay));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Feature/When_purging_queues.cs b/src/NServiceBus.AcceptanceTests/Feature/When_purging_queues.cs
index d10cad94f5a..65a8a02a5cb 100644
--- a/src/NServiceBus.AcceptanceTests/Feature/When_purging_queues.cs
+++ b/src/NServiceBus.AcceptanceTests/Feature/When_purging_queues.cs
@@ -19,7 +19,7 @@ public async Task Should_purge_before_FeatureStartupTasks()
.Done(c => c.LocalMessageReceived)
.Run();
- Assert.IsTrue(context.LocalMessageReceived);
+ Assert.That(context.LocalMessageReceived, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Feature/When_subscribing_in_FST.cs b/src/NServiceBus.AcceptanceTests/Feature/When_subscribing_in_FST.cs
index 57a43f7b8c8..fb6ca4151bf 100644
--- a/src/NServiceBus.AcceptanceTests/Feature/When_subscribing_in_FST.cs
+++ b/src/NServiceBus.AcceptanceTests/Feature/When_subscribing_in_FST.cs
@@ -23,7 +23,7 @@ public async Task Should_receive_subscribed_events_native()
.Done(c => c.LocalEventReceived)
.Run();
- Assert.IsTrue(context.LocalEventReceived);
+ Assert.That(context.LocalEventReceived, Is.True);
}
[Test]
@@ -37,7 +37,7 @@ public async Task Should_receive_subscribed_events_mdps()
.Done(c => c.LocalEventReceived)
.Run();
- Assert.IsTrue(context.LocalEventReceived);
+ Assert.That(context.LocalEventReceived, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Forwarding/When_requesting_message_to_be_forwarded.cs b/src/NServiceBus.AcceptanceTests/Forwarding/When_requesting_message_to_be_forwarded.cs
index 27c2c0974f9..69b4c7d3a61 100644
--- a/src/NServiceBus.AcceptanceTests/Forwarding/When_requesting_message_to_be_forwarded.cs
+++ b/src/NServiceBus.AcceptanceTests/Forwarding/When_requesting_message_to_be_forwarded.cs
@@ -18,8 +18,8 @@ public async Task Should_forward_message()
.Done(c => c.GotForwardedMessage)
.Run();
- Assert.IsTrue(context.GotForwardedMessage);
- CollectionAssert.AreEqual(context.ForwardedHeaders, context.ReceivedHeaders, "Headers should be preserved on the forwarded message");
+ Assert.That(context.GotForwardedMessage, Is.True);
+ Assert.That(context.ReceivedHeaders, Is.EqualTo(context.ForwardedHeaders).AsCollection, "Headers should be preserved on the forwarded message");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/MessageId/When_message_has_empty_id_header.cs b/src/NServiceBus.AcceptanceTests/MessageId/When_message_has_empty_id_header.cs
index 934218d7c64..28fb1811acd 100644
--- a/src/NServiceBus.AcceptanceTests/MessageId/When_message_has_empty_id_header.cs
+++ b/src/NServiceBus.AcceptanceTests/MessageId/When_message_has_empty_id_header.cs
@@ -19,8 +19,11 @@ public async Task A_message_id_is_generated_by_the_transport_layer()
.Done(c => c.MessageReceived)
.Run();
- Assert.IsFalse(string.IsNullOrWhiteSpace(context.MessageId));
- Assert.AreEqual(context.MessageId, context.Headers[Headers.MessageId], "Should populate the NServiceBus.MessageId header with the new value");
+ Assert.Multiple(() =>
+ {
+ Assert.That(string.IsNullOrWhiteSpace(context.MessageId), Is.False);
+ Assert.That(context.Headers[Headers.MessageId], Is.EqualTo(context.MessageId), "Should populate the NServiceBus.MessageId header with the new value");
+ });
}
class CorruptionBehavior : IBehavior
diff --git a/src/NServiceBus.AcceptanceTests/MessageId/When_message_has_no_id_header.cs b/src/NServiceBus.AcceptanceTests/MessageId/When_message_has_no_id_header.cs
index def6a892738..da173a95591 100644
--- a/src/NServiceBus.AcceptanceTests/MessageId/When_message_has_no_id_header.cs
+++ b/src/NServiceBus.AcceptanceTests/MessageId/When_message_has_no_id_header.cs
@@ -18,7 +18,7 @@ public async Task A_message_id_is_generated_by_the_transport_layer_on_receiving_
.Done(c => c.MessageReceived)
.Run();
- Assert.IsFalse(string.IsNullOrWhiteSpace(context.MessageId));
+ Assert.That(string.IsNullOrWhiteSpace(context.MessageId), Is.False);
}
class CorruptionBehavior : IBehavior
diff --git a/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj b/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj
index fb2ec7e80c2..e24d10bc905 100644
--- a/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj
+++ b/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj
@@ -12,6 +12,7 @@
+
diff --git a/src/NServiceBus.AcceptanceTests/NServiceBusAcceptanceTest.cs b/src/NServiceBus.AcceptanceTests/NServiceBusAcceptanceTest.cs
index 88f786a3efa..af888e1ab93 100644
--- a/src/NServiceBus.AcceptanceTests/NServiceBusAcceptanceTest.cs
+++ b/src/NServiceBus.AcceptanceTests/NServiceBusAcceptanceTest.cs
@@ -48,23 +48,23 @@ public void TearDown()
if (Environment.GetEnvironmentVariable("CI") != "true" || Environment.GetEnvironmentVariable("VERBOSE_TEST_LOGGING")?.ToLower() == "true")
{
- TestContext.WriteLine($@"Test settings:
+ TestContext.Out.WriteLine($@"Test settings:
{string.Join(Environment.NewLine, runDescriptor.Settings.Select(setting => $" {setting.Key}: {setting.Value}"))}");
- TestContext.WriteLine($@"Context:
+ TestContext.Out.WriteLine($@"Context:
{string.Join(Environment.NewLine, scenarioContext.GetType().GetProperties().Select(p => $"{p.Name} = {p.GetValue(scenarioContext, null)}"))}");
}
if (TestExecutionContext.CurrentContext.CurrentResult.ResultState == ResultState.Failure || TestExecutionContext.CurrentContext.CurrentResult.ResultState == ResultState.Error)
{
- TestContext.WriteLine(string.Empty);
- TestContext.WriteLine($"Log entries (log level: {scenarioContext.LogLevel}):");
- TestContext.WriteLine("--- Start log entries ---------------------------------------------------");
+ TestContext.Out.WriteLine(string.Empty);
+ TestContext.Out.WriteLine($"Log entries (log level: {scenarioContext.LogLevel}):");
+ TestContext.Out.WriteLine("--- Start log entries ---------------------------------------------------");
foreach (var logEntry in scenarioContext.Logs)
{
- TestContext.WriteLine($"{logEntry.Timestamp:T} {logEntry.Level} {logEntry.Endpoint ?? TestContext.CurrentContext.Test.Name}: {logEntry.Message}");
+ TestContext.Out.WriteLine($"{logEntry.Timestamp:T} {logEntry.Level} {logEntry.Endpoint ?? TestContext.CurrentContext.Test.Name}: {logEntry.Message}");
}
- TestContext.WriteLine("--- End log entries ---------------------------------------------------");
+ TestContext.Out.WriteLine("--- End log entries ---------------------------------------------------");
}
}
}
diff --git a/src/NServiceBus.AcceptanceTests/Outbox/When_a_duplicate_message_arrives.cs b/src/NServiceBus.AcceptanceTests/Outbox/When_a_duplicate_message_arrives.cs
index 2ae6b035b8c..e01cb217d4e 100644
--- a/src/NServiceBus.AcceptanceTests/Outbox/When_a_duplicate_message_arrives.cs
+++ b/src/NServiceBus.AcceptanceTests/Outbox/When_a_duplicate_message_arrives.cs
@@ -35,8 +35,11 @@ await session.SendLocal(new PlaceOrder
.Done(c => c.Done && c.MessagesReceivedByDownstreamEndpoint >= 2 && c.MessagesReceivedByOutboxEndpoint >= 2)
.Run();
- Assert.AreEqual(2, context.MessagesReceivedByDownstreamEndpoint);
- Assert.AreEqual(2, context.MessagesReceivedByOutboxEndpoint);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessagesReceivedByDownstreamEndpoint, Is.EqualTo(2));
+ Assert.That(context.MessagesReceivedByOutboxEndpoint, Is.EqualTo(2));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Outbox/When_a_message_is_audited.cs b/src/NServiceBus.AcceptanceTests/Outbox/When_a_message_is_audited.cs
index e7939a41e6f..4cb44d09af1 100644
--- a/src/NServiceBus.AcceptanceTests/Outbox/When_a_message_is_audited.cs
+++ b/src/NServiceBus.AcceptanceTests/Outbox/When_a_message_is_audited.cs
@@ -24,7 +24,7 @@ public async Task Should_dispatch_audit_message_immediately()
.Done(c => c.MessageAudited)
.Run();
- Assert.True(context.MessageAudited);
+ Assert.That(context.MessageAudited, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Outbox/When_blowing_up_just_after_dispatch.cs b/src/NServiceBus.AcceptanceTests/Outbox/When_blowing_up_just_after_dispatch.cs
index 738d2f237f4..21fe985d7bf 100644
--- a/src/NServiceBus.AcceptanceTests/Outbox/When_blowing_up_just_after_dispatch.cs
+++ b/src/NServiceBus.AcceptanceTests/Outbox/When_blowing_up_just_after_dispatch.cs
@@ -21,7 +21,7 @@ public async Task Should_still_release_the_outgoing_messages_to_the_transport()
.Done(c => c.OrderAckReceived)
.Run(TimeSpan.FromSeconds(20));
- Assert.IsTrue(context.OrderAckReceived, "Order ack should have been received since outbox dispatch isn't part of the receive tx");
+ Assert.That(context.OrderAckReceived, Is.True, "Order ack should have been received since outbox dispatch isn't part of the receive tx");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Outbox/When_headers_contain_special_characters.cs b/src/NServiceBus.AcceptanceTests/Outbox/When_headers_contain_special_characters.cs
index 08bde014a4a..01de6e12128 100644
--- a/src/NServiceBus.AcceptanceTests/Outbox/When_headers_contain_special_characters.cs
+++ b/src/NServiceBus.AcceptanceTests/Outbox/When_headers_contain_special_characters.cs
@@ -35,8 +35,8 @@ public async Task Outbox_should_work()
.Done(c => c.MessageReceived)
.Run();
- Assert.IsNotEmpty(context.UnicodeHeaders);
- CollectionAssert.IsSubsetOf(sentHeaders, context.UnicodeHeaders);
+ Assert.That(context.UnicodeHeaders, Is.Not.Empty);
+ Assert.That(sentHeaders, Is.SubsetOf(context.UnicodeHeaders));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Outbox/When_publishing_with_outbox.cs b/src/NServiceBus.AcceptanceTests/Outbox/When_publishing_with_outbox.cs
index 64a3bef7132..f188abb78fa 100644
--- a/src/NServiceBus.AcceptanceTests/Outbox/When_publishing_with_outbox.cs
+++ b/src/NServiceBus.AcceptanceTests/Outbox/When_publishing_with_outbox.cs
@@ -55,8 +55,11 @@ public async Task Should_be_delivered_to_all_subscribers()
.Done(c => c.Subscriber1GotTheEvent && c.Subscriber2GotTheEvent)
.Run(TimeSpan.FromSeconds(10));
- Assert.True(context.Subscriber1GotTheEvent);
- Assert.True(context.Subscriber2GotTheEvent);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Subscriber1GotTheEvent, Is.True);
+ Assert.That(context.Subscriber2GotTheEvent, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Outbox/When_receiving_a_message.cs b/src/NServiceBus.AcceptanceTests/Outbox/When_receiving_a_message.cs
index 0688ed74561..6bcb6eb6317 100644
--- a/src/NServiceBus.AcceptanceTests/Outbox/When_receiving_a_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Outbox/When_receiving_a_message.cs
@@ -18,7 +18,7 @@ public async Task Should_handle_it()
.Done(c => c.OrderAckReceived == 1)
.Run(TimeSpan.FromSeconds(20));
- Assert.AreEqual(1, context.OrderAckReceived, "Order ack should have been received");
+ Assert.That(context.OrderAckReceived, Is.EqualTo(1), "Order ack should have been received");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Pipeline/When_a_message_is_audited.cs b/src/NServiceBus.AcceptanceTests/Pipeline/When_a_message_is_audited.cs
index 06d74af6c35..46d3997e6fd 100644
--- a/src/NServiceBus.AcceptanceTests/Pipeline/When_a_message_is_audited.cs
+++ b/src/NServiceBus.AcceptanceTests/Pipeline/When_a_message_is_audited.cs
@@ -17,8 +17,11 @@ public async Task Should_flow_causation_headers()
.Done(c => c.Done)
.Run();
- Assert.AreEqual(context.OriginRelatedTo, context.RelatedTo, "The RelatedTo header in audit message should be be equal to RelatedTo header in origin.");
- Assert.AreEqual(context.OriginConversationId, context.ConversationId, "The ConversationId header in audit message should be be equal to ConversationId header in origin.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.RelatedTo, Is.EqualTo(context.OriginRelatedTo), "The RelatedTo header in audit message should be be equal to RelatedTo header in origin.");
+ Assert.That(context.ConversationId, Is.EqualTo(context.OriginConversationId), "The ConversationId header in audit message should be be equal to ConversationId header in origin.");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Pipeline/When_a_message_is_faulted.cs b/src/NServiceBus.AcceptanceTests/Pipeline/When_a_message_is_faulted.cs
index 92713aa5bf7..df6c0199778 100644
--- a/src/NServiceBus.AcceptanceTests/Pipeline/When_a_message_is_faulted.cs
+++ b/src/NServiceBus.AcceptanceTests/Pipeline/When_a_message_is_faulted.cs
@@ -17,8 +17,11 @@ public async Task Should_flow_causation_headers()
.Done(c => c.Done)
.Run();
- Assert.AreEqual(context.OriginRelatedTo, context.RelatedTo, "The RelatedTo header in fault message should be be equal to RelatedTo header in origin.");
- Assert.AreEqual(context.OriginConversationId, context.ConversationId, "The ConversationId header in fault message should be be equal to ConversationId header in origin.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.RelatedTo, Is.EqualTo(context.OriginRelatedTo), "The RelatedTo header in fault message should be be equal to RelatedTo header in origin.");
+ Assert.That(context.ConversationId, Is.EqualTo(context.OriginConversationId), "The ConversationId header in fault message should be be equal to ConversationId header in origin.");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Pipeline/When_message_processing_fails.cs b/src/NServiceBus.AcceptanceTests/Pipeline/When_message_processing_fails.cs
index 4d1b1b42a65..034f8988972 100644
--- a/src/NServiceBus.AcceptanceTests/Pipeline/When_message_processing_fails.cs
+++ b/src/NServiceBus.AcceptanceTests/Pipeline/When_message_processing_fails.cs
@@ -18,11 +18,14 @@ public async Task Should_provide_additional_exception_information()
.Done(c => c.MessageFailed)
.Run();
- Assert.IsTrue(context.Exception.Data.Contains("Message type"));
- Assert.IsTrue(context.Exception.Data.Contains("Handler type"));
- Assert.IsTrue(context.Exception.Data.Contains("Handler start time"));
- Assert.IsTrue(context.Exception.Data.Contains("Handler failure time"));
- Assert.IsTrue(context.Exception.Data.Contains("Message ID"));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Exception.Data.Contains("Message type"), Is.True);
+ Assert.That(context.Exception.Data.Contains("Handler type"), Is.True);
+ Assert.That(context.Exception.Data.Contains("Handler start time"), Is.True);
+ Assert.That(context.Exception.Data.Contains("Handler failure time"), Is.True);
+ Assert.That(context.Exception.Data.Contains("Message ID"), Is.True);
+ });
// we can't assert for the native message ID as not every transport has uses a different ID internally
}
diff --git a/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_record_class_messages.cs b/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_record_class_messages.cs
index 6fc58d26c6e..2a041a068c2 100644
--- a/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_record_class_messages.cs
+++ b/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_record_class_messages.cs
@@ -19,7 +19,7 @@ public async Task Should_process_record_message()
.Done(c => c.ReceivedText != null)
.Run();
- Assert.AreEqual(expectedText, context.ReceivedText);
+ Assert.That(context.ReceivedText, Is.EqualTo(expectedText));
}
[Test]
@@ -33,7 +33,7 @@ public async Task Should_process_positional_record_message()
.Done(c => c.ReceivedText != null)
.Run();
- Assert.AreEqual(expectedText, context.ReceivedText);
+ Assert.That(context.ReceivedText, Is.EqualTo(expectedText));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_record_struct_messages.cs b/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_record_struct_messages.cs
index 474bf651069..8053c67f5af 100644
--- a/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_record_struct_messages.cs
+++ b/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_record_struct_messages.cs
@@ -19,7 +19,7 @@ public async Task Should_process_record_message()
.Done(c => c.ReceivedText != null)
.Run();
- Assert.AreEqual(expectedText, context.ReceivedText);
+ Assert.That(context.ReceivedText, Is.EqualTo(expectedText));
}
[Test]
@@ -33,7 +33,7 @@ public async Task Should_process_readonly_record_message()
.Done(c => c.ReceivedText != null)
.Run();
- Assert.AreEqual(expectedText, context.ReceivedText);
+ Assert.That(context.ReceivedText, Is.EqualTo(expectedText));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_to_another_endpoint.cs b/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_to_another_endpoint.cs
index 48582b14228..c4625bdde83 100644
--- a/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_to_another_endpoint.cs
+++ b/src/NServiceBus.AcceptanceTests/Pipeline/When_sending_to_another_endpoint.cs
@@ -31,11 +31,14 @@ public async Task Should_receive_the_message()
.Done(c => c.WasCalled)
.Run();
- Assert.True(context.WasCalled, "The message handler should be called");
- Assert.AreEqual(1, context.TimesCalled, "The message handler should only be invoked once");
- Assert.AreEqual("StaticHeaderValue", context.ReceivedHeaders["MyStaticHeader"], "Static headers should be attached to outgoing messages");
- Assert.AreEqual("MyHeaderValue", context.MyHeader, "Static headers should be attached to outgoing messages");
- Assert.AreEqual("MyMessageId", context.MyMessageId, "MessageId should be applied to outgoing messages");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.WasCalled, Is.True, "The message handler should be called");
+ Assert.That(context.TimesCalled, Is.EqualTo(1), "The message handler should only be invoked once");
+ Assert.That(context.ReceivedHeaders["MyStaticHeader"], Is.EqualTo("StaticHeaderValue"), "Static headers should be attached to outgoing messages");
+ Assert.That(context.MyHeader, Is.EqualTo("MyHeaderValue"), "Static headers should be attached to outgoing messages");
+ Assert.That(context.MyMessageId, Is.EqualTo("MyMessageId"), "MessageId should be applied to outgoing messages");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/Cross_q_tx_msg_moved_to_error_q.cs b/src/NServiceBus.AcceptanceTests/Recoverability/Cross_q_tx_msg_moved_to_error_q.cs
index ea70972e9b0..768f656924b 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/Cross_q_tx_msg_moved_to_error_q.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/Cross_q_tx_msg_moved_to_error_q.cs
@@ -27,8 +27,11 @@ public async Task Should_not_dispatch_outgoing_messages()
.Done(c => c.MessageMovedToErrorQueue)
.Run();
- Assert.IsFalse(context.OutgoingMessageSent, "Outgoing messages should not be sent");
- Assert.IsTrue(!context.FailedMessages.IsEmpty);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.OutgoingMessageSent, Is.False, "Outgoing messages should not be sent");
+ Assert.That(!context.FailedMessages.IsEmpty, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/CustomPolicyDoes1DelayedRetryThenSendsToError.cs b/src/NServiceBus.AcceptanceTests/Recoverability/CustomPolicyDoes1DelayedRetryThenSendsToError.cs
index b84e9cb0aa2..5dcf0601677 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/CustomPolicyDoes1DelayedRetryThenSendsToError.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/CustomPolicyDoes1DelayedRetryThenSendsToError.cs
@@ -29,8 +29,8 @@ public async Task Should_execute_twice_and_send_to_error_queue()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.AreEqual(2, context.Count);
- Assert.AreEqual(messageId, context.FailedMessages.Single().Value.Single().MessageId);
+ Assert.That(context.Count, Is.EqualTo(2));
+ Assert.That(context.FailedMessages.Single().Value.Single().MessageId, Is.EqualTo(messageId));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_always_moves_to_error.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_always_moves_to_error.cs
index 501dca99592..ffac7d7b33a 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_always_moves_to_error.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_always_moves_to_error.cs
@@ -27,8 +27,8 @@ public async Task Should_execute_only_once_and_send_to_error_queue()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.AreEqual(1, context.Count);
- Assert.AreEqual(messageId, context.FailedMessages.Single().Value.Single().MessageId);
+ Assert.That(context.Count, Is.EqualTo(1));
+ Assert.That(context.FailedMessages.Single().Value.Single().MessageId, Is.EqualTo(messageId));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_discards_message.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_discards_message.cs
index ca8fe7c11e2..d5bca01c6d9 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_discards_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_discards_message.cs
@@ -16,8 +16,11 @@ public async Task Should_consume_message_without_retries()
.Done(c => c.HandlerInvoked >= 1)
.Run();
- Assert.IsEmpty(context.FailedMessages, "the message should not be moved to the error queue");
- Assert.AreEqual(1, context.HandlerInvoked, "the discarded message should not be retried");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.FailedMessages, Is.Empty, "the message should not be moved to the error queue");
+ Assert.That(context.HandlerInvoked, Is.EqualTo(1), "the discarded message should not be retried");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_moves_to_overridden_error_queue.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_moves_to_overridden_error_queue.cs
index bd8324c1467..f318f53fad9 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_moves_to_overridden_error_queue.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_custom_policy_moves_to_overridden_error_queue.cs
@@ -24,7 +24,7 @@ public async Task Should_move_to_defined_error_queue()
.Done(c => c.MessageMovedToErrorQueue)
.Run();
- Assert.IsTrue(context.MessageMovedToErrorQueue);
+ Assert.That(context.MessageMovedToErrorQueue, Is.True);
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_delayed_retries_with_immediate_retries_disabled.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_delayed_retries_with_immediate_retries_disabled.cs
index 6c93777f5e6..814465db024 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_delayed_retries_with_immediate_retries_disabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_delayed_retries_with_immediate_retries_disabled.cs
@@ -21,7 +21,7 @@ public async Task Should_reschedule_message_the_configured_number_of_times()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.AreEqual(ConfiguredNumberOfDelayedRetries + 1, context.ReceiveCount, "Message should be delivered 4 times. Once initially and retried 3 times by Delayed Retries");
+ Assert.That(context.ReceiveCount, Is.EqualTo(ConfiguredNumberOfDelayedRetries + 1), "Message should be delivered 4 times. Once initially and retried 3 times by Delayed Retries");
}
const int ConfiguredNumberOfDelayedRetries = 3;
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_error_is_overridden_in_code.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_error_is_overridden_in_code.cs
index bf83b6484b8..129490c2960 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_error_is_overridden_in_code.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_error_is_overridden_in_code.cs
@@ -18,7 +18,7 @@ public async Task Should_error_to_target_queue()
.Done(c => c.MessageReceived)
.Run();
- Assert.True(context.MessageReceived);
+ Assert.That(context.MessageReceived, Is.True);
}
public class UserEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_are_enabled.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_are_enabled.cs
index f206fbef2db..263979ca143 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_are_enabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_are_enabled.cs
@@ -19,10 +19,13 @@ public async Task Should_do_the_configured_number_of_retries()
.Done(c => c.ForwardedToErrorQueue)
.Run();
- Assert.True(context.ForwardedToErrorQueue);
- Assert.AreEqual(numberOfRetries + 1, context.NumberOfTimesInvoked, "Message should be retried 5 times immediately");
- Assert.AreEqual(numberOfRetries, context.Logs.Count(l => l.Message
- .StartsWith($"Immediate Retry is going to retry message '{context.MessageId}' because of an exception:")));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ForwardedToErrorQueue, Is.True);
+ Assert.That(context.NumberOfTimesInvoked, Is.EqualTo(numberOfRetries + 1), "Message should be retried 5 times immediately");
+ Assert.That(context.Logs.Count(l => l.Message
+ .StartsWith($"Immediate Retry is going to retry message '{context.MessageId}' because of an exception:")), Is.EqualTo(numberOfRetries));
+ });
}
const int numberOfRetries = 5;
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_disabled.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_disabled.cs
index 2018d4c8e0f..4456cafdf6c 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_disabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_disabled.cs
@@ -23,7 +23,7 @@ public async Task Should_not_retry_the_message_using_immediate_retries()
.Done(c => c.GaveUp)
.Run();
- Assert.AreEqual(1, context.NumberOfTimesInvoked, "No Immediate Retry should be in use if NumberOfRetries is set to 0");
+ Assert.That(context.NumberOfTimesInvoked, Is.EqualTo(1), "No Immediate Retry should be in use if NumberOfRetries is set to 0");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_fail.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_fail.cs
index 87e94a1aca6..14cf8101c76 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_fail.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_immediate_retries_fail.cs
@@ -24,7 +24,7 @@ public async Task Should_do_delayed_retries()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.GreaterOrEqual(context.NumberOfRetriesAttempted, 1, "Should retry one or more times");
+ Assert.That(context.NumberOfRetriesAttempted, Is.GreaterThanOrEqualTo(1), "Should retry one or more times");
}
static TimeSpan Delay = TimeSpan.FromMilliseconds(1);
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_message_fails_retries.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_message_fails_retries.cs
index 454afb4fc7d..5f7177e57a9 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_message_fails_retries.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_message_fails_retries.cs
@@ -18,15 +18,18 @@ public void Should_forward_message_to_error_queue()
.Done(c => !c.FailedMessages.IsEmpty)
.Run());
- Assert.AreEqual(1, exception.ScenarioContext.FailedMessages.Count);
+ Assert.That(exception.ScenarioContext.FailedMessages, Has.Count.EqualTo(1));
var testContext = (Context)exception.ScenarioContext;
- Assert.AreEqual(typeof(MessageWhichFailsRetries).AssemblyQualifiedName, exception.FailedMessage.Headers[Headers.EnclosedMessageTypes]);
- Assert.AreEqual(testContext.PhysicalMessageId, exception.FailedMessage.MessageId);
- Assert.IsAssignableFrom(typeof(SimulatedException), exception.FailedMessage.Exception);
+ Assert.Multiple(() =>
+ {
+ Assert.That(exception.FailedMessage.Headers[Headers.EnclosedMessageTypes], Is.EqualTo(typeof(MessageWhichFailsRetries).AssemblyQualifiedName));
+ Assert.That(exception.FailedMessage.MessageId, Is.EqualTo(testContext.PhysicalMessageId));
+ Assert.That(exception.FailedMessage.Exception, Is.AssignableFrom());
+ });
- Assert.AreEqual(1, testContext.Logs.Count(l => l.Message
- .StartsWith($"Moving message '{testContext.PhysicalMessageId}' to the error queue 'error' because processing failed due to an exception:")));
+ Assert.That(testContext.Logs.Count(l => l.Message
+ .StartsWith($"Moving message '{testContext.PhysicalMessageId}' to the error queue 'error' because processing failed due to an exception:")), Is.EqualTo(1));
}
public class RetryEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_message_is_deferred_by_delayed_retries_using_dtc.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_message_is_deferred_by_delayed_retries_using_dtc.cs
index 9f59a35a2c3..522e0812e72 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_message_is_deferred_by_delayed_retries_using_dtc.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_message_is_deferred_by_delayed_retries_using_dtc.cs
@@ -27,8 +27,11 @@ public async Task Should_not_commit_distributed_transaction()
.Done(c => !c.FailedMessages.IsEmpty)
.Run();
- Assert.GreaterOrEqual(context.NumberOfRetriesAttempted, 3, "Should retry at least three times");
- Assert.That(context.TransactionStatuses, Is.All.Not.EqualTo(TransactionStatus.Committed));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.NumberOfRetriesAttempted, Is.GreaterThanOrEqualTo(3), "Should retry at least three times");
+ Assert.That(context.TransactionStatuses, Is.All.Not.EqualTo(TransactionStatus.Committed));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_message_with_TimeToBeReceived_fails.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_message_with_TimeToBeReceived_fails.cs
index b07ee8e5d9a..6f5b95c45ca 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_message_with_TimeToBeReceived_fails.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_message_with_TimeToBeReceived_fails.cs
@@ -26,8 +26,11 @@ public async Task Should_not_honor_TimeToBeReceived_for_error_message()
.Done(c => c.MessageFailed && c.TTBRHasExpiredAndMessageIsStillInErrorQueue)
.Run();
- Assert.IsTrue(context.MessageFailed);
- Assert.IsTrue(context.TTBRHasExpiredAndMessageIsStillInErrorQueue);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageFailed, Is.True);
+ Assert.That(context.TTBRHasExpiredAndMessageIsStillInErrorQueue, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_non_transactional_message_is_moved_to_error_queue.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_non_transactional_message_is_moved_to_error_queue.cs
index 9f50ef38287..3a0660e9595 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_non_transactional_message_is_moved_to_error_queue.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_non_transactional_message_is_moved_to_error_queue.cs
@@ -27,7 +27,7 @@ public async Task Should_dispatch_outgoing_messages()
.Done(c => c.MessageMovedToErrorQueue && c.OutgoingMessageSent)
.Run();
- Assert.IsTrue(!context.FailedMessages.IsEmpty, "Messages should have failed");
+ Assert.That(!context.FailedMessages.IsEmpty, Is.True, "Messages should have failed");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_receiveonly_message_is_moved_to_error_queue.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_receiveonly_message_is_moved_to_error_queue.cs
index 20a745a8bf0..bceac303e57 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_receiveonly_message_is_moved_to_error_queue.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_receiveonly_message_is_moved_to_error_queue.cs
@@ -27,7 +27,7 @@ public async Task Should_dispatch_outgoing_messages()
.Done(c => c.MessageMovedToErrorQueue && c.OutgoingMessageSent)
.Run();
- Assert.IsTrue(!context.FailedMessages.IsEmpty, "Messages should have failed");
+ Assert.That(!context.FailedMessages.IsEmpty, Is.True, "Messages should have failed");
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_retrying_control_message_from_error_queue.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_retrying_control_message_from_error_queue.cs
index bfdbd402eee..d31f04bd29e 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_retrying_control_message_from_error_queue.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_retrying_control_message_from_error_queue.cs
@@ -28,7 +28,7 @@ public async Task Should_confirm_successful_processing()
.Done(c => c.ConfirmedRetryId != null)
.Run();
- Assert.AreEqual(RetryId, context.ConfirmedRetryId);
+ Assert.That(context.ConfirmedRetryId, Is.EqualTo(RetryId));
var processingTime = DateTimeOffsetHelper.ToDateTimeOffset(context.RetryProcessingTimestamp);
Assert.That(processingTime, Is.EqualTo(DateTimeOffset.UtcNow).Within(TimeSpan.FromMinutes(1)));
}
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_retrying_message_from_error_queue.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_retrying_message_from_error_queue.cs
index 1f33bfe9cec..2c3b6cd7629 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_retrying_message_from_error_queue.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_retrying_message_from_error_queue.cs
@@ -30,11 +30,17 @@ public async Task Should_confirm_successful_processing()
.Done(c => c.ConfirmedRetryId != null && c.AuditHeaders != null)
.Run();
- Assert.IsTrue(context.MessageProcessed);
- Assert.AreEqual(context.RetryId, context.ConfirmedRetryId);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageProcessed, Is.True);
+ Assert.That(context.ConfirmedRetryId, Is.EqualTo(context.RetryId));
+ });
var processingTime = DateTimeOffsetHelper.ToDateTimeOffset(context.RetryProcessingTimestamp);
- Assert.That(processingTime, Is.EqualTo(DateTimeOffset.UtcNow).Within(TimeSpan.FromMinutes(1)));
- Assert.IsTrue(context.AuditHeaders.ContainsKey("ServiceControl.Retry.AcknowledgementSent"));
+ Assert.Multiple(() =>
+ {
+ Assert.That(processingTime, Is.EqualTo(DateTimeOffset.UtcNow).Within(TimeSpan.FromMinutes(1)));
+ Assert.That(context.AuditHeaders.ContainsKey("ServiceControl.Retry.AcknowledgementSent"), Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Recoverability/When_transactionscope_message_is_moved_to_error_queue.cs b/src/NServiceBus.AcceptanceTests/Recoverability/When_transactionscope_message_is_moved_to_error_queue.cs
index 979570acd44..e7ad5ecd0e3 100644
--- a/src/NServiceBus.AcceptanceTests/Recoverability/When_transactionscope_message_is_moved_to_error_queue.cs
+++ b/src/NServiceBus.AcceptanceTests/Recoverability/When_transactionscope_message_is_moved_to_error_queue.cs
@@ -27,8 +27,11 @@ public async Task Should_not_dispatch_outgoing_messages()
.Done(c => c.MessageMovedToErrorQueue)
.Run();
- Assert.IsFalse(context.OutgoingMessageSent, "Outgoing messages should not be sent");
- Assert.IsTrue(!context.FailedMessages.IsEmpty, "There should be failed messages registered in this scenario");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.OutgoingMessageSent, Is.False, "Outgoing messages should not be sent");
+ Assert.That(!context.FailedMessages.IsEmpty, Is.True, "There should be failed messages registered in this scenario");
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Extend_event_routing.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Extend_event_routing.cs
index 31a1c0f6805..f351e18bad2 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Extend_event_routing.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Extend_event_routing.cs
@@ -26,7 +26,7 @@ public async Task Should_route_events_correctly()
.Done(c => c.MessageDelivered)
.Run();
- Assert.True(context.MessageDelivered);
+ Assert.That(context.MessageDelivered, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Missing_pub_info.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Missing_pub_info.cs
index ffa231c7c22..d29a0ed5baa 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Missing_pub_info.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Missing_pub_info.cs
@@ -20,12 +20,15 @@ public async Task Should_log_events_with_missing_routes()
.Done(c => c.EndpointsStarted)
.Run();
- Assert.True(context.EndpointsStarted, "because it should not prevent endpoint startup");
+ Assert.That(context.EndpointsStarted, Is.True, "because it should not prevent endpoint startup");
var log = context.Logs.Single(l => l.Message.Contains($"AutoSubscribe was unable to subscribe to an event:"));
- Assert.AreEqual(LogLevel.Error, log.Level);
- Assert.AreEqual(typeof(AutoSubscribe).FullName, log.LoggerName);
- StringAssert.Contains($"No publisher address could be found for message type '{typeof(MyEvent).FullName}'.", log.Message);
+ Assert.Multiple(() =>
+ {
+ Assert.That(log.Level, Is.EqualTo(LogLevel.Error));
+ Assert.That(log.LoggerName, Is.EqualTo(typeof(AutoSubscribe).FullName));
+ });
+ Assert.That(log.Message, Does.Contain($"No publisher address could be found for message type '{typeof(MyEvent).FullName}'."));
}
public class Subscriber : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Multi_sub_to_poly_event.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Multi_sub_to_poly_event.cs
index 8c103b4aac3..3fe913d766a 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Multi_sub_to_poly_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Multi_sub_to_poly_event.cs
@@ -33,8 +33,11 @@ public async Task Both_events_should_be_delivered()
.Done(c => c.SubscriberGotIMyEvent && c.SubscriberGotMyEvent2)
.Run();
- Assert.True(context.SubscriberGotIMyEvent);
- Assert.True(context.SubscriberGotMyEvent2);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SubscriberGotIMyEvent, Is.True);
+ Assert.That(context.SubscriberGotMyEvent2, Is.True);
+ });
}
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Pub_from_sendonly.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Pub_from_sendonly.cs
index a93bef3ba45..cdf450864ce 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Pub_from_sendonly.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Pub_from_sendonly.cs
@@ -29,7 +29,7 @@ public async Task Should_be_delivered_to_all_subscribers()
.Done(c => c.SubscriberGotTheEvent)
.Run();
- Assert.True(context.SubscriberGotTheEvent);
+ Assert.That(context.SubscriberGotTheEvent, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Pub_to_scaled_out_subs.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Pub_to_scaled_out_subs.cs
index 44c7bcce96c..2906fd40106 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Pub_to_scaled_out_subs.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Pub_to_scaled_out_subs.cs
@@ -22,8 +22,11 @@ public async Task Each_event_should_be_delivered_to_single_instance_of_each_subs
.Done(c => c.ProcessedByA > 0 && c.ProcessedByB > 0)
.Run();
- Assert.AreEqual(1, context.ProcessedByA);
- Assert.AreEqual(1, context.ProcessedByB);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ProcessedByA, Is.EqualTo(1));
+ Assert.That(context.ProcessedByB, Is.EqualTo(1));
+ });
}
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_base_event.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_base_event.cs
index c80f7993e1c..9a62f6f4132 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_base_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_base_event.cs
@@ -23,8 +23,11 @@ public async Task Both_base_and_specific_events_should_be_delivered()
.Done(c => c.SubscriberGotBaseEvent && c.SubscriberGotSpecificEvent)
.Run();
- Assert.True(context.SubscriberGotBaseEvent);
- Assert.True(context.SubscriberGotSpecificEvent);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SubscriberGotBaseEvent, Is.True);
+ Assert.That(context.SubscriberGotSpecificEvent, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_derived_event.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_derived_event.cs
index ebe63fdbf38..d6913755a87 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_derived_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_derived_event.cs
@@ -24,7 +24,7 @@ public async Task Base_event_should_not_be_delivered()
.Done(c => c.Done)
.Run();
- Assert.IsFalse(context.SubscriberGotEvent);
+ Assert.That(context.SubscriberGotEvent, Is.False);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_multiple_pubs.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_multiple_pubs.cs
index 12adedd565b..611c7a507c8 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_multiple_pubs.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_multiple_pubs.cs
@@ -31,8 +31,11 @@ public async Task Should_subscribe_to_all_registered_publishers_of_same_type()
.Done(c => c.SubscribedToPublisher1 && c.SubscribedToPublisher2)
.Run();
- Assert.That(context.SubscribedToPublisher1, Is.True);
- Assert.That(context.SubscribedToPublisher2, Is.True);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SubscribedToPublisher1, Is.True);
+ Assert.That(context.SubscribedToPublisher2, Is.True);
+ });
}
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_scaled_out_pubs.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_scaled_out_pubs.cs
index 497cab5b35e..5f9fec4349e 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_scaled_out_pubs.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Sub_to_scaled_out_pubs.cs
@@ -26,7 +26,7 @@ public async Task Should_send_subscription_message_to_each_instance()
// each instance should receive a subscription message
Assert.That(context.PublisherReceivedSubscription, Does.Contain("1"));
Assert.That(context.PublisherReceivedSubscription, Does.Contain("2"));
- Assert.That(context.PublisherReceivedSubscription.Count, Is.EqualTo(2));
+ Assert.That(context.PublisherReceivedSubscription, Has.Count.EqualTo(2));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Unsub_from_event.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Unsub_from_event.cs
index 65921bc5547..22aeac4eebd 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Unsub_from_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Unsub_from_event.cs
@@ -38,9 +38,12 @@ public async Task Should_no_longer_receive_event()
.Done(c => c.Subscriber1ReceivedMessages >= 4)
.Run();
- Assert.AreEqual(4, context.Subscriber1ReceivedMessages);
- Assert.AreEqual(1, context.Subscriber2ReceivedMessages);
- Assert.IsTrue(context.Subscriber2Unsubscribed);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Subscriber1ReceivedMessages, Is.EqualTo(4));
+ Assert.That(context.Subscriber2ReceivedMessages, Is.EqualTo(1));
+ Assert.That(context.Subscriber2Unsubscribed, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Unsub_from_scaled_out_pubs.cs b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Unsub_from_scaled_out_pubs.cs
index 5c62279ac37..16180732548 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Unsub_from_scaled_out_pubs.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/MessageDrivenSubscriptions/Unsub_from_scaled_out_pubs.cs
@@ -26,7 +26,7 @@ public async Task Should_send_unsubscribe_message_to_each_instance()
// each instance should receive an unsubscribe message
Assert.That(context.PublisherReceivedUnsubscribeMessage, Does.Contain("1"));
Assert.That(context.PublisherReceivedUnsubscribeMessage, Does.Contain("2"));
- Assert.That(context.PublisherReceivedUnsubscribeMessage.Count, Is.EqualTo(2));
+ Assert.That(context.PublisherReceivedUnsubscribeMessage, Has.Count.EqualTo(2));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/MultiSubscribeToPolymorphicEvent.cs b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/MultiSubscribeToPolymorphicEvent.cs
index a7ef97070f9..915338e6662 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/MultiSubscribeToPolymorphicEvent.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/MultiSubscribeToPolymorphicEvent.cs
@@ -27,8 +27,11 @@ public async Task Both_events_should_be_delivered()
.Done(c => c.SubscriberGotIMyEvent && c.SubscriberGotMyEvent2)
.Run();
- Assert.True(context.SubscriberGotIMyEvent);
- Assert.True(context.SubscriberGotMyEvent2);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SubscriberGotIMyEvent, Is.True);
+ Assert.That(context.SubscriberGotMyEvent2, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_publishing_from_sendonly.cs b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_publishing_from_sendonly.cs
index c480e89955c..7c3b2d0021c 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_publishing_from_sendonly.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_publishing_from_sendonly.cs
@@ -19,7 +19,7 @@ public async Task Should_be_delivered_to_all_subscribers()
.Done(c => c.SubscriberGotTheEvent)
.Run();
- Assert.True(context.SubscriberGotTheEvent);
+ Assert.That(context.SubscriberGotTheEvent, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_publishing_to_scaled_out_subscribers.cs b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_publishing_to_scaled_out_subscribers.cs
index f929bbc6bb2..23d85070011 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_publishing_to_scaled_out_subscribers.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_publishing_to_scaled_out_subscribers.cs
@@ -23,8 +23,11 @@ public async Task Should_route_event_to_shared_queue()
.Done(c => c.SubscriberACounter > 0 && c.SubscriberBCounter > 0)
.Run();
- Assert.AreEqual(1, context.SubscriberACounter);
- Assert.AreEqual(1, context.SubscriberBCounter);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SubscriberACounter, Is.EqualTo(1));
+ Assert.That(context.SubscriberBCounter, Is.EqualTo(1));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_subscribing_to_a_base_event.cs b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_subscribing_to_a_base_event.cs
index 43560553045..55f8a9bbc45 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_subscribing_to_a_base_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_subscribing_to_a_base_event.cs
@@ -27,8 +27,11 @@ public async Task Both_base_and_specific_events_should_be_delivered()
.Done(c => c.SubscriberGotBaseEvent && c.SubscriberGotSpecificEvent)
.Run();
- Assert.True(context.SubscriberGotBaseEvent);
- Assert.True(context.SubscriberGotSpecificEvent);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SubscriberGotBaseEvent, Is.True);
+ Assert.That(context.SubscriberGotSpecificEvent, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_subscribing_to_a_derived_event.cs b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_subscribing_to_a_derived_event.cs
index ecc4e51077a..b677dc98598 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_subscribing_to_a_derived_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_subscribing_to_a_derived_event.cs
@@ -28,7 +28,7 @@ public async Task Base_event_should_not_be_delivered()
.Done(c => c.Done)
.Run();
- Assert.IsFalse(context.SubscriberGotEvent);
+ Assert.That(context.SubscriberGotEvent, Is.False);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_unsubscribing_from_event.cs b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_unsubscribing_from_event.cs
index da5fc73ba59..4cc2275f7f4 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_unsubscribing_from_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/NativePublishSubscribe/When_unsubscribing_from_event.cs
@@ -49,9 +49,12 @@ public async Task Should_no_longer_receive_event()
.Done(c => c.Subscriber1ReceivedMessages >= 4)
.Run();
- Assert.AreEqual(4, context.Subscriber1ReceivedMessages);
- Assert.AreEqual(1, context.Subscriber2ReceivedMessages);
- Assert.IsTrue(context.Subscriber2Unsubscribed);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Subscriber1ReceivedMessages, Is.EqualTo(4));
+ Assert.That(context.Subscriber2ReceivedMessages, Is.EqualTo(1));
+ Assert.That(context.Subscriber2Unsubscribed, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_base_event_from_2_publishers.cs b/src/NServiceBus.AcceptanceTests/Routing/When_base_event_from_2_publishers.cs
index 0e47888a1f9..bfdb6c64789 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_base_event_from_2_publishers.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_base_event_from_2_publishers.cs
@@ -33,8 +33,11 @@ public async Task Should_receive_events_from_all_publishers()
.Done(c => c.GotTheEventFromPublisher1 && c.GotTheEventFromPublisher2)
.Run();
- Assert.True(context.GotTheEventFromPublisher1);
- Assert.True(context.GotTheEventFromPublisher2);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.GotTheEventFromPublisher1, Is.True);
+ Assert.That(context.GotTheEventFromPublisher2, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_extending_command_routing.cs b/src/NServiceBus.AcceptanceTests/Routing/When_extending_command_routing.cs
index 59c8b0ff3fd..50129a1c8c3 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_extending_command_routing.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_extending_command_routing.cs
@@ -32,7 +32,7 @@ public async Task Should_route_commands_correctly()
.Done(c => c.MessageDelivered >= 4)
.Run();
- Assert.IsTrue(ctx.MessageDelivered >= 4);
+ Assert.That(ctx.MessageDelivered, Is.GreaterThanOrEqualTo(4));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_making_endpoint_uniquely_addressable.cs b/src/NServiceBus.AcceptanceTests/Routing/When_making_endpoint_uniquely_addressable.cs
index 42e27277cc5..8702114b6ee 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_making_endpoint_uniquely_addressable.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_making_endpoint_uniquely_addressable.cs
@@ -25,7 +25,7 @@ public async Task Should_be_addressable_both_by_shared_queue_and_unique_queue()
.Done(c => c.MessagesReceived > 1)
.Run();
- Assert.AreEqual(2, context.MessagesReceived);
+ Assert.That(context.MessagesReceived, Is.EqualTo(2));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_multiple_mappings_exists.cs b/src/NServiceBus.AcceptanceTests/Routing/When_multiple_mappings_exists.cs
index 6d03bb0b7c0..91e25ab709f 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_multiple_mappings_exists.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_multiple_mappings_exists.cs
@@ -18,8 +18,11 @@ public async Task First_registration_should_be_the_final_destination()
.Done(c => c.WasCalled1 || c.WasCalled2)
.Run();
- Assert.IsTrue(context.WasCalled1);
- Assert.IsFalse(context.WasCalled2);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.WasCalled1, Is.True);
+ Assert.That(context.WasCalled2, Is.False);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_overriding_local_address.cs b/src/NServiceBus.AcceptanceTests/Routing/When_overriding_local_address.cs
index 1bfd4d2f464..f840577801f 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_overriding_local_address.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_overriding_local_address.cs
@@ -38,7 +38,7 @@ public void Should_not_be_allowed_when_send_only()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains("send-only", ex.Message);
+ Assert.That(ex.Message, Does.Contain("send-only"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing.cs
index 263c7110078..69daa1b6b6f 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing.cs
@@ -29,7 +29,7 @@ public async Task Issue_1851()
.Done(c => c.Subscriber3GotTheEvent)
.Run();
- Assert.True(context.Subscriber3GotTheEvent);
+ Assert.That(context.Subscriber3GotTheEvent, Is.True);
}
[Test]
@@ -77,9 +77,12 @@ public async Task Should_be_delivered_to_all_subscribers()
.Done(c => c.Subscriber1GotTheEvent && c.Subscriber2GotTheEvent)
.Run(TimeSpan.FromSeconds(10));
- Assert.True(context.Subscriber1GotTheEvent);
- Assert.True(context.Subscriber2GotTheEvent);
- Assert.AreEqual("SomeValue", context.HeaderValue);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Subscriber1GotTheEvent, Is.True);
+ Assert.That(context.Subscriber2GotTheEvent, Is.True);
+ Assert.That(context.HeaderValue, Is.EqualTo("SomeValue"));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs
index df0a1f5685b..f8ee789b3c9 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs
@@ -37,8 +37,11 @@ public async Task Event_should_be_published_using_instance_type()
.Done(c => c.GotEventA && c.GotEventB)
.Run(TimeSpan.FromSeconds(20));
- Assert.True(context.GotEventA);
- Assert.True(context.GotEventB);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.GotEventA, Is.True);
+ Assert.That(context.GotEventB, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_interface.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_interface.cs
index 40e94c5e0a0..efff6540e9a 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_interface.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_interface.cs
@@ -28,8 +28,11 @@ public async Task Should_receive_event()
.Done(c => c.GotTheEvent)
.Run();
- Assert.True(context.GotTheEvent);
- Assert.AreEqual(typeof(IMyEvent), context.EventTypePassedToRouting);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.GotTheEvent, Is.True);
+ Assert.That(context.EventTypePassedToRouting, Is.EqualTo(typeof(IMyEvent)));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_interface_with_unobtrusive.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_interface_with_unobtrusive.cs
index 7d9cd52ed15..c8b4da9c91b 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_interface_with_unobtrusive.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_an_interface_with_unobtrusive.cs
@@ -28,8 +28,11 @@ public async Task Should_receive_event()
.Done(c => c.GotTheEvent)
.Run();
- Assert.True(context.GotTheEvent);
- Assert.AreEqual(typeof(IMyEvent), context.EventTypePassedToRouting);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.GotTheEvent, Is.True);
+ Assert.That(context.EventTypePassedToRouting, Is.EqualTo(typeof(IMyEvent)));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs
index da85b55a759..06c19ff6eaa 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs
@@ -28,8 +28,11 @@ public async Task Should_publish_event_to_interface_type_subscribers()
.Done(c => c.GotTheEvent)
.Run();
- Assert.True(context.GotTheEvent);
- Assert.AreEqual(typeof(IMyEvent), context.EventTypePassedToRouting);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.GotTheEvent, Is.True);
+ Assert.That(context.EventTypePassedToRouting, Is.EqualTo(typeof(IMyEvent)));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_using_base_type.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_using_base_type.cs
index c55e5997554..958a8509175 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_using_base_type.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_using_base_type.cs
@@ -33,7 +33,7 @@ public async Task Event_should_be_published_using_instance_type()
.Done(c => c.Subscriber1GotTheEvent)
.Run(TimeSpan.FromSeconds(20));
- Assert.True(context.Subscriber1GotTheEvent);
+ Assert.That(context.Subscriber1GotTheEvent, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_with_overridden_local_address.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_with_overridden_local_address.cs
index eb4bc6e1c54..e80ccbad4db 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_with_overridden_local_address.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_with_overridden_local_address.cs
@@ -27,7 +27,7 @@ public async Task Should_be_delivered_to_all_subscribers()
.Done(c => c.Subscriber1GotTheEvent)
.Run();
- Assert.True(context.Subscriber1GotTheEvent);
+ Assert.That(context.Subscriber1GotTheEvent, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_registering_publishers_unobtrusive_messages_code.cs b/src/NServiceBus.AcceptanceTests/Routing/When_registering_publishers_unobtrusive_messages_code.cs
index 545ba0d2a10..271bcf48643 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_registering_publishers_unobtrusive_messages_code.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_registering_publishers_unobtrusive_messages_code.cs
@@ -19,8 +19,11 @@ public async Task Should_deliver_event()
.Done(c => c.ReceivedMessage)
.Run();
- Assert.That(context.Subscribed, Is.True);
- Assert.That(context.ReceivedMessage, Is.True);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Subscribed, Is.True);
+ Assert.That(context.ReceivedMessage, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_registering_publishers_unobtrusive_messages_config.cs b/src/NServiceBus.AcceptanceTests/Routing/When_registering_publishers_unobtrusive_messages_config.cs
index 0c7b73abf21..5d8d41ca1fe 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_registering_publishers_unobtrusive_messages_config.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_registering_publishers_unobtrusive_messages_config.cs
@@ -19,8 +19,11 @@ public async Task Should_deliver_event()
.Done(c => c.ReceivedMessage)
.Run();
- Assert.That(context.Subscribed, Is.True);
- Assert.That(context.ReceivedMessage, Is.True);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Subscribed, Is.True);
+ Assert.That(context.ReceivedMessage, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_replying_to_message.cs b/src/NServiceBus.AcceptanceTests/Routing/When_replying_to_message.cs
index 4ad748970a7..2ef24b799ae 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_replying_to_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_replying_to_message.cs
@@ -20,8 +20,11 @@ public async Task Should_reply_to_originator()
.Done(c => c.SendingEndpointGotResponse)
.Run();
- Assert.IsTrue(ctx.SendingEndpointGotResponse);
- Assert.IsFalse(ctx.OtherEndpointGotResponse);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ctx.SendingEndpointGotResponse, Is.True);
+ Assert.That(ctx.OtherEndpointGotResponse, Is.False);
+ });
}
[Test]
@@ -37,8 +40,8 @@ public async Task Should_reply_to_shared_queue_by_default()
.Done(c => c.SendingEndpointGotResponse)
.Run();
- Assert.IsTrue(ctx.SendingEndpointGotResponse);
- StringAssert.DoesNotContain(instanceDiscriminator, ctx.ReplyToAddress);
+ Assert.That(ctx.SendingEndpointGotResponse, Is.True);
+ Assert.That(ctx.ReplyToAddress, Does.Not.Contain(instanceDiscriminator));
}
[Test]
@@ -53,8 +56,11 @@ public async Task Should_reply_to_configured_return_address()
.Done(c => c.OtherEndpointGotResponse)
.Run();
- Assert.IsTrue(ctx.OtherEndpointGotResponse);
- Assert.IsFalse(ctx.SendingEndpointGotResponse);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ctx.OtherEndpointGotResponse, Is.True);
+ Assert.That(ctx.SendingEndpointGotResponse, Is.False);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_replying_to_message_with_interface_and_unobtrusive.cs b/src/NServiceBus.AcceptanceTests/Routing/When_replying_to_message_with_interface_and_unobtrusive.cs
index e9bb9f3c132..57fb4241ddd 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_replying_to_message_with_interface_and_unobtrusive.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_replying_to_message_with_interface_and_unobtrusive.cs
@@ -19,8 +19,11 @@ public async Task Should_reply_to_originator()
.Done(c => c.SendingEndpointGotResponse)
.Run();
- Assert.IsTrue(ctx.SendingEndpointGotResponse);
- Assert.IsFalse(ctx.OtherEndpointGotResponse);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ctx.SendingEndpointGotResponse, Is.True);
+ Assert.That(ctx.OtherEndpointGotResponse, Is.False);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_any_instance.cs b/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_any_instance.cs
index 1cef8806f39..137f4e85e8a 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_any_instance.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_any_instance.cs
@@ -24,8 +24,8 @@ public async Task Should_route_reply_to_shared_queue()
.Done(c => c.ReplyReceived)
.Run();
- Assert.IsTrue(context.ReplyReceived);
- StringAssert.DoesNotContain(instanceDiscriminator, context.ReplyToAddress);
+ Assert.That(context.ReplyReceived, Is.True);
+ Assert.That(context.ReplyToAddress, Does.Not.Contain(instanceDiscriminator));
}
const string instanceDiscriminator = "instance-42";
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_specific_address.cs b/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_specific_address.cs
index 283b6b60dcc..da80741b08f 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_specific_address.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_specific_address.cs
@@ -27,8 +27,8 @@ public async Task Should_route_reply_to_instance_specific_queue()
.Done(c => c.ReplyReceived)
.Run();
- Assert.IsTrue(context.ReplyReceived);
- StringAssert.Contains(replyHandlerAddress, context.ReplyToAddress);
+ Assert.That(context.ReplyReceived, Is.True);
+ Assert.That(context.ReplyToAddress, Does.Contain(replyHandlerAddress));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_specific_instance.cs b/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_specific_instance.cs
index 6604d89356c..adcffae3704 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_specific_instance.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_routing_reply_to_specific_instance.cs
@@ -24,8 +24,8 @@ public async Task Should_route_reply_to_instance_specific_queue()
.Done(c => c.ReplyReceived)
.Run();
- Assert.IsTrue(context.ReplyReceived);
- StringAssert.Contains(instanceDiscriminator, context.ReplyToAddress);
+ Assert.That(context.ReplyReceived, Is.True);
+ Assert.That(context.ReplyToAddress, Does.Contain(instanceDiscriminator));
}
const string instanceDiscriminator = "instance-42";
diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_using_custom_routing_strategy.cs b/src/NServiceBus.AcceptanceTests/Routing/When_using_custom_routing_strategy.cs
index d9bfd00e9a0..0781db537fc 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/When_using_custom_routing_strategy.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/When_using_custom_routing_strategy.cs
@@ -33,8 +33,11 @@ public async Task Should_route_commands_correctly()
.Done(c => c.MessageDeliveredReceiver1 >= 3 && c.MessageDeliveredReceiver2 >= 1)
.Run();
- Assert.AreEqual(3, ctx.MessageDeliveredReceiver1);
- Assert.AreEqual(1, ctx.MessageDeliveredReceiver2);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ctx.MessageDeliveredReceiver1, Is.EqualTo(3));
+ Assert.That(ctx.MessageDeliveredReceiver2, Is.EqualTo(1));
+ });
}
static string Discriminator1 = "553E9649";
diff --git a/src/NServiceBus.AcceptanceTests/Routing/when_replying_to_a_message_sent_to_specific_instance.cs b/src/NServiceBus.AcceptanceTests/Routing/when_replying_to_a_message_sent_to_specific_instance.cs
index 164ef3e458e..40eaf92beac 100644
--- a/src/NServiceBus.AcceptanceTests/Routing/when_replying_to_a_message_sent_to_specific_instance.cs
+++ b/src/NServiceBus.AcceptanceTests/Routing/when_replying_to_a_message_sent_to_specific_instance.cs
@@ -22,7 +22,7 @@ public async Task Reply_address_should_be_set_to_shared_endpoint_queue()
.Done(c => c.ReplyToAddress != null)
.Run();
- StringAssert.DoesNotContain("XZY", context.ReplyToAddress);
+ Assert.That(context.ReplyToAddress, Does.Not.Contain("XZY"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_an_endpoint_replies_to_a_saga.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_an_endpoint_replies_to_a_saga.cs
index 6a520ef46ea..d37a7b19fc6 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_an_endpoint_replies_to_a_saga.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_an_endpoint_replies_to_a_saga.cs
@@ -23,7 +23,7 @@ public async Task Should_correlate_all_saga_messages_properly()
.Done(c => c.Done)
.Run();
- Assert.AreEqual(context.RunId, context.ResponseRunId);
+ Assert.That(context.ResponseRunId, Is.EqualTo(context.RunId));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_correlated_property_value_is_changed.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_correlated_property_value_is_changed.cs
index 53e0ee33ca9..7eefa72ea47 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_correlated_property_value_is_changed.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_correlated_property_value_is_changed.cs
@@ -23,10 +23,10 @@ await Scenario.Define()
.Done(c => c.ModifiedCorrelationProperty)
.Run());
- Assert.AreEqual(1, exception.ScenarioContext.FailedMessages.Count);
- StringAssert.Contains(
- "Changing the value of correlated properties at runtime is currently not supported",
- exception.FailedMessage.Exception.Message);
+ Assert.That(exception.ScenarioContext.FailedMessages, Has.Count.EqualTo(1));
+ Assert.That(
+ exception.FailedMessage.Exception.Message,
+ Does.Contain("Changing the value of correlated properties at runtime is currently not supported"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_correlating_on_special_characters.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_correlating_on_special_characters.cs
index bee6b25506c..f888f05bc4f 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_correlating_on_special_characters.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_correlating_on_special_characters.cs
@@ -21,7 +21,7 @@ public async Task Saga_persistence_and_correlation_should_work()
.Done(c => c.RehydratedValueForCorrelatedHandler != null)
.Run();
- Assert.AreEqual(propertyValue, context.RehydratedValueForCorrelatedHandler);
+ Assert.That(context.RehydratedValueForCorrelatedHandler, Is.EqualTo(propertyValue));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_guid.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_guid.cs
index eb71e6fb20d..7d57c84918b 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_guid.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_guid.cs
@@ -22,8 +22,11 @@ public async Task Show_allow_default()
.Done(c => c.MessageCorrelated)
.Run();
- Assert.That(context.MessageCorrelated, Is.True);
- Assert.That(context.CorrelatedId, Is.EqualTo(default(Guid)));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageCorrelated, Is.True);
+ Assert.That(context.CorrelatedId, Is.EqualTo(default(Guid)));
+ });
}
public class MessageWithGuidCorrelationProperty : IMessage
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_int.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_int.cs
index 2f26eef1814..5073d3ae3a5 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_int.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_int.cs
@@ -21,8 +21,11 @@ public async Task Show_allow_default()
.Done(c => c.MessageCorrelated)
.Run();
- Assert.That(context.MessageCorrelated, Is.True);
- Assert.That(context.CorrelatedId, Is.EqualTo(default(int)));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageCorrelated, Is.True);
+ Assert.That(context.CorrelatedId, Is.EqualTo(default(int)));
+ });
}
public class MessageWithIntCorrelationProperty : IMessage
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_null.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_null.cs
index 7c0fe4946e2..13fd367bd73 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_null.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_correlation_property_is_null.cs
@@ -23,7 +23,7 @@ public void Should_throw_an_exception_with_details()
var errorMessage = $"Message {typeof(MessageWithNullCorrelationProperty).FullName} mapped to saga {typeof(SagaWithCorrelationPropertyEndpoint.SagaWithCorrelatedProperty).FullName} has attempted to assign null to the correlation property {nameof(SagaWithCorrelationPropertyEndpoint.SagaDataWithCorrelatedProperty.CorrelatedProperty)}. Correlation properties cannot be assigned null.";
- StringAssert.Contains(errorMessage, exception.FailedMessage.Exception.Message);
+ Assert.That(exception.FailedMessage.Exception.Message, Does.Contain(errorMessage));
}
public class SagaWithCorrelationPropertyEndpoint : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_doing_request_response_between_sagas.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_doing_request_response_between_sagas.cs
index da3a4737a47..a3287449a08 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_doing_request_response_between_sagas.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_doing_request_response_between_sagas.cs
@@ -16,7 +16,7 @@ public async Task Should_autocorrelate_the_response_back_to_the_requesting_saga(
.Done(c => c.DidRequestingSagaGetTheResponse)
.Run();
- Assert.True(context.DidRequestingSagaGetTheResponse);
+ Assert.That(context.DidRequestingSagaGetTheResponse, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_handling_concurrent_messages.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_handling_concurrent_messages.cs
index 7368212c83e..5029da2fe54 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_handling_concurrent_messages.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_handling_concurrent_messages.cs
@@ -36,12 +36,12 @@ public async Task Should_not_overwrite_each_other(bool useOutbox)
.Done(c => c.SagaData != null)
.Run();
- Assert.IsNotNull(context.SagaData);
- Assert.AreEqual(3, context.SagaData.ContinueCount);
+ Assert.That(context.SagaData, Is.Not.Null);
+ Assert.That(context.SagaData.ContinueCount, Is.EqualTo(3));
- StringAssert.Contains("1", context.SagaData.CollectedIndexes);
- StringAssert.Contains("2", context.SagaData.CollectedIndexes);
- StringAssert.Contains("3", context.SagaData.CollectedIndexes);
+ Assert.That(context.SagaData.CollectedIndexes, Does.Contain("1"));
+ Assert.That(context.SagaData.CollectedIndexes, Does.Contain("2"));
+ Assert.That(context.SagaData.CollectedIndexes, Does.Contain("3"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_message_has_a_saga_id.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_message_has_a_saga_id.cs
index 9df1114441f..ae1dd388740 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_message_has_a_saga_id.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_message_has_a_saga_id.cs
@@ -29,9 +29,12 @@ public async Task Should_not_start_a_new_saga_if_not_found()
.Done(c => c.Done)
.Run();
- Assert.True(context.NotFoundHandlerCalled);
- Assert.False(context.MessageHandlerCalled);
- Assert.False(context.TimeoutHandlerCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.NotFoundHandlerCalled, Is.True);
+ Assert.That(context.MessageHandlerCalled, Is.False);
+ Assert.That(context.TimeoutHandlerCalled, Is.False);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_receiving_multiple_timeouts.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_receiving_multiple_timeouts.cs
index 5a1db7c4d32..3b4db95219e 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_receiving_multiple_timeouts.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_receiving_multiple_timeouts.cs
@@ -23,9 +23,12 @@ public async Task It_should_not_invoke_SagaNotFound_handler()
.Done(c => (c.Saga1TimeoutFired && c.Saga2TimeoutFired) || c.SagaNotFound)
.Run(TimeSpan.FromSeconds(60));
- Assert.IsFalse(context.SagaNotFound);
- Assert.IsTrue(context.Saga1TimeoutFired);
- Assert.IsTrue(context.Saga2TimeoutFired);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SagaNotFound, Is.False);
+ Assert.That(context.Saga1TimeoutFired, Is.True);
+ Assert.That(context.Saga2TimeoutFired, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_reply_from_saga_not_found_handler.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_reply_from_saga_not_found_handler.cs
index d0ce1fa83bb..1435afe5ad2 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_reply_from_saga_not_found_handler.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_reply_from_saga_not_found_handler.cs
@@ -21,10 +21,13 @@ public async Task It_should_invoke_message_handler()
.Done(c => c.ReplyReceived)
.Run();
- Assert.IsTrue(context.Logs.Any(m => m.Message.Equals("Could not find a started saga of 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+ReceiverWithSaga+NotFoundHandlerSaga1' for message type 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+MessageToSaga'.")));
- Assert.IsTrue(context.Logs.Any(m => m.Message.Equals("Could not find a started saga of 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+ReceiverWithSaga+NotFoundHandlerSaga2' for message type 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+MessageToSaga'.")));
- Assert.IsTrue(context.Logs.Count(m => m.Message.Equals("Could not find any started sagas for message type 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+MessageToSaga'. Going to invoke SagaNotFoundHandlers.")) == 1);
- Assert.IsTrue(context.ReplyReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Logs.Any(m => m.Message.Equals("Could not find a started saga of 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+ReceiverWithSaga+NotFoundHandlerSaga1' for message type 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+MessageToSaga'.")), Is.True);
+ Assert.That(context.Logs.Any(m => m.Message.Equals("Could not find a started saga of 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+ReceiverWithSaga+NotFoundHandlerSaga2' for message type 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+MessageToSaga'.")), Is.True);
+ Assert.That(context.Logs.Count(m => m.Message.Equals("Could not find any started sagas for message type 'NServiceBus.AcceptanceTests.Sagas.When_reply_from_saga_not_found_handler+MessageToSaga'. Going to invoke SagaNotFoundHandlers.")), Is.EqualTo(1));
+ Assert.That(context.ReplyReceived, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_originator.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_originator.cs
index 0f5c5d79dad..f75bdec84ff 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_originator.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_originator.cs
@@ -16,7 +16,7 @@ public async Task Should_route_the_message_to_the_endpoint_starting_the_saga()
.Done(c => c.DidRequestingSagaGetTheResponse)
.Run();
- Assert.True(context.DidRequestingSagaGetTheResponse);
+ Assert.That(context.DidRequestingSagaGetTheResponse, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_originator_from_a_timeout.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_originator_from_a_timeout.cs
index b3200b6c059..59e70844e43 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_originator_from_a_timeout.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_originator_from_a_timeout.cs
@@ -18,7 +18,7 @@ public async Task Should_route_the_message_to_the_endpoint_starting_the_saga()
.Done(c => c.DidRequestingSagaGetTheResponse)
.Run(TimeSpan.FromSeconds(15));
- Assert.True(context.DidRequestingSagaGetTheResponse);
+ Assert.That(context.DidRequestingSagaGetTheResponse, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_saga_event.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_saga_event.cs
index 54e246ea393..40945212b7b 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_saga_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_replying_to_saga_event.cs
@@ -31,7 +31,7 @@ public async Task Should_correlate_reply_to_publishing_saga_instance()
.Done(c => c.CorrelatedResponseReceived)
.Run();
- Assert.True(context.CorrelatedResponseReceived);
+ Assert.That(context.CorrelatedResponseReceived, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_exists_for_start_message.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_exists_for_start_message.cs
index b347cf4e91b..ce32d84ff2b 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_exists_for_start_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_exists_for_start_message.cs
@@ -31,8 +31,8 @@ await session.SendLocal(
.Done(c => c.SagaIds.Count >= 2)
.Run();
- Assert.AreEqual(2, context.SagaIds.Count);
- Assert.AreEqual(context.SagaIds[0], context.SagaIds[1]);
+ Assert.That(context.SagaIds, Has.Count.EqualTo(2));
+ Assert.That(context.SagaIds[1], Is.EqualTo(context.SagaIds[0]));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_handles_unmapped_message.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_handles_unmapped_message.cs
index 93fe44d63f4..17695003cc1 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_handles_unmapped_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_handles_unmapped_message.cs
@@ -27,11 +27,14 @@ public async Task Should_throw_on_unmapped_uncorrelated_msg()
.Done(c => c.MappedEchoReceived && (c.EchoReceived || !c.FailedMessages.IsEmpty))
.Run();
- Assert.AreEqual(true, context.StartReceived);
- Assert.AreEqual(true, context.OutboundReceived);
- Assert.AreEqual(true, context.MappedEchoReceived);
- Assert.AreEqual(false, context.EchoReceived);
- Assert.AreEqual(1, context.FailedMessages.Count);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.StartReceived, Is.EqualTo(true));
+ Assert.That(context.OutboundReceived, Is.EqualTo(true));
+ Assert.That(context.MappedEchoReceived, Is.EqualTo(true));
+ Assert.That(context.EchoReceived, Is.EqualTo(false));
+ Assert.That(context.FailedMessages, Has.Count.EqualTo(1));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_id_changed.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_id_changed.cs
index 13e2f788c78..5900251d267 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_id_changed.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_id_changed.cs
@@ -24,9 +24,12 @@ await Scenario.Define()
.Done(c => !c.FailedMessages.IsEmpty)
.Run());
- Assert.That(exception.ScenarioContext.FailedMessages, Has.Count.EqualTo(1));
- Assert.That(((Context)exception.ScenarioContext).MessageId, Is.EqualTo(exception.FailedMessage.MessageId), "Message should be moved to errorqueue");
- Assert.That(exception.FailedMessage.Exception.Message, Contains.Substring("A modification of IContainSagaData.Id has been detected. This property is for infrastructure purposes only and should not be modified. SagaType:"));
+ Assert.Multiple(() =>
+ {
+ Assert.That(exception.ScenarioContext.FailedMessages, Has.Count.EqualTo(1));
+ Assert.That(((Context)exception.ScenarioContext).MessageId, Is.EqualTo(exception.FailedMessage.MessageId), "Message should be moved to errorqueue");
+ Assert.That(exception.FailedMessage.Exception.Message, Contains.Substring("A modification of IContainSagaData.Id has been detected. This property is for infrastructure purposes only and should not be modified. SagaType:"));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_is_mapped_to_complex_expression.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_is_mapped_to_complex_expression.cs
index 3681689889e..04c2e12ce28 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_is_mapped_to_complex_expression.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_is_mapped_to_complex_expression.cs
@@ -25,8 +25,11 @@ public async Task Should_hydrate_and_invoke_the_existing_instance()
.Done(c => c.SecondMessageReceived)
.Run();
- Assert.IsTrue(context.SecondMessageReceived);
- Assert.AreEqual(context.SagaIdWhenStartSagaMessageReceived, context.SagaIdWhenOtherMessageReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SecondMessageReceived, Is.True);
+ Assert.That(context.SagaIdWhenOtherMessageReceived, Is.EqualTo(context.SagaIdWhenStartSagaMessageReceived));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_started_concurrently.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_started_concurrently.cs
index a9837ca22d3..12b0075f28c 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_saga_started_concurrently.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_saga_started_concurrently.cs
@@ -30,9 +30,12 @@ public async Task Should_start_single_saga()
.Done(c => c.PlacedSagaId != Guid.Empty && c.BilledSagaId != Guid.Empty)
.Run();
- Assert.AreNotEqual(Guid.Empty, context.PlacedSagaId);
- Assert.AreNotEqual(Guid.Empty, context.BilledSagaId);
- Assert.AreEqual(context.PlacedSagaId, context.BilledSagaId, "Both messages should have been handled by the same saga, but SagaIds don't match.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.PlacedSagaId, Is.Not.EqualTo(Guid.Empty));
+ Assert.That(context.BilledSagaId, Is.Not.EqualTo(Guid.Empty));
+ });
+ Assert.That(context.BilledSagaId, Is.EqualTo(context.PlacedSagaId), "Both messages should have been handled by the same saga, but SagaIds don't match.");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_sagas_cant_be_found.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_sagas_cant_be_found.cs
index 3ac699f2c0c..3ca0f9dfd8c 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_sagas_cant_be_found.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_sagas_cant_be_found.cs
@@ -21,7 +21,7 @@ public async Task IHandleSagaNotFound_only_called_once()
.Done(c => c.Done)
.Run();
- Assert.AreEqual(1, context.TimesFired);
+ Assert.That(context.TimesFired, Is.EqualTo(1));
}
[Test]
@@ -35,11 +35,14 @@ public async Task IHandleSagaNotFound_not_called_if_second_saga_is_executed()
.Done(c => c.Done)
.Run();
- Assert.IsTrue(context.Logs.Any(m => m.Message.Equals("Could not find a started saga of 'NServiceBus.AcceptanceTests.Sagas.When_sagas_cant_be_found+ReceiverWithOrderedSagas+ReceiverWithOrderedSagasSaga1' for message type 'NServiceBus.AcceptanceTests.Sagas.When_sagas_cant_be_found+MessageToSaga'.")));
- Assert.IsFalse(context.Logs.Any(m => m.Message.Equals("Could not find a started saga of 'NServiceBus.AcceptanceTests.Sagas.When_sagas_cant_be_found+ReceiverWithOrderedSagas+ReceiverWithOrderedSagasSaga2' for message type 'NServiceBus.AcceptanceTests.Sagas.When_sagas_cant_be_found+MessageToSaga'.")));
- Assert.IsFalse(context.Logs.Any(m => m.Message.Contains("Going to invoke SagaNotFoundHandlers.")));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Logs.Any(m => m.Message.Equals("Could not find a started saga of 'NServiceBus.AcceptanceTests.Sagas.When_sagas_cant_be_found+ReceiverWithOrderedSagas+ReceiverWithOrderedSagasSaga1' for message type 'NServiceBus.AcceptanceTests.Sagas.When_sagas_cant_be_found+MessageToSaga'.")), Is.True);
+ Assert.That(context.Logs.Any(m => m.Message.Equals("Could not find a started saga of 'NServiceBus.AcceptanceTests.Sagas.When_sagas_cant_be_found+ReceiverWithOrderedSagas+ReceiverWithOrderedSagasSaga2' for message type 'NServiceBus.AcceptanceTests.Sagas.When_sagas_cant_be_found+MessageToSaga'.")), Is.False);
+ Assert.That(context.Logs.Any(m => m.Message.Contains("Going to invoke SagaNotFoundHandlers.")), Is.False);
- Assert.AreEqual(0, context.TimesFired);
+ Assert.That(context.TimesFired, Is.EqualTo(0));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_sagas_share_timeout_messages.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_sagas_share_timeout_messages.cs
index 24ee1f2d4ea..d89678380b7 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_sagas_share_timeout_messages.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_sagas_share_timeout_messages.cs
@@ -21,8 +21,11 @@ public async Task Should_invoke_instance_that_requested_the_timeout()
.Done(c => c.Saga1ReceivedTimeout || c.Saga2ReceivedTimeout)
.Run(TimeSpan.FromSeconds(30));
- Assert.IsTrue(context.Saga2ReceivedTimeout);
- Assert.IsFalse(context.Saga1ReceivedTimeout);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Saga2ReceivedTimeout, Is.True);
+ Assert.That(context.Saga1ReceivedTimeout, Is.False);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_sending_from_a_saga_handle.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_sending_from_a_saga_handle.cs
index 954f4c5a2ab..2a8d20f0af5 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_sending_from_a_saga_handle.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_sending_from_a_saga_handle.cs
@@ -19,7 +19,7 @@ public async Task Should_match_different_saga()
.Done(c => c.DidSaga2ReceiveMessage)
.Run();
- Assert.True(context.DidSaga2ReceiveMessage);
+ Assert.That(context.DidSaga2ReceiveMessage, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_sending_from_a_saga_timeout.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_sending_from_a_saga_timeout.cs
index 6c189ed228e..6420035079a 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_sending_from_a_saga_timeout.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_sending_from_a_saga_timeout.cs
@@ -21,7 +21,7 @@ public async Task Should_match_different_saga()
.Done(c => c.DidSaga2ReceiveMessage)
.Run();
- Assert.True(context.DidSaga2ReceiveMessage);
+ Assert.That(context.DidSaga2ReceiveMessage, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_started_by_base_event_from_other_saga.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_started_by_base_event_from_other_saga.cs
index 5832df5e902..1f1e5d5fc24 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_started_by_base_event_from_other_saga.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_started_by_base_event_from_other_saga.cs
@@ -31,7 +31,7 @@ public async Task Should_start_the_saga_when_set_up_to_start_for_the_base_event(
.Done(c => c.DidSagaComplete)
.Run();
- Assert.True(context.DidSagaComplete);
+ Assert.That(context.DidSagaComplete, Is.True);
}
public class SagaContext : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_started_by_event_from_another_saga.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_started_by_event_from_another_saga.cs
index 780dac0e0e6..bc3d456258f 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_started_by_event_from_another_saga.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_started_by_event_from_another_saga.cs
@@ -36,7 +36,7 @@ public async Task Should_start_the_saga_and_request_a_timeout()
.Done(c => c.DidSaga1Complete && c.DidSaga2Complete)
.Run();
- Assert.True(context.DidSaga1Complete && context.DidSaga2Complete);
+ Assert.That(context.DidSaga1Complete && context.DidSaga2Complete, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_timeout_hit_not_found_saga.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_timeout_hit_not_found_saga.cs
index a53d995603e..15c1ee2bb66 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_timeout_hit_not_found_saga.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_timeout_hit_not_found_saga.cs
@@ -22,7 +22,7 @@ public async Task Should_not_fire_notfound_for_tm()
.Done(c => c.NotFoundHandlerCalledForRegularMessage)
.Run();
- Assert.False(context.NotFoundHandlerCalledForTimeout);
+ Assert.That(context.NotFoundHandlerCalledForTimeout, Is.False);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_two_sagas_subscribe_to_the_same_event.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_two_sagas_subscribe_to_the_same_event.cs
index 94ae22a354c..d996e29d63e 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_two_sagas_subscribe_to_the_same_event.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_two_sagas_subscribe_to_the_same_event.cs
@@ -27,7 +27,7 @@ public async Task Should_invoke_all_handlers_on_all_sagas()
.Done(c => c.DidSaga1EventHandlerGetInvoked && c.DidSaga2EventHandlerGetInvoked)
.Run();
- Assert.True(context.DidSaga1EventHandlerGetInvoked && context.DidSaga2EventHandlerGetInvoked);
+ Assert.That(context.DidSaga1EventHandlerGetInvoked && context.DidSaga2EventHandlerGetInvoked, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_updating_existing_correlation_property.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_updating_existing_correlation_property.cs
index cc9b6bd2f31..c9e5aca66de 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_updating_existing_correlation_property.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_updating_existing_correlation_property.cs
@@ -22,11 +22,14 @@ await Scenario.Define()
.Done(c => !c.FailedMessages.IsEmpty)
.Run());
- Assert.IsTrue(((Context)exception.ScenarioContext).ModifiedCorrelationProperty);
- Assert.AreEqual(1, exception.ScenarioContext.FailedMessages.Count);
- StringAssert.Contains(
- "Changing the value of correlated properties at runtime is currently not supported",
- exception.FailedMessage.Exception.Message);
+ Assert.Multiple(() =>
+ {
+ Assert.That(((Context)exception.ScenarioContext).ModifiedCorrelationProperty, Is.True);
+ Assert.That(exception.ScenarioContext.FailedMessages, Has.Count.EqualTo(1));
+ });
+ Assert.That(
+ exception.FailedMessage.Exception.Message,
+ Does.Contain("Changing the value of correlated properties at runtime is currently not supported"));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_using_a_received_message_for_timeout.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_using_a_received_message_for_timeout.cs
index b9e275ff1b5..612e3aea17a 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_using_a_received_message_for_timeout.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_using_a_received_message_for_timeout.cs
@@ -21,8 +21,11 @@ public async Task Timeout_should_be_received_after_expiration()
.Done(c => c.TimeoutReceived)
.Run();
- Assert.True(context.TimeoutReceived);
- Assert.AreEqual(1, context.HandlerCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.TimeoutReceived, Is.True);
+ Assert.That(context.HandlerCalled, Is.EqualTo(1));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Sagas/When_using_contain_saga_data.cs b/src/NServiceBus.AcceptanceTests/Sagas/When_using_contain_saga_data.cs
index 496cacc828f..0894cfeed76 100644
--- a/src/NServiceBus.AcceptanceTests/Sagas/When_using_contain_saga_data.cs
+++ b/src/NServiceBus.AcceptanceTests/Sagas/When_using_contain_saga_data.cs
@@ -22,7 +22,7 @@ public async Task Should_handle_timeouts_properly()
.Done(c => c.TimeoutReceived)
.Run();
- Assert.True(context.TimeoutReceived);
+ Assert.That(context.TimeoutReceived, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Satellites/When_a_message_is_available.cs b/src/NServiceBus.AcceptanceTests/Satellites/When_a_message_is_available.cs
index f31bca197cc..0537e07f4e4 100644
--- a/src/NServiceBus.AcceptanceTests/Satellites/When_a_message_is_available.cs
+++ b/src/NServiceBus.AcceptanceTests/Satellites/When_a_message_is_available.cs
@@ -20,12 +20,15 @@ public async Task Should_receive_the_message()
.Done(c => c.MessageReceived)
.Run();
- Assert.True(context.MessageReceived);
- // In the future we want the transport transaction to be an explicit
- // concept in the persisters API as well. Adding transport transaction
- // to the context will not be necessary at that point.
- // See GitHub issue #4047 for more background information.
- Assert.True(context.TransportTransactionAddedToContext);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.MessageReceived, Is.True);
+ // In the future we want the transport transaction to be an explicit
+ // concept in the persisters API as well. Adding transport transaction
+ // to the context will not be necessary at that point.
+ // See GitHub issue #4047 for more background information.
+ Assert.That(context.TransportTransactionAddedToContext, Is.True);
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_configuring_custom_xml_namespace.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_configuring_custom_xml_namespace.cs
index 8d87c2aa42a..be666a8e8f8 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_configuring_custom_xml_namespace.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_configuring_custom_xml_namespace.cs
@@ -21,7 +21,7 @@ public async Task Should_use_as_root_namespace_in_messages()
.Done(c => c.MessageReceived)
.Run();
- Assert.AreEqual($"{CustomXmlNamespace}/{typeof(SimpleMessage).Namespace}", context.MessageNamespace);
+ Assert.That(context.MessageNamespace, Is.EqualTo($"{CustomXmlNamespace}/{typeof(SimpleMessage).Namespace}"));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_defining_serializer_with_no_content_type.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_defining_serializer_with_no_content_type.cs
index b0eac289b05..d52cbbc0af9 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_defining_serializer_with_no_content_type.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_defining_serializer_with_no_content_type.cs
@@ -21,7 +21,7 @@ public void Should_fail_endpoint_startup_for_main_serializer()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains($"Serializer '{nameof(InvalidSerializer)}' defines no content type. Ensure the 'ContentType' property of the serializer has a value.", exception.Message);
+ Assert.That(exception.Message, Does.Contain($"Serializer '{nameof(InvalidSerializer)}' defines no content type. Ensure the 'ContentType' property of the serializer has a value."));
}
[Test]
@@ -33,7 +33,7 @@ public void Should_fail_endpoint_startup_for_additional_deserializer()
.Done(c => c.EndpointsStarted)
.Run());
- StringAssert.Contains($"Serializer '{nameof(InvalidSerializer)}' defines no content type. Ensure the 'ContentType' property of the serializer has a value.", exception.Message);
+ Assert.That(exception.Message, Does.Contain($"Serializer '{nameof(InvalidSerializer)}' defines no content type. Ensure the 'ContentType' property of the serializer has a value."));
}
class EndpointWithInvalidSerializer : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_disabling_serializer_type_inference.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_disabling_serializer_type_inference.cs
index a25883fc956..0cb1408c33e 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_disabling_serializer_type_inference.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_disabling_serializer_type_inference.cs
@@ -25,11 +25,14 @@ public async Task Should_not_deserialize_messages_without_types_header()
.Done(c => c.IncomingMessageReceived)
.Run(TimeSpan.FromSeconds(35));
- Assert.IsFalse(context.HandlerInvoked);
- Assert.AreEqual(1, context.FailedMessages.Single().Value.Count);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HandlerInvoked, Is.False);
+ Assert.That(context.FailedMessages.Single().Value, Has.Count.EqualTo(1));
+ });
Exception exception = context.FailedMessages.Single().Value.Single().Exception;
- Assert.IsInstanceOf(exception);
- StringAssert.Contains($"Could not determine the message type from the '{Headers.EnclosedMessageTypes}' header", exception.InnerException.Message);
+ Assert.That(exception, Is.InstanceOf());
+ Assert.That(exception.InnerException.Message, Does.Contain($"Could not determine the message type from the '{Headers.EnclosedMessageTypes}' header"));
}
[Test]
@@ -42,11 +45,14 @@ public async Task Should_not_deserialize_messages_with_unknown_type_header()
.Done(c => c.IncomingMessageReceived)
.Run(TimeSpan.FromSeconds(35));
- Assert.IsFalse(context.HandlerInvoked);
- Assert.AreEqual(1, context.FailedMessages.Single().Value.Count);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HandlerInvoked, Is.False);
+ Assert.That(context.FailedMessages.Single().Value, Has.Count.EqualTo(1));
+ });
Exception exception = context.FailedMessages.Single().Value.Single().Exception;
- Assert.IsInstanceOf(exception);
- StringAssert.Contains($"Could not determine the message type from the '{Headers.EnclosedMessageTypes}' header", exception.InnerException.Message);
+ Assert.That(exception, Is.InstanceOf());
+ Assert.That(exception.InnerException.Message, Does.Contain($"Could not determine the message type from the '{Headers.EnclosedMessageTypes}' header"));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_dynamic_loading_is_disabled.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_dynamic_loading_is_disabled.cs
index 31175f72a60..3522a03157c 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_dynamic_loading_is_disabled.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_dynamic_loading_is_disabled.cs
@@ -21,10 +21,10 @@ public async Task Should_not_load_type_dynamically()
.Done(c => c.MessageReceived)
.Run();
- Assert.AreEqual(1, context.FailedMessages.Single().Value.Count);
+ Assert.That(context.FailedMessages.Single().Value, Has.Count.EqualTo(1));
Exception exception = context.FailedMessages.Single().Value.Single().Exception;
- Assert.IsInstanceOf(exception);
- Assert.AreEqual($"Could not determine the message type from the '{Headers.EnclosedMessageTypes}' header and message type inference from the message body has been disabled. Ensure the header is set or enable message type inference.", exception.InnerException.Message);
+ Assert.That(exception, Is.InstanceOf());
+ Assert.That(exception.InnerException.Message, Is.EqualTo($"Could not determine the message type from the '{Headers.EnclosedMessageTypes}' header and message type inference from the message body has been disabled. Ensure the header is set or enable message type inference."));
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_message_type_header_is_whitespaces.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_message_type_header_is_whitespaces.cs
index 4540537c001..9576165e542 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_message_type_header_is_whitespaces.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_message_type_header_is_whitespaces.cs
@@ -20,10 +20,13 @@ public async Task Should_move_message_to_error_queue()
.Done(c => c.IncomingMessageReceived)
.Run(TimeSpan.FromSeconds(20));
- Assert.IsFalse(context.HandlerInvoked);
- Assert.AreEqual(1, context.FailedMessages.Single().Value.Count);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HandlerInvoked, Is.False);
+ Assert.That(context.FailedMessages.Single().Value, Has.Count.EqualTo(1));
+ });
Exception exception = context.FailedMessages.Single().Value.Single().Exception;
- Assert.IsInstanceOf(exception);
+ Assert.That(exception, Is.InstanceOf());
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_additional_deserializers.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_additional_deserializers.cs
index b707bcc88dc..e506b6658c4 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_additional_deserializers.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_additional_deserializers.cs
@@ -30,10 +30,13 @@ public async Task Two_endpoints_with_different_serializers_should_deserialize_th
.Done(c => c.HandlerGotTheRequest)
.Run();
- Assert.True(context.HandlerGotTheRequest);
- Assert.True(context.SerializeCalled);
- Assert.True(context.DeserializeCalled);
- Assert.AreEqual("SomeFancySettings", context.ValueFromSettings);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HandlerGotTheRequest, Is.True);
+ Assert.That(context.SerializeCalled, Is.True);
+ Assert.That(context.DeserializeCalled, Is.True);
+ Assert.That(context.ValueFromSettings, Is.EqualTo("SomeFancySettings"));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_custom_serializer.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_custom_serializer.cs
index ad7e4d0c50b..cbf96cd8e61 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_custom_serializer.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_custom_serializer.cs
@@ -24,8 +24,11 @@ public async Task Should_use_the_custom_serializer()
.Done(c => c.HandlerGotTheRequest)
.Run();
- Assert.IsTrue(context.SerializeCalled);
- Assert.IsTrue(context.DeserializeCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SerializeCalled, Is.True);
+ Assert.That(context.DeserializeCalled, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_deserializers_with_settings.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_deserializers_with_settings.cs
index 3773576cb22..9e20d9f483b 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_deserializers_with_settings.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_deserializers_with_settings.cs
@@ -32,11 +32,14 @@ public async Task Should_not_override_serializer_settings()
.Done(c => c.DeserializeCalled)
.Run();
- Assert.True(context.HandlerGotTheRequest);
- Assert.True(context.SerializeCalled);
- Assert.True(context.DeserializeCalled);
- Assert.AreEqual(Value1, context.ValueFromSettingsForMainSerializer);
- Assert.AreEqual(Value2, context.ValueFromSettingsForDeserializer);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HandlerGotTheRequest, Is.True);
+ Assert.That(context.SerializeCalled, Is.True);
+ Assert.That(context.DeserializeCalled, Is.True);
+ Assert.That(context.ValueFromSettingsForMainSerializer, Is.EqualTo(Value1));
+ Assert.That(context.ValueFromSettingsForDeserializer, Is.EqualTo(Value2));
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_serializing_a_message.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_serializing_a_message.cs
index e46461357a1..107b4e8968e 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_serializing_a_message.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_serializing_a_message.cs
@@ -35,16 +35,22 @@ public async Task DateTime_properties_should_keep_their_original_timezone_inform
.Done(c => c.ReceivedMessage != null)
.Run();
- Assert.AreEqual(expectedDateTime, context.ReceivedMessage.DateTime);
- Assert.AreEqual(expectedDateTimeLocal, context.ReceivedMessage.DateTimeLocal);
- Assert.AreEqual(expectedDateTimeUtc, context.ReceivedMessage.DateTimeUtc);
- Assert.AreEqual(expectedDateTimeOffset, context.ReceivedMessage.DateTimeOffset);
- Assert.AreEqual(expectedDateTimeOffsetLocal, context.ReceivedMessage.DateTimeOffsetLocal);
- Assert.AreEqual(expectedDateTimeOffsetUtc, context.ReceivedMessage.DateTimeOffsetUtc);
- Assert.AreEqual(expectedDateTimeOffsetLocal, context.ReceivedMessage.DateTimeOffsetLocal);
- Assert.AreEqual(expectedDateTimeOffsetLocal.Offset, context.ReceivedMessage.DateTimeOffsetLocal.Offset);
- Assert.AreEqual(expectedDateTimeOffsetUtc, context.ReceivedMessage.DateTimeOffsetUtc);
- Assert.AreEqual(expectedDateTimeOffsetUtc.Offset, context.ReceivedMessage.DateTimeOffsetUtc.Offset);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ReceivedMessage.DateTime, Is.EqualTo(expectedDateTime));
+ Assert.That(context.ReceivedMessage.DateTimeLocal, Is.EqualTo(expectedDateTimeLocal));
+ Assert.That(context.ReceivedMessage.DateTimeUtc, Is.EqualTo(expectedDateTimeUtc));
+ Assert.That(context.ReceivedMessage.DateTimeOffset, Is.EqualTo(expectedDateTimeOffset));
+ Assert.That(context.ReceivedMessage.DateTimeOffsetLocal, Is.EqualTo(expectedDateTimeOffsetLocal));
+ Assert.That(context.ReceivedMessage.DateTimeOffsetUtc, Is.EqualTo(expectedDateTimeOffsetUtc));
+ });
+ Assert.That(context.ReceivedMessage.DateTimeOffsetLocal, Is.EqualTo(expectedDateTimeOffsetLocal));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.ReceivedMessage.DateTimeOffsetLocal.Offset, Is.EqualTo(expectedDateTimeOffsetLocal.Offset));
+ Assert.That(context.ReceivedMessage.DateTimeOffsetUtc, Is.EqualTo(expectedDateTimeOffsetUtc));
+ });
+ Assert.That(context.ReceivedMessage.DateTimeOffsetUtc.Offset, Is.EqualTo(expectedDateTimeOffsetUtc.Offset));
}
class DateTimeReceiver : EndpointConfigurationBuilder
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_skip_wrapping_xml.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_skip_wrapping_xml.cs
index 7210731f135..2514e2e6af4 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_skip_wrapping_xml.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_skip_wrapping_xml.cs
@@ -23,9 +23,12 @@ public async Task Should_not_wrap_xml_content()
.Done(c => c.MessageReceived)
.Run();
- Assert.That(context.XmlPropertyValue.ToString(), Is.EqualTo(xmlContent.ToString()));
- Assert.That(context.XmlMessage.Root.Name.LocalName, Is.EqualTo(nameof(MessageWithRawXml)));
- Assert.That(context.XmlMessage.Root.Elements().Single().ToString(), Is.EqualTo(xmlContent.ToString()));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.XmlPropertyValue.ToString(), Is.EqualTo(xmlContent.ToString()));
+ Assert.That(context.XmlMessage.Root.Name.LocalName, Is.EqualTo(nameof(MessageWithRawXml)));
+ Assert.That(context.XmlMessage.Root.Elements().Single().ToString(), Is.EqualTo(xmlContent.ToString()));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_wrapping_is_not_skipped.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_wrapping_is_not_skipped.cs
index 70d7892e3e9..2826bad198d 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_wrapping_is_not_skipped.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_wrapping_is_not_skipped.cs
@@ -23,11 +23,14 @@ public async Task Should_wrap_xml_content()
.Done(c => c.MessageReceived)
.Run();
- Assert.That(context.XmlPropertyValue.ToString(), Is.EqualTo(xmlContent.ToString()));
- Assert.That(context.XmlMessage.Root.Name.LocalName, Is.EqualTo(nameof(MessageWithRawXml)));
- Assert.That(context.XmlMessage.Root.Elements().Single().Name.LocalName, Is.EqualTo("Document"));
- Assert.That(context.XmlMessage.Root.Elements().Single().Elements().Single().Name.LocalName, Is.EqualTo("Document"));
- Assert.That(context.XmlMessage.Root.Elements().Single().Elements().Single().ToString(), Is.EqualTo(xmlContent.ToString()));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.XmlPropertyValue.ToString(), Is.EqualTo(xmlContent.ToString()));
+ Assert.That(context.XmlMessage.Root.Name.LocalName, Is.EqualTo(nameof(MessageWithRawXml)));
+ Assert.That(context.XmlMessage.Root.Elements().Single().Name.LocalName, Is.EqualTo("Document"));
+ Assert.That(context.XmlMessage.Root.Elements().Single().Elements().Single().Name.LocalName, Is.EqualTo("Document"));
+ Assert.That(context.XmlMessage.Root.Elements().Single().Elements().Single().ToString(), Is.EqualTo(xmlContent.ToString()));
+ });
}
class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_xml_serializer_processes_message_without_type_header.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_xml_serializer_processes_message_without_type_header.cs
index b951934ca76..f315f96eb69 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_xml_serializer_processes_message_without_type_header.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_xml_serializer_processes_message_without_type_header.cs
@@ -17,7 +17,7 @@ public async Task Should_work_in_unobtrusive()
.Done(c => c.WasCalled)
.Run();
- Assert.True(context.WasCalled);
+ Assert.That(context.WasCalled, Is.True);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_xml_serializer_used_with_unobtrusive_mode.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_xml_serializer_used_with_unobtrusive_mode.cs
index 3377d50e9be..04ae152c51a 100644
--- a/src/NServiceBus.AcceptanceTests/Serialization/When_xml_serializer_used_with_unobtrusive_mode.cs
+++ b/src/NServiceBus.AcceptanceTests/Serialization/When_xml_serializer_used_with_unobtrusive_mode.cs
@@ -20,7 +20,7 @@ public async Task Should_deserialize_message()
.Done(c => c.WasCalled)
.Run();
- Assert.AreEqual(expectedData, context.Data);
+ Assert.That(context.Data, Is.EqualTo(expectedData));
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs b/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs
index b1b9db47bd8..6cef645ee53 100644
--- a/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs
+++ b/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs
@@ -20,7 +20,7 @@ public async Task Message_should_not_be_received()
.Done(c => c.WasCalled || DateTime.UtcNow - start > TimeSpan.FromSeconds(15))
.Run();
- Assert.IsFalse(context.WasCalled);
+ Assert.That(context.WasCalled, Is.False);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs b/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs
index 2405d89f67e..80c1a2a4eaa 100644
--- a/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs
+++ b/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs
@@ -20,7 +20,7 @@ public async Task Message_should_not_be_received()
.Done(c => c.WasCalled || DateTime.UtcNow - start > TimeSpan.FromSeconds(15))
.Run();
- Assert.IsFalse(context.WasCalled);
+ Assert.That(context.WasCalled, Is.False);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs b/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs
index 4c3c204a9f0..533850d25a6 100644
--- a/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs
+++ b/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs
@@ -16,8 +16,11 @@ public async Task Message_should_be_received()
.Done(c => c.WasCalled)
.Run();
- Assert.IsTrue(context.WasCalled);
- Assert.AreEqual(TimeSpan.FromSeconds(10), context.TTBROnIncomingMessage, "TTBR should be available as a header so receiving endpoints can know what value was used when the message was originally sent");
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.WasCalled, Is.True);
+ Assert.That(context.TTBROnIncomingMessage, Is.EqualTo(TimeSpan.FromSeconds(10)), "TTBR should be available as a header so receiving endpoints can know what value was used when the message was originally sent");
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_used_with_unobtrusive_mode.cs b/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_used_with_unobtrusive_mode.cs
index f62d6325ad2..70bd7dc0ed3 100644
--- a/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_used_with_unobtrusive_mode.cs
+++ b/src/NServiceBus.AcceptanceTests/TimeToBeReceived/When_TimeToBeReceived_used_with_unobtrusive_mode.cs
@@ -20,7 +20,7 @@ public async Task Message_should_not_be_received()
.Done(c => c.WasCalled || DateTime.UtcNow - start > TimeSpan.FromSeconds(15))
.Run();
- Assert.IsFalse(context.WasCalled);
+ Assert.That(context.WasCalled, Is.False);
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/At_least_once.cs b/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/At_least_once.cs
index 40f34422de7..ec1c40ce08d 100644
--- a/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/At_least_once.cs
+++ b/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/At_least_once.cs
@@ -17,7 +17,7 @@ public async Task Should_dispatch_immediately()
.Done(c => c.MessageDispatched)
.Run();
- Assert.True(context.MessageDispatched, "Should dispatch the message immediately");
+ Assert.That(context.MessageDispatched, Is.True, "Should dispatch the message immediately");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/At_most_once.cs b/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/At_most_once.cs
index 752da3911fc..c3e513c6ca7 100644
--- a/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/At_most_once.cs
+++ b/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/At_most_once.cs
@@ -17,7 +17,7 @@ public async Task Should_dispatch_immediately()
.Done(c => c.MessageDispatched)
.Run();
- Assert.True(context.MessageDispatched, "Should dispatch the message immediately");
+ Assert.That(context.MessageDispatched, Is.True, "Should dispatch the message immediately");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/Exactly_once.cs b/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/Exactly_once.cs
index 867d184afb1..c2443c04dbe 100644
--- a/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/Exactly_once.cs
+++ b/src/NServiceBus.AcceptanceTests/Tx/ImmediateDispatch/Exactly_once.cs
@@ -17,7 +17,7 @@ public async Task Should_dispatch_immediately()
.Done(c => c.MessageDispatched)
.Run();
- Assert.True(context.MessageDispatched, "Should dispatch the message immediately");
+ Assert.That(context.MessageDispatched, Is.True, "Should dispatch the message immediately");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_in_transaction_scope_mode.cs b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_in_transaction_scope_mode.cs
index c027c590c16..b728b122a1a 100644
--- a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_in_transaction_scope_mode.cs
+++ b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_in_transaction_scope_mode.cs
@@ -19,7 +19,7 @@ public async Task Should_enlist_in_dtc_transaction()
.Done(c => c.HandlerInvoked)
.Run();
- Assert.True(context.DtcTransactionPresent, "There should exists a DTC tx");
+ Assert.That(context.DtcTransactionPresent, Is.True, "There should exists a DTC tx");
}
diff --git a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_native_multi_queue_transaction.cs b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_native_multi_queue_transaction.cs
index 136040d5986..09655906fd1 100644
--- a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_native_multi_queue_transaction.cs
+++ b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_native_multi_queue_transaction.cs
@@ -17,8 +17,11 @@ public async Task Should_not_send_outgoing_messages_if_receiving_transaction_is_
.Done(c => c.MessageHandled)
.Run();
- Assert.IsFalse(context.HasFailed);
- Assert.IsTrue(context.MessageHandled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.HasFailed, Is.False);
+ Assert.That(context.MessageHandled, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Tx/When_sending_within_an_ambient_transaction.cs b/src/NServiceBus.AcceptanceTests/Tx/When_sending_within_an_ambient_transaction.cs
index 75f4b44c71d..c2f1502f0b1 100644
--- a/src/NServiceBus.AcceptanceTests/Tx/When_sending_within_an_ambient_transaction.cs
+++ b/src/NServiceBus.AcceptanceTests/Tx/When_sending_within_an_ambient_transaction.cs
@@ -40,7 +40,7 @@ await session.Send(new MessageThatIsEnlisted
.Done(c => c.MessageThatIsNotEnlistedHandlerWasCalled && c.TimesCalled >= 2)
.Run();
- Assert.AreEqual(1, context.SequenceNumberOfFirstMessage, "The transport should preserve the order in which the transactional messages are delivered to the queuing system");
+ Assert.That(context.SequenceNumberOfFirstMessage, Is.EqualTo(1), "The transport should preserve the order in which the transactional messages are delivered to the queuing system");
}
[Test]
@@ -62,7 +62,7 @@ public async Task Should_not_deliver_them_on_rollback()
.Done(c => c.MessageThatIsNotEnlistedHandlerWasCalled)
.Run();
- Assert.False(context.MessageThatIsEnlistedHandlerWasCalled, "The transactional handler should not be called");
+ Assert.That(context.MessageThatIsEnlistedHandlerWasCalled, Is.False, "The transactional handler should not be called");
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.AcceptanceTests/Versioning/When_multiple_versions_of_a_message_is_published.cs b/src/NServiceBus.AcceptanceTests/Versioning/When_multiple_versions_of_a_message_is_published.cs
index f6ba34d8c70..052dbe866a6 100644
--- a/src/NServiceBus.AcceptanceTests/Versioning/When_multiple_versions_of_a_message_is_published.cs
+++ b/src/NServiceBus.AcceptanceTests/Versioning/When_multiple_versions_of_a_message_is_published.cs
@@ -41,8 +41,11 @@ public async Task Should_deliver_is_to_both_v1_and_vX_subscribers()
.Done(c => c.V1SubscriberGotTheMessage && c.V2SubscriberGotTheMessage)
.Run();
- Assert.True(context.V1SubscriberGotTheMessage);
- Assert.True(context.V2SubscriberGotTheMessage);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.V1SubscriberGotTheMessage, Is.True);
+ Assert.That(context.V2SubscriberGotTheMessage, Is.True);
+ });
}
public class Context : ScenarioContext
diff --git a/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj b/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj
index 2ed017d5ff0..2b84364d165 100644
--- a/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj
+++ b/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj
@@ -13,7 +13,8 @@
-
+
+
diff --git a/src/NServiceBus.ContainerTests/When_building_components.cs b/src/NServiceBus.ContainerTests/When_building_components.cs
index 600dfb4b3dc..366be54fe17 100644
--- a/src/NServiceBus.ContainerTests/When_building_components.cs
+++ b/src/NServiceBus.ContainerTests/When_building_components.cs
@@ -13,7 +13,10 @@ public void Singleton_components_should_yield_the_same_instance()
InitializeServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.AreEqual(serviceProvider.GetService(typeof(SingletonComponent)), serviceProvider.GetService(typeof(SingletonComponent)));
+ var instance1 = serviceProvider.GetService(typeof(SingletonComponent));
+ var instance2 = serviceProvider.GetService(typeof(SingletonComponent));
+
+ Assert.That(instance1, Is.EqualTo(instance2));
}
[Test]
@@ -23,7 +26,10 @@ public void Transient_components_should_yield_unique_instances()
InitializeServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.AreNotEqual(serviceProvider.GetService(), serviceProvider.GetService());
+ var instance1 = serviceProvider.GetService();
+ var instance2 = serviceProvider.GetService();
+
+ Assert.That(instance1, Is.Not.EqualTo(instance2));
}
[Test]
@@ -36,7 +42,7 @@ public void Scoped_components_should_yield_the_same_instance()
var instance1 = serviceProvider.GetService(typeof(ScopedComponent));
var instance2 = serviceProvider.GetService(typeof(ScopedComponent));
- Assert.AreSame(instance1, instance2);
+ Assert.That(instance2, Is.SameAs(instance1));
}
[Test]
@@ -49,7 +55,7 @@ public void Lambda_scoped_components_should_yield_the_same_instance()
var instance1 = serviceProvider.GetService(typeof(ScopedLambdaComponent));
var instance2 = serviceProvider.GetService(typeof(ScopedLambdaComponent));
- Assert.AreSame(instance1, instance2);
+ Assert.That(instance2, Is.SameAs(instance1));
}
[Test]
@@ -59,7 +65,10 @@ public void Lambda_transient_components_should_yield_unique_instances()
InitializeServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.AreNotEqual(serviceProvider.GetService(typeof(TransientLambdaComponent)), serviceProvider.GetService(typeof(TransientLambdaComponent)));
+ var instance1 = serviceProvider.GetService(typeof(TransientLambdaComponent));
+ var instance2 = serviceProvider.GetService(typeof(TransientLambdaComponent));
+
+ Assert.That(instance1, Is.Not.EqualTo(instance2));
}
[Test]
@@ -69,7 +78,10 @@ public void Lambda_singleton_components_should_yield_the_same_instance()
InitializeServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.AreEqual(serviceProvider.GetService(typeof(SingletonLambdaComponent)), serviceProvider.GetService(typeof(SingletonLambdaComponent)));
+ var instance1 = serviceProvider.GetService(typeof(SingletonLambdaComponent));
+ var instance2 = serviceProvider.GetService(typeof(SingletonLambdaComponent));
+
+ Assert.That(instance1, Is.EqualTo(instance2));
}
[Test]
@@ -79,7 +91,7 @@ public void Resolving_all_components_of_unregistered_types_should_give_empty_lis
InitializeServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.IsEmpty(serviceProvider.GetServices(typeof(UnregisteredComponent)));
+ Assert.That(serviceProvider.GetServices(typeof(UnregisteredComponent)), Is.Empty);
}
[Test]
diff --git a/src/NServiceBus.ContainerTests/When_disposing_the_builder.cs b/src/NServiceBus.ContainerTests/When_disposing_the_builder.cs
index d4617c15e4f..9847cd7236b 100644
--- a/src/NServiceBus.ContainerTests/When_disposing_the_builder.cs
+++ b/src/NServiceBus.ContainerTests/When_disposing_the_builder.cs
@@ -22,8 +22,11 @@ public void Should_dispose_all_IDisposable_components()
serviceProvider.GetService(typeof(AnotherSingletonComponent));
(serviceProvider as IDisposable)?.Dispose();
- Assert.True(DisposableComponent.DisposeCalled, "Dispose should be called on DisposableComponent");
- Assert.False(AnotherSingletonComponent.DisposeCalled, "Dispose should not be called on AnotherSingletonComponent");
+ Assert.Multiple(() =>
+ {
+ Assert.That(DisposableComponent.DisposeCalled, Is.True, "Dispose should be called on DisposableComponent");
+ Assert.That(AnotherSingletonComponent.DisposeCalled, Is.False, "Dispose should not be called on AnotherSingletonComponent");
+ });
}
public class DisposableComponent : IDisposable
diff --git a/src/NServiceBus.ContainerTests/When_querying_for_registered_components.cs b/src/NServiceBus.ContainerTests/When_querying_for_registered_components.cs
index d5be6dd446c..75ce8158f22 100644
--- a/src/NServiceBus.ContainerTests/When_querying_for_registered_components.cs
+++ b/src/NServiceBus.ContainerTests/When_querying_for_registered_components.cs
@@ -13,7 +13,7 @@ public void Existing_components_should_return_true()
var serviceCollection = new ServiceCollection();
InitializeBuilder(serviceCollection);
- Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ExistingComponent)));
+ Assert.That(serviceCollection.Any(sd => sd.ServiceType == typeof(ExistingComponent)), Is.True);
}
[Test]
@@ -22,7 +22,7 @@ public void Non_existing_components_should_return_false()
var serviceCollection = new ServiceCollection();
InitializeBuilder(serviceCollection);
- Assert.False(serviceCollection.Any(sd => sd.ServiceType == typeof(NonExistingComponent)));
+ Assert.That(serviceCollection.Any(sd => sd.ServiceType == typeof(NonExistingComponent)), Is.False);
}
[Test]
@@ -31,7 +31,7 @@ public void Builders_should_not_determine_existence_by_building_components()
var serviceCollection = new ServiceCollection();
InitializeBuilder(serviceCollection);
- Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ExistingComponentWithUnsatisfiedDependency)));
+ Assert.That(serviceCollection.Any(sd => sd.ServiceType == typeof(ExistingComponentWithUnsatisfiedDependency)), Is.True);
}
static void InitializeBuilder(IServiceCollection c)
diff --git a/src/NServiceBus.ContainerTests/When_registering_components.cs b/src/NServiceBus.ContainerTests/When_registering_components.cs
index 1b1e74652ad..07d0a460fef 100644
--- a/src/NServiceBus.ContainerTests/When_registering_components.cs
+++ b/src/NServiceBus.ContainerTests/When_registering_components.cs
@@ -18,7 +18,7 @@ public void Multiple_registrations_of_the_same_component_should_be_allowed()
serviceCollection.AddTransient(typeof(DuplicateClass));
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.AreEqual(2, serviceProvider.GetServices(typeof(DuplicateClass)).Count());
+ Assert.That(serviceProvider.GetServices(typeof(DuplicateClass)).Count(), Is.EqualTo(2));
}
[Test]
@@ -29,7 +29,7 @@ public void Should_support_lambdas_that_uses_other_components_registered_later()
serviceCollection.AddSingleton(_ => new StaticFactory());
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.NotNull(serviceProvider.GetService(typeof(ComponentCreatedByFactory)));
+ Assert.That(serviceProvider.GetService(typeof(ComponentCreatedByFactory)), Is.Not.Null);
}
[Test]
@@ -40,7 +40,7 @@ public void A_registration_should_be_allowed_to_be_updated()
serviceCollection.AddSingleton(typeof(ISingletonComponent), new AnotherSingletonComponent());
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.IsInstanceOf(serviceProvider.GetService(typeof(ISingletonComponent)));
+ Assert.That(serviceProvider.GetService(typeof(ISingletonComponent)), Is.InstanceOf());
}
[Test]
@@ -52,8 +52,8 @@ public void Register_singleton_should_be_supported()
serviceCollection.AddSingleton(typeof(SingletonComponent), singleton);
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.AreEqual(serviceProvider.GetService(typeof(SingletonComponent)), singleton);
- Assert.AreEqual(serviceProvider.GetService(typeof(ISingletonComponent)), singleton);
+ Assert.That(singleton, Is.EqualTo(serviceProvider.GetService(typeof(SingletonComponent))));
+ Assert.That(singleton, Is.EqualTo(serviceProvider.GetService(typeof(ISingletonComponent))));
}
[Test]
@@ -68,11 +68,14 @@ public void Registering_the_same_singleton_for_different_interfaces_should_be_su
var serviceProvider = serviceCollection.BuildServiceProvider();
var dependency = (ComponentThatDependsOnMultiSingletons)serviceProvider.GetService(typeof(ComponentThatDependsOnMultiSingletons));
- Assert.NotNull(dependency.Singleton1);
- Assert.NotNull(dependency.Singleton2);
+ Assert.Multiple(() =>
+ {
+ Assert.That(dependency.Singleton1, Is.Not.Null);
+ Assert.That(dependency.Singleton2, Is.Not.Null);
- Assert.AreEqual(serviceProvider.GetService(typeof(ISingleton1)), singleton);
- Assert.AreEqual(serviceProvider.GetService(typeof(ISingleton2)), singleton);
+ Assert.That(singleton, Is.EqualTo(serviceProvider.GetService(typeof(ISingleton1))));
+ });
+ Assert.That(singleton, Is.EqualTo(serviceProvider.GetService(typeof(ISingleton2))));
}
[Test]
@@ -83,11 +86,11 @@ public void Given_lookupType_should_be_used_as_service_in_the_registration_when_
serviceCollection.AddSingleton(typeof(SomeClass), expected);
var serviceProvider = serviceCollection.BuildServiceProvider();
- Assert.AreEqual(expected, serviceProvider.GetService(typeof(SomeClass)));
+ Assert.That(serviceProvider.GetService(typeof(SomeClass)), Is.EqualTo(expected));
using (var scope = serviceProvider.CreateScope())
{
- Assert.AreEqual(expected, scope.ServiceProvider.GetService(typeof(SomeClass)));
+ Assert.That(scope.ServiceProvider.GetService(typeof(SomeClass)), Is.EqualTo(expected));
}
}
}
diff --git a/src/NServiceBus.ContainerTests/When_using_nested_containers.cs b/src/NServiceBus.ContainerTests/When_using_nested_containers.cs
index bbf22a1e1f6..9187ff3225f 100644
--- a/src/NServiceBus.ContainerTests/When_using_nested_containers.cs
+++ b/src/NServiceBus.ContainerTests/When_using_nested_containers.cs
@@ -17,7 +17,7 @@ public void Scoped__components_should_be_disposed_when_the_child_container_is_di
{
scope.ServiceProvider.GetService(typeof(ScopedComponent));
}
- Assert.True(ScopedComponent.DisposeCalled);
+ Assert.That(ScopedComponent.DisposeCalled, Is.True);
}
[Test]
@@ -32,7 +32,7 @@ public void Scoped_components_should_yield_different_instances_between_parent_an
{
var childInstance = scope.ServiceProvider.GetService(typeof(ScopedComponent));
- Assert.AreNotSame(parentInstance, childInstance);
+ Assert.That(childInstance, Is.Not.SameAs(parentInstance));
}
}
@@ -55,7 +55,7 @@ public void Scoped_components_should_yield_different_instances_between_different
instance2 = scope.ServiceProvider.GetService(typeof(ScopedComponent));
}
- Assert.AreNotSame(instance1, instance2);
+ Assert.That(instance2, Is.Not.SameAs(instance1));
}
[Test]
@@ -77,7 +77,7 @@ public void Transient_components_should_not_be_shared_across_child_containers()
instance2 = scope.ServiceProvider.GetService(typeof(TransientComponent));
}
- Assert.AreNotSame(instance1, instance2);
+ Assert.That(instance2, Is.Not.SameAs(instance1));
}
[Test]
@@ -92,7 +92,7 @@ public void Scoped_components_in_the_parent_container_should_be_singletons_in_th
var instance1 = scope.ServiceProvider.GetService(typeof(ScopedComponent));
var instance2 = scope.ServiceProvider.GetService(typeof(ScopedComponent));
- Assert.AreSame(instance1, instance2, "UoW's should be singleton in child container");
+ Assert.That(instance2, Is.SameAs(instance1), "UoW's should be singleton in child container");
}
}
@@ -109,7 +109,7 @@ public void Scoped_components_built_on_root_container_should_be_singletons_even_
}
var instance1 = serviceProvider.GetService(typeof(ScopedComponent));
var instance2 = serviceProvider.GetService(typeof(ScopedComponent));
- Assert.AreSame(instance1, instance2, "UoW's should be singletons in the root container");
+ Assert.That(instance2, Is.SameAs(instance1), "UoW's should be singletons in the root container");
}
[Test]
@@ -125,7 +125,7 @@ public void Should_not_dispose_singletons_when_container_goes_out_of_scope()
{
scope.ServiceProvider.GetService(typeof(ComponentThatDependsOfSingleton));
}
- Assert.False(SingletonComponent.DisposeCalled);
+ Assert.That(SingletonComponent.DisposeCalled, Is.False);
}
[Test]
@@ -143,8 +143,12 @@ public void Should_dispose_all_non_singleton_IDisposable_components_in_child_con
{
scope.ServiceProvider.GetService(typeof(DisposableComponent));
}
- Assert.False(AnotherDisposableComponent.DisposeCalled, "Dispose should not be called on AnotherSingletonComponent because it belongs to main container");
- Assert.True(DisposableComponent.DisposeCalled, "Dispose should be called on DisposableComponent");
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(AnotherDisposableComponent.DisposeCalled, Is.False, "Dispose should not be called on AnotherSingletonComponent because it belongs to main container");
+ Assert.That(DisposableComponent.DisposeCalled, Is.True, "Dispose should be called on DisposableComponent");
+ });
}
public interface IInstanceToReplaceInNested
diff --git a/src/NServiceBus.Core.Analyzer.Tests.Common/ForwardCancellationToken/ForwardFromPipelineTests.cs b/src/NServiceBus.Core.Analyzer.Tests.Common/ForwardCancellationToken/ForwardFromPipelineTests.cs
index 50e92ae07f8..f4fa6c13a98 100644
--- a/src/NServiceBus.Core.Analyzer.Tests.Common/ForwardCancellationToken/ForwardFromPipelineTests.cs
+++ b/src/NServiceBus.Core.Analyzer.Tests.Common/ForwardCancellationToken/ForwardFromPipelineTests.cs
@@ -46,20 +46,20 @@ public void EachTypeHasABasicTest()
var coveredTypes = pipelineTypes.Intersect(typesCoveredByThisTest).ToArray();
var missingTestCases = pipelineTypes.Except(typesCoveredByThisTest).ToArray();
- TestContext.WriteLine($"Types covered by a {nameof(RunTestOnType)} TestCase to ensure analyzer support:");
+ TestContext.Out.WriteLine($"Types covered by a {nameof(RunTestOnType)} TestCase to ensure analyzer support:");
foreach (var t in coveredTypes)
{
- TestContext.WriteLine(t.FullName);
+ TestContext.Out.WriteLine(t.FullName);
}
- TestContext.WriteLine();
- TestContext.WriteLine($"Types missing a {nameof(RunTestOnType)} TestCase:");
+ TestContext.Out.WriteLine();
+ TestContext.Out.WriteLine($"Types missing a {nameof(RunTestOnType)} TestCase:");
foreach (var t in missingTestCases)
{
- TestContext.WriteLine(t.FullName);
+ TestContext.Out.WriteLine(t.FullName);
}
- NUnit.Framework.Assert.AreEqual(0, missingTestCases.Length, $"One or more pipeline type(s) are not covered by the {nameof(RunTestOnType)} test in this class.");
+ NUnit.Framework.Assert.That(missingTestCases.Length, Is.EqualTo(0), $"One or more pipeline type(s) are not covered by the {nameof(RunTestOnType)} test in this class.");
}
[TestCase(typeof(IHandleMessages<>), "TestMessage", "Handle", "TestMessage message, IMessageHandlerContext context")]
diff --git a/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/AnalyzerTestFixture.cs b/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/AnalyzerTestFixture.cs
index 33759976be1..74e5e570cbb 100644
--- a/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/AnalyzerTestFixture.cs
+++ b/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/AnalyzerTestFixture.cs
@@ -14,6 +14,7 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using NServiceBus.UniformSession;
+using NUnit.Framework;
public class AnalyzerTestFixture where TAnalyzer : DiagnosticAnalyzer, new()
{
@@ -56,7 +57,7 @@ protected async Task Assert(string[] expectedDiagnosticIds, string markupCode, s
.Select(diagnostic => (diagnostic.Location.SourceTree.FilePath, diagnostic.Location.SourceSpan, diagnostic.Id))
.ToList();
- NUnit.Framework.CollectionAssert.AreEqual(expectedSpansAndIds, actualSpansAndIds);
+ NUnit.Framework.Assert.That(actualSpansAndIds, Is.EqualTo(expectedSpansAndIds).AsCollection);
}
protected static async Task WriteCode(Project project)
diff --git a/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/CodeFixTestFixture.cs b/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/CodeFixTestFixture.cs
index 6efcb94f6bc..3545cabd372 100644
--- a/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/CodeFixTestFixture.cs
+++ b/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/CodeFixTestFixture.cs
@@ -8,6 +8,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
+using NUnit.Framework;
public abstract class CodeFixTestFixture : AnalyzerTestFixture
where TAnalyzer : DiagnosticAnalyzer, new()
@@ -27,7 +28,7 @@ protected virtual async Task Assert(string original, string expected, bool fixMu
expectedCodeFiles[i] = expectedCodeFiles[i].Replace("\r\n", "\n");
}
- NUnit.Framework.Assert.AreEqual(expectedCodeFiles, actual);
+ NUnit.Framework.Assert.That(actual, Is.EqualTo(expectedCodeFiles));
}
async Task Fix(string[] codeFiles, bool fixMustCompile, CancellationToken cancellationToken, IEnumerable originalCompilerDiagnostics = null)
@@ -46,7 +47,7 @@ async Task Fix(string[] codeFiles, bool fixMustCompile, CancellationTo
}
else if (fixMustCompile)
{
- NUnit.Framework.CollectionAssert.AreEqual(originalCompilerDiagnostics, compilerDiagnostics, "Fix introduced new compiler diagnostics.");
+ NUnit.Framework.Assert.That(compilerDiagnostics, Is.EqualTo(originalCompilerDiagnostics).AsCollection, "Fix introduced new compiler diagnostics.");
}
var compilation = await project.GetCompilationAsync(cancellationToken);
diff --git a/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj b/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj
index 0d902c51447..e842260a9ae 100644
--- a/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj
+++ b/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj
@@ -16,7 +16,8 @@
-
+
+
diff --git a/src/NServiceBus.Core.Tests/API/Types.cs b/src/NServiceBus.Core.Tests/API/Types.cs
index ea38cadc225..d357c09fcab 100644
--- a/src/NServiceBus.Core.Tests/API/Types.cs
+++ b/src/NServiceBus.Core.Tests/API/Types.cs
@@ -20,6 +20,6 @@ public static void StaticTypesDoNotHaveInterfacePrefixes()
Console.Error.WriteViolators(violators);
- Assert.IsEmpty(violators);
+ Assert.That(violators, Is.Empty);
}
}
diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/AssemblyScanningComponentTests.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/AssemblyScanningComponentTests.cs
index d69dbafa55f..e6f4826fdcf 100644
--- a/src/NServiceBus.Core.Tests/AssemblyScanner/AssemblyScanningComponentTests.cs
+++ b/src/NServiceBus.Core.Tests/AssemblyScanner/AssemblyScanningComponentTests.cs
@@ -23,6 +23,6 @@ public void Should_initialize_scanner_with_custom_path_when_provided()
var foundTypeFromScannedPath = component.AvailableTypes.Any(x => x.Name == "NestedClass");
- Assert.True(foundTypeFromScannedPath, "Was expected to scan a custom path, but 'nested.dll' was not scanned.");
+ Assert.That(foundTypeFromScannedPath, Is.True, "Was expected to scan a custom path, but 'nested.dll' was not scanned.");
}
}
diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/When_configuring_assembly_scanning.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/When_configuring_assembly_scanning.cs
index ee041bc435d..2ced0d0b391 100644
--- a/src/NServiceBus.Core.Tests/AssemblyScanner/When_configuring_assembly_scanning.cs
+++ b/src/NServiceBus.Core.Tests/AssemblyScanner/When_configuring_assembly_scanning.cs
@@ -13,6 +13,6 @@ public void Should_provide_reflection_backdoor_via_endpoint_config()
// * docs - https://github.com/Particular/docs.particular.net/blob/master/Snippets/Core/Core_7/Headers/Writers/EndpointConfigurationExtensions.cs
// * metrics tests - https://github.com/Particular/NServiceBus.Metrics.PerformanceCounters/blob/master/src/NServiceBus.Metrics.PerformanceCounters.Tests/EndpointConfigurationExtensions.cs
// * we also have users relying on this to prevent assembly scanning from happening
- Assert.NotNull(typeof(EndpointConfiguration).GetMethod("TypesToScanInternal", BindingFlags.NonPublic | BindingFlags.Instance));
+ Assert.That(typeof(EndpointConfiguration).GetMethod("TypesToScanInternal", BindingFlags.NonPublic | BindingFlags.Instance), Is.Not.Null);
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/When_directory_with_messages_referencing_core_or_interfaces_is_scanned.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/When_directory_with_messages_referencing_core_or_interfaces_is_scanned.cs
index 1edc14cddca..a14c2c25ab3 100644
--- a/src/NServiceBus.Core.Tests/AssemblyScanner/When_directory_with_messages_referencing_core_or_interfaces_is_scanned.cs
+++ b/src/NServiceBus.Core.Tests/AssemblyScanner/When_directory_with_messages_referencing_core_or_interfaces_is_scanned.cs
@@ -19,7 +19,7 @@ public void Assemblies_should_be_scanned()
var result = scanner.GetScannableAssemblies();
var assemblyFullNames = result.Assemblies.Select(a => a.GetName().Name).ToList();
- CollectionAssert.Contains(assemblyFullNames, "Messages.Referencing.Core");
- CollectionAssert.Contains(assemblyFullNames, "Messages.Referencing.MessageInterfaces");
+ Assert.That(assemblyFullNames, Has.Member("Messages.Referencing.Core"));
+ Assert.That(assemblyFullNames, Has.Member("Messages.Referencing.MessageInterfaces"));
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/When_directory_with_no_reference_dlls_is_scanned.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/When_directory_with_no_reference_dlls_is_scanned.cs
index cb0e60491e4..748e9670d39 100644
--- a/src/NServiceBus.Core.Tests/AssemblyScanner/When_directory_with_no_reference_dlls_is_scanned.cs
+++ b/src/NServiceBus.Core.Tests/AssemblyScanner/When_directory_with_no_reference_dlls_is_scanned.cs
@@ -16,7 +16,7 @@ public void Assemblies_without_nsb_reference_are_skipped()
var result = scanner.GetScannableAssemblies();
- Assert.That(result.Assemblies.Contains(assemblyToScan), Is.False);
+ Assert.That(result.Assemblies, Does.Not.Contain(assemblyToScan));
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/When_scanning_assemblies_with_circular_dependencies.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/When_scanning_assemblies_with_circular_dependencies.cs
index 7d3cf55e2d2..ca19351a205 100644
--- a/src/NServiceBus.Core.Tests/AssemblyScanner/When_scanning_assemblies_with_circular_dependencies.cs
+++ b/src/NServiceBus.Core.Tests/AssemblyScanner/When_scanning_assemblies_with_circular_dependencies.cs
@@ -18,7 +18,10 @@ public void ReferencesNServiceBus_circular()
var result = scanner.GetScannableAssemblies();
- Assert.That(result.Assemblies.Any(a => a.FullName.Contains("ClassLibraryA")), Is.False);
- Assert.That(result.Assemblies.Any(a => a.FullName.Contains("ClassLibraryB")), Is.False);
+ Assert.Multiple(() =>
+ {
+ Assert.That(result.Assemblies.Any(a => a.FullName.Contains("ClassLibraryA")), Is.False);
+ Assert.That(result.Assemblies.Any(a => a.FullName.Contains("ClassLibraryB")), Is.False);
+ });
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/When_scanning_directory_with_nested_directories.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/When_scanning_directory_with_nested_directories.cs
index 9f1b15a2e09..14dace35a4b 100644
--- a/src/NServiceBus.Core.Tests/AssemblyScanner/When_scanning_directory_with_nested_directories.cs
+++ b/src/NServiceBus.Core.Tests/AssemblyScanner/When_scanning_directory_with_nested_directories.cs
@@ -21,8 +21,11 @@ public void Should_not_scan_nested_directories_by_default()
var foundTypeFromNestedAssembly = result.Types.Any(x => x.Name == "NestedClass");
var foundTypeFromDerivedAssembly = result.Types.Any(x => x.Name == "DerivedClass");
- Assert.False(foundTypeFromNestedAssembly, "Was expected not to scan nested assemblies, but 'nested.dll' was scanned.");
- Assert.False(foundTypeFromDerivedAssembly, "Was expected not to scan nested assemblies, but 'Derived.dll' was scanned.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(foundTypeFromNestedAssembly, Is.False, "Was expected not to scan nested assemblies, but 'nested.dll' was scanned.");
+ Assert.That(foundTypeFromDerivedAssembly, Is.False, "Was expected not to scan nested assemblies, but 'Derived.dll' was scanned.");
+ });
}
[Test]
@@ -39,7 +42,10 @@ public void Should_scan_nested_directories_if_requested()
var foundTypeFromNestedAssembly = result.Types.Any(x => x.Name == "NestedClass");
var foundTypeFromDerivedAssembly = result.Types.Any(x => x.Name == "DerivedClass");
- Assert.True(foundTypeFromNestedAssembly, "Was expected to scan nested assemblies, but 'nested.dll' was not scanned.");
- Assert.True(foundTypeFromDerivedAssembly, "Was expected to scan nested assemblies, but 'Derived.dll' was not scanned.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(foundTypeFromNestedAssembly, Is.True, "Was expected to scan nested assemblies, but 'nested.dll' was not scanned.");
+ Assert.That(foundTypeFromDerivedAssembly, Is.True, "Was expected to scan nested assemblies, but 'Derived.dll' was not scanned.");
+ });
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/When_using_type_forwarding.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/When_using_type_forwarding.cs
index 947c51bd1ac..5379f65d114 100644
--- a/src/NServiceBus.Core.Tests/AssemblyScanner/When_using_type_forwarding.cs
+++ b/src/NServiceBus.Core.Tests/AssemblyScanner/When_using_type_forwarding.cs
@@ -41,6 +41,6 @@ public void Should_scan_assemblies_indicated_by_the_forwarding_metadata()
var result = scanner.GetScannableAssemblies();
var assemblyFullNames = result.Assemblies.Select(a => a.GetName().Name).ToList();
- CollectionAssert.IsSubsetOf(assemblyNamesOfForwardedTypes, assemblyFullNames);
+ Assert.That(assemblyNamesOfForwardedTypes, Is.SubsetOf(assemblyFullNames));
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/When_validating_assemblies.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/When_validating_assemblies.cs
index 2b310f87169..9e7670c3e9d 100644
--- a/src/NServiceBus.Core.Tests/AssemblyScanner/When_validating_assemblies.cs
+++ b/src/NServiceBus.Core.Tests/AssemblyScanner/When_validating_assemblies.cs
@@ -16,8 +16,11 @@ public void Should_not_validate_system_assemblies()
{
AssemblyValidator.ValidateAssemblyFile(assembly.Location, out var shouldLoad, out var reason);
- Assert.IsFalse(shouldLoad, $"Should not validate {assembly.FullName}");
- Assert.That(reason == "File is a .NET runtime assembly.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(shouldLoad, Is.False, $"Should not validate {assembly.FullName}");
+ Assert.That(reason, Is.EqualTo("File is a .NET runtime assembly."));
+ });
}
}
@@ -26,8 +29,11 @@ public void Should_validate_NServiceBus_Core_assembly()
{
AssemblyValidator.ValidateAssemblyFile(typeof(EndpointConfiguration).Assembly.Location, out var shouldLoad, out var reason);
- Assert.IsTrue(shouldLoad);
- Assert.That(reason == "File is a .NET assembly.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(shouldLoad, Is.True);
+ Assert.That(reason, Is.EqualTo("File is a .NET assembly."));
+ });
}
[Test]
@@ -35,7 +41,10 @@ public void Should_validate_non_system_assemblies()
{
AssemblyValidator.ValidateAssemblyFile(GetType().Assembly.Location, out var shouldLoad, out var reason);
- Assert.IsTrue(shouldLoad);
- Assert.That(reason == "File is a .NET assembly.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(shouldLoad, Is.True);
+ Assert.That(reason, Is.EqualTo("File is a .NET assembly."));
+ });
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/Audit/AuditConfigReaderTests.cs b/src/NServiceBus.Core.Tests/Audit/AuditConfigReaderTests.cs
index 73b29db84dc..70b41f164d5 100644
--- a/src/NServiceBus.Core.Tests/Audit/AuditConfigReaderTests.cs
+++ b/src/NServiceBus.Core.Tests/Audit/AuditConfigReaderTests.cs
@@ -14,8 +14,11 @@ public void ShouldUseExplicitValueInSettingsIfPresent()
settingsHolder.Set(new AuditConfigReader.Result(configuredAddress, null));
- Assert.True(settingsHolder.TryGetAuditQueueAddress(out var address));
- Assert.AreEqual(configuredAddress, address);
+ Assert.Multiple(() =>
+ {
+ Assert.That(settingsHolder.TryGetAuditQueueAddress(out var address), Is.True);
+ Assert.That(address, Is.EqualTo(configuredAddress));
+ });
}
[Test]
@@ -26,13 +29,16 @@ public void ShouldReturnConfiguredExpiration()
settingsHolder.Set(new AuditConfigReader.Result("someAddress", configuredExpiration));
- Assert.True(settingsHolder.TryGetAuditMessageExpiration(out var expiration));
- Assert.AreEqual(configuredExpiration, expiration);
+ Assert.Multiple(() =>
+ {
+ Assert.That(settingsHolder.TryGetAuditMessageExpiration(out var expiration), Is.True);
+ Assert.That(expiration, Is.EqualTo(configuredExpiration));
+ });
}
[Test]
public void ShouldReturnFalseIfNoExpirationIsConfigured()
{
- Assert.False(new SettingsHolder().TryGetAuditMessageExpiration(out _));
+ Assert.That(new SettingsHolder().TryGetAuditMessageExpiration(out _), Is.False);
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/Causation/AttachCausationHeadersBehaviorTests.cs b/src/NServiceBus.Core.Tests/Causation/AttachCausationHeadersBehaviorTests.cs
index 439be9b70fc..63ba543e480 100644
--- a/src/NServiceBus.Core.Tests/Causation/AttachCausationHeadersBehaviorTests.cs
+++ b/src/NServiceBus.Core.Tests/Causation/AttachCausationHeadersBehaviorTests.cs
@@ -20,7 +20,7 @@ public async Task Should_generate_new_conversation_id_when_sending_outside_of_ha
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.AreEqual(generatedId, context.Headers[Headers.ConversationId]);
+ Assert.That(context.Headers[Headers.ConversationId], Is.EqualTo(generatedId));
}
[Test]
@@ -39,7 +39,7 @@ public async Task Should_set_the_conversation_id_to_conversation_id_of_incoming_
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.AreEqual(incomingConversationId, context.Headers[Headers.ConversationId]);
+ Assert.That(context.Headers[Headers.ConversationId], Is.EqualTo(incomingConversationId));
}
[Test]
@@ -58,7 +58,7 @@ public async Task When_no_incoming_message_should_not_override_a_conversation_id
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.AreEqual(userConversationId, context.Headers[Headers.ConversationId]);
+ Assert.That(context.Headers[Headers.ConversationId], Is.EqualTo(userConversationId));
}
[Test]
@@ -83,7 +83,7 @@ public void When_user_defined_conversation_id_would_overwrite_incoming_conversat
var exception = Assert.ThrowsAsync(() => behavior.Invoke(context, ctx => Task.CompletedTask));
- Assert.AreEqual($"Cannot set the {Headers.ConversationId} header to '{userDefinedConversationId}' as it cannot override the incoming header value ('{incomingConversationId}'). To start a new conversation use sendOptions.StartNewConversation().", exception.Message);
+ Assert.That(exception.Message, Is.EqualTo($"Cannot set the {Headers.ConversationId} header to '{userDefinedConversationId}' as it cannot override the incoming header value ('{incomingConversationId}'). To start a new conversation use sendOptions.StartNewConversation()."));
}
[Test]
@@ -96,7 +96,7 @@ public async Task Should_set_the_related_to_header_with_the_id_of_the_current_me
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.AreEqual("the message id", context.Headers[Headers.RelatedTo]);
+ Assert.That(context.Headers[Headers.RelatedTo], Is.EqualTo("the message id"));
}
string ReturnDefaultConversationId(IOutgoingLogicalMessageContext context)
diff --git a/src/NServiceBus.Core.Tests/Causation/CustomConversationIdStrategyTests.cs b/src/NServiceBus.Core.Tests/Causation/CustomConversationIdStrategyTests.cs
index a621b3a5022..a4c152842b1 100644
--- a/src/NServiceBus.Core.Tests/Causation/CustomConversationIdStrategyTests.cs
+++ b/src/NServiceBus.Core.Tests/Causation/CustomConversationIdStrategyTests.cs
@@ -26,13 +26,13 @@ public void Should_wrap_exceptions_for_better_debugging()
{
var ex = Assert.Throws(() => Invoke(_ => throw new Exception("User invocation failed")));
- StringAssert.Contains("Failed to execute the custom conversation ID strategy", ex.Message);
+ Assert.That(ex.Message, Does.Contain("Failed to execute the custom conversation ID strategy"));
}
[Test]
public void Should_default_to_combguid_id()
{
- Assert.True(Guid.TryParse(Invoke(_ => ConversationId.Default), out var _));
+ Assert.That(Guid.TryParse(Invoke(_ => ConversationId.Default), out var _), Is.True);
}
static string Invoke(Func strategy)
diff --git a/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs b/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs
index 61270a52950..0e7cca2b017 100644
--- a/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs
+++ b/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs
@@ -25,8 +25,11 @@ public async Task Last_one_wins()
await endpoint.Stop();
- Assert.That(transport1.Initialized, Is.False, "First transport should not be initialized");
- Assert.That(transport2.Initialized, Is.True, "Second transport should be initialized");
+ Assert.Multiple(() =>
+ {
+ Assert.That(transport1.Initialized, Is.False, "First transport should not be initialized");
+ Assert.That(transport2.Initialized, Is.True, "Second transport should be initialized");
+ });
}
class FakeTransportDefinition : TransportDefinition, IMessageDrivenSubscriptionTransport
diff --git a/src/NServiceBus.Core.Tests/Config/When_scanning_assemblies.cs b/src/NServiceBus.Core.Tests/Config/When_scanning_assemblies.cs
index b3748d81a85..9559979cd5b 100644
--- a/src/NServiceBus.Core.Tests/Config/When_scanning_assemblies.cs
+++ b/src/NServiceBus.Core.Tests/Config/When_scanning_assemblies.cs
@@ -22,22 +22,22 @@ public void SetUp()
[Ignore("Does not work")]
public void Should_for_our_code_exclude_everything_but_NServiceBus_by_default()
{
- CollectionAssert.AreEquivalent(System.Array.Empty(),
- foundAssemblies.Where(a => !a.FullName.StartsWith("NServiceBus") && !a.FullName.StartsWith("Obsolete")));
+ Assert.That(foundAssemblies.Where(a => !a.FullName.StartsWith("NServiceBus") && !a.FullName.StartsWith("Obsolete")),
+ Is.EquivalentTo(System.Array.Empty()));
}
[Test]
public void Should_exclude_system_assemblies()
{
- CollectionAssert.AreEquivalent(System.Array.Empty(),
- foundAssemblies.Where(a => a.FullName.StartsWith("System")).ToArray());
+ Assert.That(foundAssemblies.Where(a => a.FullName.StartsWith("System")).ToArray(),
+ Is.EquivalentTo(System.Array.Empty()));
}
[Test]
public void Should_exclude_nhibernate_assemblies()
{
- CollectionAssert.AreEquivalent(System.Array.Empty(),
- foundAssemblies.Where(a => a.FullName.StartsWith("nhibernate", System.StringComparison.OrdinalIgnoreCase)).ToArray());
+ Assert.That(foundAssemblies.Where(a => a.FullName.StartsWith("nhibernate", System.StringComparison.OrdinalIgnoreCase)).ToArray(),
+ Is.EquivalentTo(System.Array.Empty()));
}
static List GetAssembliesInDirectory(string path, params string[] assembliesToSkip)
diff --git a/src/NServiceBus.Core.Tests/Config/When_starting_endpoint_without_configuring_serializer.cs b/src/NServiceBus.Core.Tests/Config/When_starting_endpoint_without_configuring_serializer.cs
index 0b1c8110bcd..70c4c938d45 100644
--- a/src/NServiceBus.Core.Tests/Config/When_starting_endpoint_without_configuring_serializer.cs
+++ b/src/NServiceBus.Core.Tests/Config/When_starting_endpoint_without_configuring_serializer.cs
@@ -16,6 +16,6 @@ public void Should_throw()
scanner.ExcludeAssemblies("NServiceBus.Core.Tests.dll");
var exception = Assert.ThrowsAsync(async () => await Endpoint.Create(configuration).ConfigureAwait(false));
- Assert.True(exception.Message.StartsWith("A serializer has not been configured"));
+ Assert.That(exception.Message, Does.StartWith("A serializer has not been configured"));
}
}
diff --git a/src/NServiceBus.Core.Tests/Config/When_using_initialization.cs b/src/NServiceBus.Core.Tests/Config/When_using_initialization.cs
index 176887571b0..ef99dc3e9c2 100644
--- a/src/NServiceBus.Core.Tests/Config/When_using_initialization.cs
+++ b/src/NServiceBus.Core.Tests/Config/When_using_initialization.cs
@@ -16,7 +16,7 @@ public void Should_throw_meaningful_exception()
var ae = Assert.Throws(() => EndpointCreator.Create(endpointConfiguration, new ServiceCollection()));
var expected = $"Unable to create the type '{nameof(FeatureWithInitialization)}'. Types implementing '{nameof(INeedInitialization)}' must have a public parameterless (default) constructor.";
- Assert.AreEqual(expected, ae.Message);
+ Assert.That(ae.Message, Is.EqualTo(expected));
}
public class FeatureWithInitialization : INeedInitialization
diff --git a/src/NServiceBus.Core.Tests/ContextBagTests.cs b/src/NServiceBus.Core.Tests/ContextBagTests.cs
index f8c7bec3dd7..7ff010f501c 100644
--- a/src/NServiceBus.Core.Tests/ContextBagTests.cs
+++ b/src/NServiceBus.Core.Tests/ContextBagTests.cs
@@ -14,7 +14,7 @@ public void ShouldAllowMonkeyPatching()
contextBag.Set("MonkeyPatch", "some string");
((IReadOnlyContextBag)contextBag).TryGet("MonkeyPatch", out string theValue);
- Assert.AreEqual("some string", theValue);
+ Assert.That(theValue, Is.EqualTo("some string"));
}
[Test]
@@ -29,8 +29,11 @@ public void SetOnRoot_should_set_value_on_root_context()
context.SetOnRoot(key, 42);
- Assert.AreEqual(42, root.Get(key), "should store value on root context");
- Assert.AreEqual(42, context.Get(key), "stored value should be readable in the writing context");
- Assert.AreEqual(42, fork.Get(key), "stored value should be visible to a forked context");
+ Assert.Multiple(() =>
+ {
+ Assert.That(root.Get(key), Is.EqualTo(42), "should store value on root context");
+ Assert.That(context.Get(key), Is.EqualTo(42), "stored value should be readable in the writing context");
+ Assert.That(fork.Get(key), Is.EqualTo(42), "stored value should be visible to a forked context");
+ });
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/ConventionsTests.cs b/src/NServiceBus.Core.Tests/ConventionsTests.cs
index 368919a1aa7..920c8c24fee 100644
--- a/src/NServiceBus.Core.Tests/ConventionsTests.cs
+++ b/src/NServiceBus.Core.Tests/ConventionsTests.cs
@@ -10,7 +10,7 @@ public class ConventionsTests
public void IsMessageType_should_return_false_for_unknown_type()
{
var conventions = new Conventions();
- Assert.IsFalse(conventions.IsMessageType(typeof(NoAMessage)));
+ Assert.That(conventions.IsMessageType(typeof(NoAMessage)), Is.False);
}
public class NoAMessage
@@ -22,7 +22,7 @@ public class NoAMessage
public void IsMessageType_should_return_true_for_IMessage()
{
var conventions = new Conventions();
- Assert.IsTrue(conventions.IsMessageType(typeof(MyMessage)));
+ Assert.That(conventions.IsMessageType(typeof(MyMessage)), Is.True);
}
public class MyMessage : IMessage
@@ -34,7 +34,7 @@ public class MyMessage : IMessage
public void IsMessageType_should_return_true_for_ICommand()
{
var conventions = new Conventions();
- Assert.IsTrue(conventions.IsMessageType(typeof(MyCommand)));
+ Assert.That(conventions.IsMessageType(typeof(MyCommand)), Is.True);
}
public class MyCommand : ICommand
@@ -46,7 +46,7 @@ public class MyCommand : ICommand
public void IsMessageType_should_return_true_for_IEvent()
{
var conventions = new Conventions();
- Assert.IsTrue(conventions.IsMessageType(typeof(MyEvent)));
+ Assert.That(conventions.IsMessageType(typeof(MyEvent)), Is.True);
}
public class MyEvent : IEvent
@@ -59,7 +59,7 @@ public void IsMessageType_should_return_true_for_systemMessage()
{
var conventions = new Conventions();
conventions.AddSystemMessagesConventions(type => type == typeof(MySystemMessage));
- Assert.IsTrue(conventions.IsMessageType(typeof(MySystemMessage)));
+ Assert.That(conventions.IsMessageType(typeof(MySystemMessage)), Is.True);
}
public class MySystemMessage
@@ -75,7 +75,7 @@ public void IsCommandType_should_return_false_for_NServiceBus_types()
{
var conventions = new Conventions();
conventions.DefineCommandTypeConventions(t => t.Assembly == typeof(Conventions).Assembly);
- Assert.IsFalse(conventions.IsCommandType(typeof(Conventions)));
+ Assert.That(conventions.IsCommandType(typeof(Conventions)), Is.False);
}
[Test]
@@ -84,7 +84,7 @@ public void IsMessageType_should_return_false_for_NServiceBus_types()
var conventions = new Conventions();
conventions.DefineMessageTypeConvention(t => t.Assembly == typeof(Conventions).Assembly);
- Assert.IsFalse(conventions.IsMessageType(typeof(Conventions)));
+ Assert.That(conventions.IsMessageType(typeof(Conventions)), Is.False);
}
[Test]
@@ -92,7 +92,7 @@ public void IsEventType_should_return_false_for_NServiceBus_types()
{
var conventions = new Conventions();
conventions.DefineEventTypeConventions(t => t.Assembly == typeof(Conventions).Assembly);
- Assert.IsFalse(conventions.IsEventType(typeof(Conventions)));
+ Assert.That(conventions.IsEventType(typeof(Conventions)), Is.False);
}
public class MyConventionExpress
@@ -105,7 +105,7 @@ public void IsCommandType_should_return_true_for_matching_type()
var conventions = new Conventions();
conventions.DefineCommandTypeConventions(t => t.Assembly == typeof(Conventions).Assembly ||
t == typeof(MyConventionCommand));
- Assert.IsTrue(conventions.IsCommandType(typeof(MyConventionCommand)));
+ Assert.That(conventions.IsCommandType(typeof(MyConventionCommand)), Is.True);
}
public class MyConventionCommand
@@ -118,7 +118,7 @@ public void IsMessageType_should_return_true_for_matching_type()
var conventions = new Conventions();
conventions.DefineMessageTypeConvention(t => t.Assembly == typeof(Conventions).Assembly || t == typeof(MyConventionMessage));
- Assert.IsTrue(conventions.IsMessageType(typeof(MyConventionMessage)));
+ Assert.That(conventions.IsMessageType(typeof(MyConventionMessage)), Is.True);
}
public class MyConventionMessage
@@ -131,7 +131,7 @@ public void IsEventType_should_return_true_for_matching_type()
var conventions = new Conventions();
conventions.DefineEventTypeConventions(t => t.Assembly == typeof(Conventions).Assembly ||
t == typeof(MyConventionEvent));
- Assert.IsTrue(conventions.IsEventType(typeof(MyConventionEvent)));
+ Assert.That(conventions.IsEventType(typeof(MyConventionEvent)), Is.True);
}
public class MyConventionEvent
@@ -147,7 +147,7 @@ public void IsCommandType_should_return_true_for_matching_type()
{
var conventions = new Conventions();
conventions.Add(new MyConvention());
- Assert.IsTrue(conventions.IsCommandType(typeof(MyConventionCommand)));
+ Assert.That(conventions.IsCommandType(typeof(MyConventionCommand)), Is.True);
}
[Test]
@@ -155,7 +155,7 @@ public void IsEventType_should_return_true_for_matching_type()
{
var conventions = new Conventions();
conventions.Add(new MyConvention());
- Assert.IsTrue(conventions.IsEventType(typeof(MyConventionEvent)));
+ Assert.That(conventions.IsEventType(typeof(MyConventionEvent)), Is.True);
}
[Test]
@@ -163,7 +163,7 @@ public void IsMessageType_should_return_true_for_matching_type()
{
var conventions = new Conventions();
conventions.Add(new MyConvention());
- Assert.IsTrue(conventions.IsMessageType(typeof(MyConventionMessage)));
+ Assert.That(conventions.IsMessageType(typeof(MyConventionMessage)), Is.True);
}
[Test]
@@ -171,7 +171,7 @@ public void IsCommandType_should_return_true_for_default_convention()
{
var conventions = new Conventions();
conventions.Add(new MyConvention());
- Assert.IsTrue(conventions.IsCommandType(typeof(DefaultConventionCommand)));
+ Assert.That(conventions.IsCommandType(typeof(DefaultConventionCommand)), Is.True);
}
[Test]
@@ -179,7 +179,7 @@ public void IsEventType_should_return_true_for_default_convention()
{
var conventions = new Conventions();
conventions.Add(new MyConvention());
- Assert.IsTrue(conventions.IsEventType(typeof(DefaultConventionEvent)));
+ Assert.That(conventions.IsEventType(typeof(DefaultConventionEvent)), Is.True);
}
[Test]
@@ -187,7 +187,7 @@ public void IsMessageType_should_return_true_for_default_convention()
{
var conventions = new Conventions();
conventions.Add(new MyConvention());
- Assert.IsTrue(conventions.IsMessageType(typeof(DefaultConventionMessage)));
+ Assert.That(conventions.IsMessageType(typeof(DefaultConventionMessage)), Is.True);
}
class DefaultConventionCommand : ICommand { }
diff --git a/src/NServiceBus.Core.Tests/DataBus/DataBusConfigurationTests.cs b/src/NServiceBus.Core.Tests/DataBus/DataBusConfigurationTests.cs
index 8c3dd6c14ef..28897bf860a 100644
--- a/src/NServiceBus.Core.Tests/DataBus/DataBusConfigurationTests.cs
+++ b/src/NServiceBus.Core.Tests/DataBus/DataBusConfigurationTests.cs
@@ -20,7 +20,7 @@ public void Should_allow_multiple_deserializers_to_be_used()
.AddDeserializer(new FakeDataBusSerializer("content-type-1"))
.AddDeserializer(new FakeDataBusSerializer("content-type-2"));
- Assert.AreEqual(endpointConfiguration.Settings.Get>(NServiceBus.Features.DataBus.AdditionalDataBusDeserializersKey).Count, 2);
+ Assert.That(endpointConfiguration.Settings.Get>(NServiceBus.Features.DataBus.AdditionalDataBusDeserializersKey).Count, Is.EqualTo(2));
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/DataBus/DataBusDeserializerTests.cs b/src/NServiceBus.Core.Tests/DataBus/DataBusDeserializerTests.cs
index 72eaa1f62e8..7737440931b 100644
--- a/src/NServiceBus.Core.Tests/DataBus/DataBusDeserializerTests.cs
+++ b/src/NServiceBus.Core.Tests/DataBus/DataBusDeserializerTests.cs
@@ -23,7 +23,7 @@ public void Should_deserialized_with_the_serializer_used()
var deserializedProperty = deserializer.Deserialize(jsonSerializer.ContentType, typeof(string), stream);
- Assert.AreEqual(somePropertyValue, deserializedProperty);
+ Assert.That(deserializedProperty, Is.EqualTo(somePropertyValue));
}
}
@@ -41,7 +41,7 @@ public void Should_throw_if_serializer_used_not_available()
var ex = Assert.Throws(() => deserializer.Deserialize("other-serializer-not-configured", typeof(string), stream));
- StringAssert.Contains("other-serializer-not-configured", ex.Message);
+ Assert.That(ex.Message, Does.Contain("other-serializer-not-configured"));
}
}
@@ -54,7 +54,7 @@ public void Should_try_main_and_fallback_when_serializer_used_not_known()
var somePropertyValue = "test";
var deserializedProperty = deserializer.Deserialize(null, typeof(string), new MemoryStream());
- Assert.AreEqual(somePropertyValue, deserializedProperty);
+ Assert.That(deserializedProperty, Is.EqualTo(somePropertyValue));
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/DataBus/FileShare/AcceptanceTests.cs b/src/NServiceBus.Core.Tests/DataBus/FileShare/AcceptanceTests.cs
index e8694697eba..823926b9117 100644
--- a/src/NServiceBus.Core.Tests/DataBus/FileShare/AcceptanceTests.cs
+++ b/src/NServiceBus.Core.Tests/DataBus/FileShare/AcceptanceTests.cs
@@ -37,7 +37,7 @@ public async Task Should_handle_be_able_to_read_stored_values()
using (var stream = await dataBus.Get(key))
using (var streamReader = new StreamReader(stream))
{
- Assert.AreEqual(await streamReader.ReadToEndAsync(), content);
+ Assert.That(await streamReader.ReadToEndAsync(), Is.EqualTo(content));
}
}
@@ -53,7 +53,7 @@ public async Task Should_handle_be_able_to_read_stored_values_concurrently()
using (var stream = await dataBus.Get(key))
using (var streamReader = new StreamReader(stream))
{
- Assert.AreEqual(await streamReader.ReadToEndAsync(), content);
+ Assert.That(await streamReader.ReadToEndAsync(), Is.EqualTo(content));
}
});
}
@@ -68,7 +68,7 @@ public async Task Should_handle_be_able_to_read_stored_values_when_received_from
using (var stream = await dataBus.Get(key.Replace(Path.DirectorySeparatorChar, pathSeparator)))
using (var streamReader = new StreamReader(stream))
{
- Assert.AreEqual(await streamReader.ReadToEndAsync(), content);
+ Assert.That(await streamReader.ReadToEndAsync(), Is.EqualTo(content));
}
}
@@ -76,7 +76,7 @@ public async Task Should_handle_be_able_to_read_stored_values_when_received_from
public async Task Should_handle_max_ttl()
{
await Put("Test", TimeSpan.MaxValue);
- Assert.True(Directory.Exists(Path.Combine(basePath, DateTime.MaxValue.ToString("yyyy-MM-dd_HH"))));
+ Assert.That(Directory.Exists(Path.Combine(basePath, DateTime.MaxValue.ToString("yyyy-MM-dd_HH"))), Is.True);
}
[Test]
@@ -85,6 +85,6 @@ public async Task Should_honor_the_ttl_limit()
dataBus.MaxMessageTimeToLive = TimeSpan.FromDays(1);
await Put("Test", TimeSpan.MaxValue);
- Assert.True(Directory.Exists(Path.Combine(basePath, DateTime.UtcNow.AddDays(1).ToString("yyyy-MM-dd_HH"))));
+ Assert.That(Directory.Exists(Path.Combine(basePath, DateTime.UtcNow.AddDays(1).ToString("yyyy-MM-dd_HH"))), Is.True);
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/DataBus/When_applying_the_databus_message_mutator_to_outgoing_messages.cs b/src/NServiceBus.Core.Tests/DataBus/When_applying_the_databus_message_mutator_to_outgoing_messages.cs
index 6b63a3fbeae..e320b50b680 100644
--- a/src/NServiceBus.Core.Tests/DataBus/When_applying_the_databus_message_mutator_to_outgoing_messages.cs
+++ b/src/NServiceBus.Core.Tests/DataBus/When_applying_the_databus_message_mutator_to_outgoing_messages.cs
@@ -31,7 +31,7 @@ public async Task Outgoing_databus_properties_should_be_dehydrated()
await sendBehavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.AreEqual(TimeSpan.MaxValue, fakeDatabus.TTBRUsed);
+ Assert.That(fakeDatabus.TTBRUsed, Is.EqualTo(TimeSpan.MaxValue));
}
[Test]
@@ -52,7 +52,7 @@ public async Task Serializer_header_should_be_set()
await sendBehavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.AreEqual(serializer.ContentType, context.Headers[Headers.DataBusConfigContentType]);
+ Assert.That(context.Headers[Headers.DataBusConfigContentType], Is.EqualTo(serializer.ContentType));
}
[Test]
@@ -74,7 +74,7 @@ public async Task Time_to_live_should_be_passed_on_the_databus()
await sendBehavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.AreEqual(TimeSpan.FromMinutes(1), fakeDatabus.TTBRUsed);
+ Assert.That(fakeDatabus.TTBRUsed, Is.EqualTo(TimeSpan.FromMinutes(1)));
}
class FakeDataBus : IDataBus
diff --git a/src/NServiceBus.Core.Tests/DateTimeExtensionsTests.cs b/src/NServiceBus.Core.Tests/DateTimeExtensionsTests.cs
index d0a4fc862f7..00328ca0276 100644
--- a/src/NServiceBus.Core.Tests/DateTimeExtensionsTests.cs
+++ b/src/NServiceBus.Core.Tests/DateTimeExtensionsTests.cs
@@ -14,7 +14,7 @@ public void When_roundtripping_constructed_date_should_be_equal()
var dateString = DateTimeOffsetHelper.ToWireFormattedString(date);
var result = DateTimeOffsetHelper.ToDateTimeOffset(dateString);
- Assert.AreEqual(date, result);
+ Assert.That(result, Is.EqualTo(date));
}
[Test]
@@ -24,15 +24,18 @@ public void When_roundtripping_UtcNow_should_be_accurate_to_microseconds()
var dateString = DateTimeOffsetHelper.ToWireFormattedString(date);
var result = DateTimeOffsetHelper.ToDateTimeOffset(dateString);
- Assert.AreEqual(date.Year, result.Year);
- Assert.AreEqual(date.Month, result.Month);
- Assert.AreEqual(date.Day, result.Day);
- Assert.AreEqual(date.Hour, result.Hour);
- Assert.AreEqual(date.Minute, result.Minute);
- Assert.AreEqual(date.Second, result.Second);
- Assert.AreEqual(date.Millisecond, result.Millisecond);
- Assert.AreEqual(date.Microseconds(), result.Microseconds());
- Assert.AreEqual(date.Offset, result.Offset);
+ Assert.Multiple(() =>
+ {
+ Assert.That(result.Year, Is.EqualTo(date.Year));
+ Assert.That(result.Month, Is.EqualTo(date.Month));
+ Assert.That(result.Day, Is.EqualTo(date.Day));
+ Assert.That(result.Hour, Is.EqualTo(date.Hour));
+ Assert.That(result.Minute, Is.EqualTo(date.Minute));
+ Assert.That(result.Second, Is.EqualTo(date.Second));
+ Assert.That(result.Millisecond, Is.EqualTo(date.Millisecond));
+ Assert.That(result.Microseconds(), Is.EqualTo(date.Microseconds()));
+ Assert.That(result.Offset, Is.EqualTo(date.Offset));
+ });
}
[Test]
@@ -42,15 +45,18 @@ public void When_converting_string_should_be_accurate_to_microseconds()
var date = DateTimeOffset.ParseExact(dateString, "yyyy-MM-dd HH:mm:ss:ffffff Z", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
var result = DateTimeOffsetHelper.ToDateTimeOffset(dateString);
- Assert.AreEqual(date.Year, result.Year);
- Assert.AreEqual(date.Month, result.Month);
- Assert.AreEqual(date.Day, result.Day);
- Assert.AreEqual(date.Hour, result.Hour);
- Assert.AreEqual(date.Minute, result.Minute);
- Assert.AreEqual(date.Second, result.Second);
- Assert.AreEqual(date.Millisecond, result.Millisecond);
- Assert.AreEqual(date.Microseconds(), result.Microseconds());
- Assert.AreEqual(date.Offset, result.Offset);
+ Assert.Multiple(() =>
+ {
+ Assert.That(result.Year, Is.EqualTo(date.Year));
+ Assert.That(result.Month, Is.EqualTo(date.Month));
+ Assert.That(result.Day, Is.EqualTo(date.Day));
+ Assert.That(result.Hour, Is.EqualTo(date.Hour));
+ Assert.That(result.Minute, Is.EqualTo(date.Minute));
+ Assert.That(result.Second, Is.EqualTo(date.Second));
+ Assert.That(result.Millisecond, Is.EqualTo(date.Millisecond));
+ Assert.That(result.Microseconds(), Is.EqualTo(date.Microseconds()));
+ Assert.That(result.Offset, Is.EqualTo(date.Offset));
+ });
}
[Test]
@@ -59,7 +65,7 @@ public void When_converting_string_that_is_too_short_should_throw()
var dateString = "201-08-16 10:06:20:123456 Z";
var exception = Assert.Throws(() => DateTimeOffsetHelper.ToDateTimeOffset(dateString));
- Assert.AreEqual(exception.Message, "String was not recognized as a valid DateTime.");
+ Assert.That(exception.Message, Is.EqualTo("String was not recognized as a valid DateTime."));
}
[Test]
@@ -68,6 +74,6 @@ public void When_converting_string_with_invalid_characters_should_throw()
var dateString = "201j-08-16 10:06:20:123456 Z";
var exception = Assert.Throws(() => DateTimeOffsetHelper.ToDateTimeOffset(dateString));
- Assert.AreEqual(exception.Message, "String was not recognized as a valid DateTime.");
+ Assert.That(exception.Message, Is.EqualTo("String was not recognized as a valid DateTime."));
}
}
diff --git a/src/NServiceBus.Core.Tests/DelayedDelivery/DelayedDeliveryOptionExtensionsTests.cs b/src/NServiceBus.Core.Tests/DelayedDelivery/DelayedDeliveryOptionExtensionsTests.cs
index 6f418e60bc9..5aaad9d9b4d 100644
--- a/src/NServiceBus.Core.Tests/DelayedDelivery/DelayedDeliveryOptionExtensionsTests.cs
+++ b/src/NServiceBus.Core.Tests/DelayedDelivery/DelayedDeliveryOptionExtensionsTests.cs
@@ -13,7 +13,7 @@ public void GetDeliveryDelayShouldReturnTheConfiguredDelayTimeSpan()
var delay = TimeSpan.FromMinutes(42);
options.DelayDeliveryWith(delay);
- Assert.AreEqual(delay, options.GetDeliveryDelay());
+ Assert.That(options.GetDeliveryDelay(), Is.EqualTo(delay));
}
[Test]
@@ -21,7 +21,7 @@ public void GetDeliveryDelayShouldReturnNullWhenNoDelayConfigured()
{
var options = new SendOptions();
- Assert.IsNull(options.GetDeliveryDelay());
+ Assert.That(options.GetDeliveryDelay(), Is.Null);
}
[Test]
@@ -31,7 +31,7 @@ public void GetDeliveryDateShouldReturnTheConfiguredDeliveryDate()
var deliveryDate = new DateTimeOffset(2012, 12, 12, 12, 12, 12, TimeSpan.Zero);
options.DoNotDeliverBefore(deliveryDate);
- Assert.AreEqual(deliveryDate, options.GetDeliveryDate());
+ Assert.That(options.GetDeliveryDate(), Is.EqualTo(deliveryDate));
}
[Test]
@@ -39,7 +39,7 @@ public void GetDeliveryDateShouldReturnNullWhenNoDateConfigured()
{
var options = new SendOptions();
- Assert.IsNull(options.GetDeliveryDate());
+ Assert.That(options.GetDeliveryDate(), Is.Null);
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/Fakes/TestableMessageHandlerContextTests.cs b/src/NServiceBus.Core.Tests/Fakes/TestableMessageHandlerContextTests.cs
index bb5f15083c6..506d3930322 100644
--- a/src/NServiceBus.Core.Tests/Fakes/TestableMessageHandlerContextTests.cs
+++ b/src/NServiceBus.Core.Tests/Fakes/TestableMessageHandlerContextTests.cs
@@ -17,9 +17,12 @@ public async Task Send_ShouldContainMessageInSentMessages()
await context.Send(messageInstance, sendOptions);
- Assert.AreEqual(1, context.SentMessages.Length);
- Assert.AreSame(messageInstance, context.SentMessages[0].Message);
- Assert.AreSame(sendOptions, context.SentMessages[0].Options);
+ Assert.That(context.SentMessages, Has.Length.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.SentMessages[0].Message, Is.SameAs(messageInstance));
+ Assert.That(context.SentMessages[0].Options, Is.SameAs(sendOptions));
+ });
}
[Test]
@@ -29,7 +32,7 @@ public async Task Send_ShouldInvokeMessageInitializer()
await context.Send(m => m.Value = "initialized value");
- Assert.AreEqual("initialized value", context.SentMessages[0].Message().Value);
+ Assert.That(context.SentMessages[0].Message().Value, Is.EqualTo("initialized value"));
}
[Test]
@@ -41,9 +44,12 @@ public async Task Publish_ShouldContainMessageInPublishedMessages()
await context.Publish(messageInstance, publishOptions);
- Assert.AreEqual(1, context.PublishedMessages.Length);
- Assert.AreSame(messageInstance, context.PublishedMessages[0].Message);
- Assert.AreSame(publishOptions, context.PublishedMessages[0].Options);
+ Assert.That(context.PublishedMessages, Has.Length.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.PublishedMessages[0].Message, Is.SameAs(messageInstance));
+ Assert.That(context.PublishedMessages[0].Options, Is.SameAs(publishOptions));
+ });
}
[Test]
@@ -53,7 +59,7 @@ public async Task Publish_ShouldInvokeMessageInitializer()
await context.Publish(m => m.Value = "initialized value");
- Assert.AreEqual("initialized value", context.PublishedMessages[0].Message().Value);
+ Assert.That(context.PublishedMessages[0].Message().Value, Is.EqualTo("initialized value"));
}
[Test]
@@ -65,9 +71,12 @@ public async Task Reply_ShouldContainMessageInRepliedMessages()
await context.Reply(messageInstance, publishOptions);
- Assert.AreEqual(1, context.RepliedMessages.Length);
- Assert.AreSame(messageInstance, context.RepliedMessages[0].Message);
- Assert.AreSame(publishOptions, context.RepliedMessages[0].Options);
+ Assert.That(context.RepliedMessages, Has.Length.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.RepliedMessages[0].Message, Is.SameAs(messageInstance));
+ Assert.That(context.RepliedMessages[0].Options, Is.SameAs(publishOptions));
+ });
}
[Test]
@@ -77,7 +86,7 @@ public async Task Reply_ShouldInvokeMessageInitializer()
await context.Reply(m => m.Value = "initialized value");
- Assert.AreEqual("initialized value", context.RepliedMessages[0].Message().Value);
+ Assert.That(context.RepliedMessages[0].Message().Value, Is.EqualTo("initialized value"));
}
[Test]
@@ -88,8 +97,8 @@ public async Task ForwardCurrentMessageTo_ShouldContainDestinationsInForwardDest
await context.ForwardCurrentMessageTo("destination1");
await context.ForwardCurrentMessageTo("destination2");
- Assert.Contains("destination1", context.ForwardedMessages);
- Assert.Contains("destination2", context.ForwardedMessages);
+ Assert.That(context.ForwardedMessages, Does.Contain("destination1"));
+ Assert.That(context.ForwardedMessages, Does.Contain("destination2"));
}
[Test]
@@ -97,7 +106,7 @@ public void DoNotContinueDispatchingCurrentMessageToHandlers_WhenNotCalled_Shoul
{
var context = new TestableMessageHandlerContext();
- Assert.IsFalse(context.DoNotContinueDispatchingCurrentMessageToHandlersWasCalled);
+ Assert.That(context.DoNotContinueDispatchingCurrentMessageToHandlersWasCalled, Is.False);
}
[Test]
@@ -107,7 +116,7 @@ public void DoNotContinueDispatchingCurrentMessageToHandlers_WhenCalled_ShouldIn
context.DoNotContinueDispatchingCurrentMessageToHandlers();
- Assert.IsTrue(context.DoNotContinueDispatchingCurrentMessageToHandlersWasCalled);
+ Assert.That(context.DoNotContinueDispatchingCurrentMessageToHandlersWasCalled, Is.True);
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/Fakes/TestableMessageSessionTests.cs b/src/NServiceBus.Core.Tests/Fakes/TestableMessageSessionTests.cs
index 9444848349d..f32109295df 100644
--- a/src/NServiceBus.Core.Tests/Fakes/TestableMessageSessionTests.cs
+++ b/src/NServiceBus.Core.Tests/Fakes/TestableMessageSessionTests.cs
@@ -14,9 +14,12 @@ public async System.Threading.Tasks.Task Subscribe_ShouldTrackSubscriptionsAsync
await session.Subscribe(typeof(MyEvent), options);
- Assert.AreEqual(1, session.Subscriptions.Length);
- Assert.AreSame(options, session.Subscriptions[0].Options);
- Assert.AreEqual(typeof(MyEvent), session.Subscriptions[0].Message);
+ Assert.That(session.Subscriptions, Has.Length.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(session.Subscriptions[0].Options, Is.SameAs(options));
+ Assert.That(session.Subscriptions[0].Message, Is.EqualTo(typeof(MyEvent)));
+ });
}
[Test]
@@ -27,9 +30,12 @@ public async System.Threading.Tasks.Task Unsubscribe_ShouldTrackUnsubscriptionsA
await session.Unsubscribe(typeof(MyEvent), options);
- Assert.AreEqual(1, session.Unsubscription.Length);
- Assert.AreSame(options, session.Unsubscription[0].Options);
- Assert.AreEqual(typeof(MyEvent), session.Unsubscription[0].Message);
+ Assert.That(session.Unsubscription, Has.Length.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(session.Unsubscription[0].Options, Is.SameAs(options));
+ Assert.That(session.Unsubscription[0].Message, Is.EqualTo(typeof(MyEvent)));
+ });
}
class MyEvent
diff --git a/src/NServiceBus.Core.Tests/Features/FeatureDefaultsTests.cs b/src/NServiceBus.Core.Tests/Features/FeatureDefaultsTests.cs
index defd30752aa..850b35477c2 100644
--- a/src/NServiceBus.Core.Tests/Features/FeatureDefaultsTests.cs
+++ b/src/NServiceBus.Core.Tests/Features/FeatureDefaultsTests.cs
@@ -56,7 +56,7 @@ public void Feature_enabled_by_later_feature_should_have_default_called()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(featureThatIsEnabledByAnother.DefaultCalled, "FeatureThatIsEnabledByAnother wasn't activated");
+ Assert.That(featureThatIsEnabledByAnother.DefaultCalled, Is.True, "FeatureThatIsEnabledByAnother wasn't activated");
}
[Test]
@@ -88,15 +88,18 @@ public void Should_enable_features_in_defaults()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(level1.IsActive, "Activate1 wasn't activated");
- Assert.True(level2.IsActive, "Activate2 wasn't activated");
- Assert.True(level3.IsActive, "Activate3 wasn't activated");
+ Assert.Multiple(() =>
+ {
+ Assert.That(level1.IsActive, Is.True, "Activate1 wasn't activated");
+ Assert.That(level2.IsActive, Is.True, "Activate2 wasn't activated");
+ Assert.That(level3.IsActive, Is.True, "Activate3 wasn't activated");
- Assert.IsInstanceOf(defaultsOrder[0], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(defaultsOrder[1], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(defaultsOrder[2], "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder[0], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder[1], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder[2], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
- CollectionAssert.AreEqual(defaultsOrder, activatedOrder);
+ Assert.That(activatedOrder, Is.EqualTo(defaultsOrder).AsCollection);
}
[Test]
@@ -120,9 +123,12 @@ public void Should_activate_upstream_dependencies_first()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(dependingFeature.IsActive);
+ Assert.Multiple(() =>
+ {
+ Assert.That(dependingFeature.IsActive, Is.True);
- Assert.IsInstanceOf(defaultsOrder.First(), "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder.First(), Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
}
[Test]
@@ -158,11 +164,14 @@ public void Should_activate_all_upstream_dependencies_first()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(dependingFeature.IsActive);
+ Assert.Multiple(() =>
+ {
+ Assert.That(dependingFeature.IsActive, Is.True);
- Assert.IsInstanceOf(defaultsOrder[0], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(defaultsOrder[1], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(defaultsOrder[2], "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder[0], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder[1], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder[2], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
}
[Test]
@@ -190,13 +199,16 @@ public void Should_activate_all_upstream_dependencies_when_chain_deep()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(level1.IsActive, "Level1 wasn't activated");
- Assert.True(level2.IsActive, "Level2 wasn't activated");
- Assert.True(level3.IsActive, "Level3 wasn't activated");
-
- Assert.IsInstanceOf(defaultsOrder[0], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(defaultsOrder[1], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(defaultsOrder[2], "Upstream dependencies should be activated first");
+ Assert.Multiple(() =>
+ {
+ Assert.That(level1.IsActive, Is.True, "Level1 wasn't activated");
+ Assert.That(level2.IsActive, Is.True, "Level2 wasn't activated");
+ Assert.That(level3.IsActive, Is.True, "Level3 wasn't activated");
+
+ Assert.That(defaultsOrder[0], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder[1], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(defaultsOrder[2], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
}
public class Level1 : TestFeature
diff --git a/src/NServiceBus.Core.Tests/Features/FeatureDependencyTests.cs b/src/NServiceBus.Core.Tests/Features/FeatureDependencyTests.cs
index cae11800731..0be0e0ec40a 100644
--- a/src/NServiceBus.Core.Tests/Features/FeatureDependencyTests.cs
+++ b/src/NServiceBus.Core.Tests/Features/FeatureDependencyTests.cs
@@ -61,7 +61,7 @@ public void Should_only_activate_features_if_dependencies_are_met(FeatureCombina
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.AreEqual(setup.ShouldBeActive, dependingFeature.IsActive);
+ Assert.That(dependingFeature.IsActive, Is.EqualTo(setup.ShouldBeActive));
}
[Test]
@@ -88,9 +88,12 @@ public void Should_activate_upstream_dependencies_first()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(dependingFeature.IsActive);
+ Assert.Multiple(() =>
+ {
+ Assert.That(dependingFeature.IsActive, Is.True);
- Assert.IsInstanceOf(order.First(), "Upstream dependencies should be activated first");
+ Assert.That(order.First(), Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
}
[Test]
@@ -117,8 +120,11 @@ public void Should_activate_named_dependency_first()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(dependingFeature.IsActive);
- Assert.IsInstanceOf(order.First(), "Upstream dependencies should be activated first");
+ Assert.Multiple(() =>
+ {
+ Assert.That(dependingFeature.IsActive, Is.True);
+ Assert.That(order.First(), Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
}
[Test]
@@ -143,8 +149,11 @@ public void Should_not_activate_feature_when_named_dependency_disabled()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.False(dependingFeature.IsActive);
- Assert.IsEmpty(order);
+ Assert.Multiple(() =>
+ {
+ Assert.That(dependingFeature.IsActive, Is.False);
+ Assert.That(order, Is.Empty);
+ });
}
[Test]
@@ -183,11 +192,14 @@ public void Should_activate_all_upstream_dependencies_first()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(dependingFeature.IsActive);
+ Assert.Multiple(() =>
+ {
+ Assert.That(dependingFeature.IsActive, Is.True);
- Assert.IsInstanceOf(order[0], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(order[1], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(order[2], "Upstream dependencies should be activated first");
+ Assert.That(order[0], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(order[1], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(order[2], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
}
[Test]
@@ -219,14 +231,16 @@ public void Should_activate_all_upstream_dependencies_when_chain_deep()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
-
- Assert.True(level1.IsActive, "Level1 wasn't activated");
- Assert.True(level2.IsActive, "Level2 wasn't activated");
- Assert.True(level3.IsActive, "Level3 wasn't activated");
-
- Assert.IsInstanceOf(order[0], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(order[1], "Upstream dependencies should be activated first");
- Assert.IsInstanceOf(order[2], "Upstream dependencies should be activated first");
+ Assert.Multiple(() =>
+ {
+ Assert.That(level1.IsActive, Is.True, "Level1 wasn't activated");
+ Assert.That(level2.IsActive, Is.True, "Level2 wasn't activated");
+ Assert.That(level3.IsActive, Is.True, "Level3 wasn't activated");
+
+ Assert.That(order[0], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(order[1], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ Assert.That(order[2], Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/Features/FeatureDifferingOnlyByNamespaceTests.cs b/src/NServiceBus.Core.Tests/Features/FeatureDifferingOnlyByNamespaceTests.cs
index 3f30f5f4412..812e074e272 100644
--- a/src/NServiceBus.Core.Tests/Features/FeatureDifferingOnlyByNamespaceTests.cs
+++ b/src/NServiceBus.Core.Tests/Features/FeatureDifferingOnlyByNamespaceTests.cs
@@ -33,9 +33,12 @@ public void Should_activate_upstream_dependencies_first()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(dependingFeature.IsActive);
+ Assert.Multiple(() =>
+ {
+ Assert.That(dependingFeature.IsActive, Is.True);
- Assert.IsInstanceOf(order.First(), "Upstream dependencies should be activated first");
+ Assert.That(order.First(), Is.InstanceOf(), "Upstream dependencies should be activated first");
+ });
}
}
}
diff --git a/src/NServiceBus.Core.Tests/Features/FeatureSettingsTests.cs b/src/NServiceBus.Core.Tests/Features/FeatureSettingsTests.cs
index 6836a8f87e6..d723f504fa5 100644
--- a/src/NServiceBus.Core.Tests/Features/FeatureSettingsTests.cs
+++ b/src/NServiceBus.Core.Tests/Features/FeatureSettingsTests.cs
@@ -30,10 +30,13 @@ public void Should_check_prerequisites()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(featureWithTrueCondition.IsActive);
- Assert.False(featureWithFalseCondition.IsActive);
- Assert.AreEqual("The description",
- featureSettings.Status.Single(s => s.Name == featureWithFalseCondition.Name).PrerequisiteStatus.Reasons.First());
+ Assert.Multiple(() =>
+ {
+ Assert.That(featureWithTrueCondition.IsActive, Is.True);
+ Assert.That(featureWithFalseCondition.IsActive, Is.False);
+ Assert.That(featureSettings.Status.Single(s => s.Name == featureWithFalseCondition.Name).PrerequisiteStatus.Reasons.First(),
+ Is.EqualTo("The description"));
+ });
}
[Test]
@@ -43,7 +46,7 @@ public void Should_register_defaults_if_feature_is_activated()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.True(settings.HasSetting("Test1"));
+ Assert.That(settings.HasSetting("Test1"), Is.True);
}
[Test]
@@ -55,8 +58,11 @@ public void Should_not_register_defaults_if_feature_is_not_activated()
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
- Assert.False(settings.HasSetting("Test1"));
- Assert.False(settings.HasSetting("Test2"));
+ Assert.Multiple(() =>
+ {
+ Assert.That(settings.HasSetting("Test1"), Is.False);
+ Assert.That(settings.HasSetting("Test2"), Is.False);
+ });
}
diff --git a/src/NServiceBus.Core.Tests/Features/FeatureStartupTests.cs b/src/NServiceBus.Core.Tests/Features/FeatureStartupTests.cs
index 531582463aa..70b33a09df7 100644
--- a/src/NServiceBus.Core.Tests/Features/FeatureStartupTests.cs
+++ b/src/NServiceBus.Core.Tests/Features/FeatureStartupTests.cs
@@ -30,8 +30,11 @@ public async Task Should_start_and_stop_features()
await featureSettings.StartFeatures(null, null);
await featureSettings.StopFeatures();
- Assert.True(feature.TaskStarted);
- Assert.True(feature.TaskStopped);
+ Assert.Multiple(() =>
+ {
+ Assert.That(feature.TaskStarted, Is.True);
+ Assert.That(feature.TaskStopped, Is.True);
+ });
}
[Test]
@@ -53,7 +56,7 @@ public async Task Should_start_and_stop_features_in_dependency_order()
expectedOrderBuilder.AppendLine("FeatureWithStartupThatAnotherFeatureDependsOn.Stop");
expectedOrderBuilder.AppendLine("FeatureWithStartupTaskWithDependency.Stop");
- Assert.AreEqual(expectedOrderBuilder.ToString(), orderBuilder.ToString());
+ Assert.That(orderBuilder.ToString(), Is.EqualTo(expectedOrderBuilder.ToString()));
}
[Test]
@@ -68,7 +71,7 @@ public async Task Should_dispose_feature_startup_tasks_when_they_implement_IDisp
await featureSettings.StartFeatures(null, null);
await featureSettings.StopFeatures();
- Assert.True(feature.TaskDisposed);
+ Assert.That(feature.TaskDisposed, Is.True);
}
[Test]
@@ -85,13 +88,16 @@ public void Should_throw_when_feature_task_fails_on_start_and_should_stop_previo
featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());
var exception = Assert.ThrowsAsync(async () => await featureSettings.StartFeatures(null, null));
- Assert.AreEqual("feature2", exception.Message);
-
- Assert.True(feature1.TaskStarted, "Feature 1 should have been started.");
- Assert.True(feature2.TaskStartCalled, "An attempt should have been made to start feature 2.");
- Assert.True(feature1.TaskStopCalled, "An attempt should have been made to stop feature 1.");
- Assert.False(feature2.TaskStopCalled, "No attempt should have been made to stop feature 2.");
- Assert.False(feature3.TaskStartCalled, "No attempt should have been made to start feature 3.");
+ Assert.Multiple(() =>
+ {
+ Assert.That(exception.Message, Is.EqualTo("feature2"));
+
+ Assert.That(feature1.TaskStarted, Is.True, "Feature 1 should have been started.");
+ Assert.That(feature2.TaskStartCalled, Is.True, "An attempt should have been made to start feature 2.");
+ Assert.That(feature1.TaskStopCalled, Is.True, "An attempt should have been made to stop feature 1.");
+ Assert.That(feature2.TaskStopCalled, Is.False, "No attempt should have been made to stop feature 2.");
+ Assert.That(feature3.TaskStartCalled, Is.False, "No attempt should have been made to start feature 3.");
+ });
}
[Test]
@@ -109,8 +115,11 @@ public async Task Should_not_throw_when_feature_task_fails_on_stop_and_should_no
Assert.DoesNotThrowAsync(async () => await featureSettings.StopFeatures());
- Assert.True(feature1.TaskStarted && feature1.TaskStopped);
- Assert.True(feature2.TaskStarted && !feature2.TaskStopped);
+ Assert.Multiple(() =>
+ {
+ Assert.That(feature1.TaskStarted && feature1.TaskStopped, Is.True);
+ Assert.That(feature2.TaskStarted && !feature2.TaskStopped, Is.True);
+ });
}
[Test]
@@ -124,7 +133,7 @@ public async Task Should_dispose_feature_task_even_when_stop_throws()
await featureSettings.StartFeatures(null, null);
await featureSettings.StopFeatures();
- Assert.True(feature.TaskDisposed);
+ Assert.That(feature.TaskDisposed, Is.True);
}
FeatureActivator featureSettings;
diff --git a/src/NServiceBus.Core.Tests/Features/FeatureTests.cs b/src/NServiceBus.Core.Tests/Features/FeatureTests.cs
index 4e4df830420..0892508f2ca 100644
--- a/src/NServiceBus.Core.Tests/Features/FeatureTests.cs
+++ b/src/NServiceBus.Core.Tests/Features/FeatureTests.cs
@@ -10,7 +10,7 @@ public void Should_be_disabled_be_default()
{
var feature = new MyFeature();
- Assert.False(feature.IsEnabledByDefault);
+ Assert.That(feature.IsEnabledByDefault, Is.False);
}
[Test]
@@ -18,7 +18,7 @@ public void Should_be_allow_features_to_request_being_enabled_by_default()
{
var feature = new MyEnabledByDefaultFeature();
- Assert.True(feature.IsEnabledByDefault);
+ Assert.That(feature.IsEnabledByDefault, Is.True);
}
diff --git a/src/NServiceBus.Core.Tests/Handlers/MessageHandlerRegistryTests.cs b/src/NServiceBus.Core.Tests/Handlers/MessageHandlerRegistryTests.cs
index 38746d0a719..0985c1ff09f 100644
--- a/src/NServiceBus.Core.Tests/Handlers/MessageHandlerRegistryTests.cs
+++ b/src/NServiceBus.Core.Tests/Handlers/MessageHandlerRegistryTests.cs
@@ -32,31 +32,37 @@ public async Task ShouldIndicateWhetherAHandlerIsATimeoutHandler()
var handlers = registry.GetHandlersFor(typeof(MyMessage));
- Assert.AreEqual(2, handlers.Count);
+ Assert.That(handlers.Count, Is.EqualTo(2));
var timeoutHandler = handlers.SingleOrDefault(h => h.IsTimeoutHandler);
- Assert.NotNull(timeoutHandler, "Timeout handler should be marked as such");
+ Assert.That(timeoutHandler, Is.Not.Null, "Timeout handler should be marked as such");
var timeoutInstance = new SagaWithTimeoutOfMessage();
timeoutHandler.Instance = timeoutInstance;
await timeoutHandler.Invoke(new MyMessage(), new TestableInvokeHandlerContext());
- Assert.True(timeoutInstance.TimeoutCalled);
- Assert.False(timeoutInstance.HandlerCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(timeoutInstance.TimeoutCalled, Is.True);
+ Assert.That(timeoutInstance.HandlerCalled, Is.False);
+ });
var regularHandler = handlers.SingleOrDefault(h => !h.IsTimeoutHandler);
- Assert.NotNull(regularHandler, "Regular handler should be marked as timeout handler");
+ Assert.That(regularHandler, Is.Not.Null, "Regular handler should be marked as timeout handler");
var regularInstance = new SagaWithTimeoutOfMessage();
regularHandler.Instance = regularInstance;
await regularHandler.Invoke(new MyMessage(), new TestableInvokeHandlerContext());
- Assert.False(regularInstance.TimeoutCalled);
- Assert.True(regularInstance.HandlerCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(regularInstance.TimeoutCalled, Is.False);
+ Assert.That(regularInstance.HandlerCalled, Is.True);
+ });
}
class HandlerWithIMessageSessionProperty : IHandleMessages
diff --git a/src/NServiceBus.Core.Tests/Hosting/HostInfoSettingsTests.cs b/src/NServiceBus.Core.Tests/Hosting/HostInfoSettingsTests.cs
index c7d86a38e48..3b6e9a31ed4 100644
--- a/src/NServiceBus.Core.Tests/Hosting/HostInfoSettingsTests.cs
+++ b/src/NServiceBus.Core.Tests/Hosting/HostInfoSettingsTests.cs
@@ -16,7 +16,7 @@ public void It_overrides_the_host_id()
busConfig.UniquelyIdentifyRunningInstance().UsingCustomIdentifier(requestedId);
var configuredId = busConfig.Settings.Get().HostId;
- Assert.AreEqual(requestedId, configuredId);
+ Assert.That(configuredId, Is.EqualTo(requestedId));
}
[Test]
@@ -27,7 +27,7 @@ public void It_allows_to_generate_a_deterministic_id_using_instance_and_host_nam
busConfig.UniquelyIdentifyRunningInstance().UsingNames("Instance", "Host");
var configuredId = busConfig.Settings.Get().HostId;
- Assert.AreEqual(DeterministicGuid.Create("Instance", "Host"), configuredId);
+ Assert.That(configuredId, Is.EqualTo(DeterministicGuid.Create("Instance", "Host")));
}
[Test]
@@ -38,6 +38,6 @@ public void It_overrides_the_machine_name()
busConfig.UniquelyIdentifyRunningInstance().UsingHostName("overridenhostname");
var hostName = RuntimeEnvironment.MachineName;
- Assert.AreEqual("overridenhostname", hostName);
+ Assert.That(hostName, Is.EqualTo("overridenhostname"));
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/Hosting/HostTests.cs b/src/NServiceBus.Core.Tests/Hosting/HostTests.cs
index 4618a63006c..05e591cd6f4 100644
--- a/src/NServiceBus.Core.Tests/Hosting/HostTests.cs
+++ b/src/NServiceBus.Core.Tests/Hosting/HostTests.cs
@@ -12,6 +12,6 @@ public void When_not_running_ASP_NET_should_choose_BaseDirectory_as_output_direc
{
var directory = Host.GetOutputDirectory();
- Assert.AreEqual(AppDomain.CurrentDomain.BaseDirectory, directory);
+ Assert.That(directory, Is.EqualTo(AppDomain.CurrentDomain.BaseDirectory));
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/Hosting/PathUtilities_Tests.cs b/src/NServiceBus.Core.Tests/Hosting/PathUtilities_Tests.cs
index 1e5359aa4a9..a10a46ea45e 100644
--- a/src/NServiceBus.Core.Tests/Hosting/PathUtilities_Tests.cs
+++ b/src/NServiceBus.Core.Tests/Hosting/PathUtilities_Tests.cs
@@ -10,7 +10,7 @@ public void Parse_from_path_without_spaces_but_with_quotes()
{
var path = PathUtilities.SanitizedPath("\"pathto\\my.exe\" somevar");
- Assert.AreEqual("pathto\\my.exe", path);
+ Assert.That(path, Is.EqualTo("pathto\\my.exe"));
}
[Test]
@@ -18,7 +18,7 @@ public void Parse_from_path_without_spaces_but_without_quotes()
{
var path = PathUtilities.SanitizedPath("pathto\\my.exe somevar");
- Assert.AreEqual("pathto\\my.exe", path);
+ Assert.That(path, Is.EqualTo("pathto\\my.exe"));
}
[Test]
@@ -27,7 +27,7 @@ public void Paths_without_spaces_are_equal()
var path1 = PathUtilities.SanitizedPath("\"pathto\\my.exe\" somevar");
var path2 = PathUtilities.SanitizedPath("pathto\\my.exe somevar");
- Assert.AreEqual(path1, path2);
+ Assert.That(path2, Is.EqualTo(path1));
}
[Test]
@@ -35,7 +35,7 @@ public void Parse_from_path_with_spaces_having_a_parameter_with_spaces()
{
var path = PathUtilities.SanitizedPath("\"pathto\\mysuper duper.exe\" \"somevar with spaces\"");
- Assert.AreEqual("pathto\\mysuper duper.exe", path);
+ Assert.That(path, Is.EqualTo("pathto\\mysuper duper.exe"));
}
[Test]
@@ -43,7 +43,7 @@ public void Parse_from_path_with_spaces_having_a_parameter_without_spaces()
{
var path = PathUtilities.SanitizedPath("\"pathto\\mysuper duper.exe\" somevar");
- Assert.AreEqual("pathto\\mysuper duper.exe", path);
+ Assert.That(path, Is.EqualTo("pathto\\mysuper duper.exe"));
}
[Test]
@@ -52,6 +52,6 @@ public void Both_paths_with_spaces_are_equal()
var path1 = PathUtilities.SanitizedPath("\"pathto\\mysuper duper.exe\" \"somevar with spaces\"");
var path2 = PathUtilities.SanitizedPath("\"pathto\\mysuper duper.exe\" somevar");
- Assert.AreEqual(path1, path2);
+ Assert.That(path2, Is.EqualTo(path1));
}
}
diff --git a/src/NServiceBus.Core.Tests/IdGeneration/IdGenerationTests.cs b/src/NServiceBus.Core.Tests/IdGeneration/IdGenerationTests.cs
index 240ba57b626..ec795e213b4 100644
--- a/src/NServiceBus.Core.Tests/IdGeneration/IdGenerationTests.cs
+++ b/src/NServiceBus.Core.Tests/IdGeneration/IdGenerationTests.cs
@@ -13,7 +13,7 @@ public void Should_return_same_result_for_same_input(Guid guid, DateTime now)
var oldCombGuid = LocalCopyOfCombGuid.GenerateOld(guid, now);
var improvedCombGuid = CombGuid.Generate(guid, now);
- Assert.AreEqual(oldCombGuid, improvedCombGuid);
+ Assert.That(improvedCombGuid, Is.EqualTo(oldCombGuid));
}
static readonly Random Random = new Random();
diff --git a/src/NServiceBus.Core.Tests/Licensing/LicenseManagerTests.cs b/src/NServiceBus.Core.Tests/Licensing/LicenseManagerTests.cs
index c9c91e70697..4226d8931e9 100644
--- a/src/NServiceBus.Core.Tests/Licensing/LicenseManagerTests.cs
+++ b/src/NServiceBus.Core.Tests/Licensing/LicenseManagerTests.cs
@@ -16,7 +16,7 @@ public void ShouldLogNoStatusMessageWhenLicenseIsValid()
LicenseManager.LogLicenseStatus(LicenseStatus.Valid, logger, new License(), "fake-url");
- Assert.AreEqual(0, logger.Logs.Count);
+ Assert.That(logger.Logs.Count, Is.EqualTo(0));
}
[Test]
@@ -26,9 +26,12 @@ public void WhenSubscriptionLicenseExpired()
LicenseManager.LogLicenseStatus(LicenseStatus.InvalidDueToExpiredSubscription, logger, new License(), "fake-url");
- Assert.AreEqual(1, logger.Logs.Count);
- Assert.AreEqual(LogLevel.Error, logger.Logs[0].level);
- Assert.AreEqual("License expired. Contact us to renew your license: contact@particular.net", logger.Logs[0].message);
+ Assert.That(logger.Logs.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(logger.Logs[0].level, Is.EqualTo(LogLevel.Error));
+ Assert.That(logger.Logs[0].message, Is.EqualTo("License expired. Contact us to renew your license: contact@particular.net"));
+ });
}
[Test]
@@ -38,9 +41,12 @@ public void WhenUpgradeProtectionExpiredForThisRelease()
LicenseManager.LogLicenseStatus(LicenseStatus.InvalidDueToExpiredUpgradeProtection, logger, new License(), "fake-url");
- Assert.AreEqual(1, logger.Logs.Count);
- Assert.AreEqual(LogLevel.Error, logger.Logs[0].level);
- Assert.AreEqual("Upgrade protection expired. In order for us to continue to provide you with support and new versions of the Particular Service Platform, contact us to renew your license: contact@particular.net", logger.Logs[0].message);
+ Assert.That(logger.Logs.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(logger.Logs[0].level, Is.EqualTo(LogLevel.Error));
+ Assert.That(logger.Logs[0].message, Is.EqualTo("Upgrade protection expired. In order for us to continue to provide you with support and new versions of the Particular Service Platform, contact us to renew your license: contact@particular.net"));
+ });
}
[TestCase(false, "Trial license expired. Get your free development license at fake-url")]
@@ -52,9 +58,12 @@ public void WhenTrialLicenseExpired(bool isDevLicenseRenewal, string expectedMes
LicenseManager.LogLicenseStatus(LicenseStatus.InvalidDueToExpiredTrial, logger, license, "fake-url");
- Assert.AreEqual(1, logger.Logs.Count);
- Assert.AreEqual(LogLevel.Error, logger.Logs[0].level);
- Assert.AreEqual(expectedMessage, logger.Logs[0].message);
+ Assert.That(logger.Logs.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(logger.Logs[0].level, Is.EqualTo(LogLevel.Error));
+ Assert.That(logger.Logs[0].message, Is.EqualTo(expectedMessage));
+ });
}
[TestCase(3, false, "Trial license expiring in 3 days. Get your free development license at fake-url")]
@@ -77,9 +86,12 @@ public void WhenTrialLicenseAboutToExpire(int daysRemaining, bool isDevLicenseRe
LicenseManager.LogLicenseStatus(LicenseStatus.ValidWithExpiringTrial, logger, license, "fake-url");
- Assert.AreEqual(1, logger.Logs.Count);
- Assert.AreEqual(LogLevel.Warn, logger.Logs[0].level);
- Assert.AreEqual(expectedMessage, logger.Logs[0].message);
+ Assert.That(logger.Logs.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(logger.Logs[0].level, Is.EqualTo(LogLevel.Warn));
+ Assert.That(logger.Logs[0].message, Is.EqualTo(expectedMessage));
+ });
}
[TestCase(3, "License expiring in 3 days. Contact us to renew your license: contact@particular.net")]
@@ -98,9 +110,12 @@ public void WhenSubscriptionAboutToExpire(int daysRemaining, string expectedMess
LicenseManager.LogLicenseStatus(LicenseStatus.ValidWithExpiringSubscription, logger, license, "fake-url");
- Assert.AreEqual(1, logger.Logs.Count);
- Assert.AreEqual(LogLevel.Warn, logger.Logs[0].level);
- Assert.AreEqual(expectedMessage, logger.Logs[0].message);
+ Assert.That(logger.Logs.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(logger.Logs[0].level, Is.EqualTo(LogLevel.Warn));
+ Assert.That(logger.Logs[0].message, Is.EqualTo(expectedMessage));
+ });
}
[TestCase(3, "Upgrade protection expiring in 3 days. Contact us to renew your license: contact@particular.net")]
@@ -119,9 +134,12 @@ public void WhenUpgradeProtectionAboutToExpire(int daysRemaining, string expecte
LicenseManager.LogLicenseStatus(LicenseStatus.ValidWithExpiringUpgradeProtection, logger, license, "fake-url");
- Assert.AreEqual(1, logger.Logs.Count);
- Assert.AreEqual(LogLevel.Warn, logger.Logs[0].level);
- Assert.AreEqual(expectedMessage, logger.Logs[0].message);
+ Assert.That(logger.Logs.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(logger.Logs[0].level, Is.EqualTo(LogLevel.Warn));
+ Assert.That(logger.Logs[0].message, Is.EqualTo(expectedMessage));
+ });
}
[Test]
@@ -139,9 +157,12 @@ public void WhenUpgradeProtectionExpiredForFutureVersions()
LicenseManager.LogLicenseStatus(LicenseStatus.ValidWithExpiredUpgradeProtection, logger, license, "fake-url");
- Assert.AreEqual(1, logger.Logs.Count);
- Assert.AreEqual(LogLevel.Warn, logger.Logs[0].level);
- Assert.AreEqual("Upgrade protection expired. In order for us to continue to provide you with support and new versions of the Particular Service Platform, contact us to renew your license: contact@particular.net", logger.Logs[0].message);
+ Assert.That(logger.Logs.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(logger.Logs[0].level, Is.EqualTo(LogLevel.Warn));
+ Assert.That(logger.Logs[0].message, Is.EqualTo("Upgrade protection expired. In order for us to continue to provide you with support and new versions of the Particular Service Platform, contact us to renew your license: contact@particular.net"));
+ });
}
class TestableLogger : ILog
diff --git a/src/NServiceBus.Core.Tests/Logging/DefaultFactoryTests.cs b/src/NServiceBus.Core.Tests/Logging/DefaultFactoryTests.cs
index 4ad04c45d7b..a73c1a2251b 100644
--- a/src/NServiceBus.Core.Tests/Logging/DefaultFactoryTests.cs
+++ b/src/NServiceBus.Core.Tests/Logging/DefaultFactoryTests.cs
@@ -13,7 +13,7 @@ public void When_directory_is_bad_should_throw()
{
var defaultFactory = new DefaultFactory();
var nonExistingDirectoryException = Assert.Throws(() => defaultFactory.Directory("baddir"));
- Assert.AreEqual("Could not find logging directory: 'baddir'", nonExistingDirectoryException.Message);
+ Assert.That(nonExistingDirectoryException.Message, Is.EqualTo("Could not find logging directory: 'baddir'"));
Assert.Throws(() => defaultFactory.Directory(null));
Assert.Throws(() => defaultFactory.Directory(""));
Assert.Throws(() => defaultFactory.Directory(" "));
diff --git a/src/NServiceBus.Core.Tests/Logging/RollingLoggerTests.cs b/src/NServiceBus.Core.Tests/Logging/RollingLoggerTests.cs
index 36422ff0337..50e13d0e88d 100644
--- a/src/NServiceBus.Core.Tests/Logging/RollingLoggerTests.cs
+++ b/src/NServiceBus.Core.Tests/Logging/RollingLoggerTests.cs
@@ -22,16 +22,22 @@ public void When_file_already_exists_that_file_is_written_to()
};
logger1.WriteLine("Foo");
var files1 = tempPath.GetFiles();
- Assert.AreEqual(1, files1.Count);
- Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(files1.First()));
+ Assert.Multiple(() =>
+ {
+ Assert.That(files1.Count, Is.EqualTo(1));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(files1.First()), Is.EqualTo($"Foo{Environment.NewLine}"));
+ });
var logger2 = new RollingLogger(tempPath.TempDirectory)
{
GetDate = () => dateTime
};
logger2.WriteLine("Bar");
var files2 = tempPath.GetFiles();
- Assert.AreEqual(1, files2.Count);
- Assert.AreEqual($"Foo{Environment.NewLine}Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(files2.First()));
+ Assert.Multiple(() =>
+ {
+ Assert.That(files2.Count, Is.EqualTo(1));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(files2.First()), Is.EqualTo($"Foo{Environment.NewLine}Bar{Environment.NewLine}"));
+ });
}
}
@@ -48,7 +54,7 @@ public void When_file_is_deleted_underneath_continues_to_write_afterwards()
var single = tempPath.GetSingle();
File.Delete(single);
logger.WriteLine("Bar");
- Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(single));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(single), Is.EqualTo($"Bar{Environment.NewLine}"));
}
}
@@ -67,7 +73,7 @@ public void When_file_is_locked_exception_is_swallowed()
{
logger.WriteLine("Bar");
}
- Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(single));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(single), Is.EqualTo($"Foo{Environment.NewLine}"));
}
}
@@ -89,7 +95,7 @@ public void When_file_is_deleted_underneath_immediately_before_write()
var singleFile = tempPath.GetSingle();
File.Delete(singleFile);
logger.WriteLine("Bar");
- Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(singleFile), Is.EqualTo($"Bar{Environment.NewLine}"));
}
}
@@ -127,15 +133,21 @@ public void When_file_already_exists_and_is_too_large_a_new_sequence_file_is_wri
logger2.WriteLine("Bar");
var files = tempPath.GetFiles();
- Assert.AreEqual(2, files.Count);
+ Assert.That(files.Count, Is.EqualTo(2));
var first = files[0];
- Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(first));
- Assert.AreEqual($"Some long text{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(files.First()));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(first), Is.EqualTo("nsb_log_2010-10-01_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(files.First()), Is.EqualTo($"Some long text{Environment.NewLine}"));
+ });
var second = files[1];
- Assert.AreEqual("nsb_log_2010-10-01_1.txt", Path.GetFileName(second));
- Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(second), Is.EqualTo("nsb_log_2010-10-01_1.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(second), Is.EqualTo($"Bar{Environment.NewLine}"));
+ });
}
}
@@ -156,15 +168,21 @@ public void When_file_already_exists_with_wrong_date_a_file_is_written()
logger2.WriteLine("Bar");
var files = tempPath.GetFiles();
- Assert.AreEqual(2, files.Count);
+ Assert.That(files.Count, Is.EqualTo(2));
var first = files[0];
- Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(first));
- Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(files.First()));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(first), Is.EqualTo("nsb_log_2010-10-01_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(files.First()), Is.EqualTo($"Foo{Environment.NewLine}"));
+ });
var second = files[1];
- Assert.AreEqual("nsb_log_2010-10-02_0.txt", Path.GetFileName(second));
- Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(second), Is.EqualTo("nsb_log_2010-10-02_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(second), Is.EqualTo($"Bar{Environment.NewLine}"));
+ });
}
}
@@ -176,7 +194,7 @@ public void When_line_is_write_line_appears_in_file()
var logger = new RollingLogger(tempPath.TempDirectory);
logger.WriteLine("Foo");
var singleFile = tempPath.GetSingle();
- Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(singleFile), Is.EqualTo($"Foo{Environment.NewLine}"));
}
}
@@ -189,7 +207,7 @@ public void When_multiple_lines_are_written_lines_appears_in_file()
logger.WriteLine("Foo");
logger.WriteLine("Bar");
var singleFile = tempPath.GetSingle();
- Assert.AreEqual($"Foo{Environment.NewLine}Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(singleFile), Is.EqualTo($"Foo{Environment.NewLine}Bar{Environment.NewLine}"));
}
}
@@ -206,15 +224,21 @@ public void When_max_file_size_is_exceeded_sequence_number_is_added()
logger.WriteLine("Some long text");
logger.WriteLine("Bar");
var files = tempPath.GetFiles();
- Assert.AreEqual(2, files.Count);
+ Assert.That(files.Count, Is.EqualTo(2));
var first = files[0];
- Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(first));
- Assert.AreEqual($"Some long text{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(first));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(first), Is.EqualTo("nsb_log_2010-10-01_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(first), Is.EqualTo($"Some long text{Environment.NewLine}"));
+ });
var second = files[1];
- Assert.AreEqual("nsb_log_2010-10-01_1.txt", Path.GetFileName(second));
- Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(second), Is.EqualTo("nsb_log_2010-10-01_1.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(second), Is.EqualTo($"Bar{Environment.NewLine}"));
+ });
}
}
@@ -230,7 +254,7 @@ public void When_many_sequence_files_are_written_the_max_is_not_exceeded()
for (var i = 0; i < 100; i++)
{
logger.WriteLine("Some long text");
- Assert.LessOrEqual(tempPath.GetFiles().Count, 11);
+ Assert.That(tempPath.GetFiles().Count, Is.LessThanOrEqualTo(11));
}
}
}
@@ -244,7 +268,7 @@ public void When_new_write_causes_overlap_of_file_size_line_is_written_to_curren
logger.WriteLine("Foo");
logger.WriteLine("Some long text");
var singleFile = tempPath.GetSingle();
- Assert.AreEqual($"Foo{Environment.NewLine}Some long text{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(singleFile), Is.EqualTo($"Foo{Environment.NewLine}Some long text{Environment.NewLine}"));
}
}
@@ -261,15 +285,21 @@ public void When_date_changes_new_file_is_written()
logger.GetDate = () => new DateTimeOffset(2010, 10, 2, 0, 0, 0, TimeSpan.Zero);
logger.WriteLine("Bar");
var files = tempPath.GetFiles();
- Assert.AreEqual(2, files.Count);
+ Assert.That(files.Count, Is.EqualTo(2));
var first = files[0];
- Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(first));
- Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(first));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(first), Is.EqualTo("nsb_log_2010-10-01_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(first), Is.EqualTo($"Foo{Environment.NewLine}"));
+ });
var second = files[1];
- Assert.AreEqual("nsb_log_2010-10-02_0.txt", Path.GetFileName(second));
- Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(second), Is.EqualTo("nsb_log_2010-10-02_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(second), Is.EqualTo($"Bar{Environment.NewLine}"));
+ });
}
}
@@ -291,7 +321,7 @@ public void When_getting_todays_log_file_sequence_number_is_used_in_sorting()
},
};
var logFile = RollingLogger.GetTodaysNewest(logFiles, today);
- Assert.AreEqual(2, logFile.SequenceNumber);
+ Assert.That(logFile.SequenceNumber, Is.EqualTo(2));
}
[Test]
@@ -329,7 +359,7 @@ public void When_getting_todays_log_file_only_today_is_respected()
},
};
var logFile = RollingLogger.GetTodaysNewest(logFiles, today);
- Assert.AreEqual(0, logFile.SequenceNumber);
+ Assert.That(logFile.SequenceNumber, Is.EqualTo(0));
}
[Test]
@@ -348,19 +378,28 @@ public void When_many_files_written_over_size_old_files_are_deleted()
logger.WriteLine("Long text3");
logger.WriteLine("Long text4");
var files = tempPath.GetFiles();
- Assert.AreEqual(3, files.Count, "Should be numberOfArchiveFilesToKeep + 1 (the current file) ");
+ Assert.That(files.Count, Is.EqualTo(3), "Should be numberOfArchiveFilesToKeep + 1 (the current file) ");
var first = files[0];
- Assert.AreEqual("nsb_log_2010-10-01_2.txt", Path.GetFileName(first));
- Assert.AreEqual($"Long text2{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(first));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(first), Is.EqualTo("nsb_log_2010-10-01_2.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(first), Is.EqualTo($"Long text2{Environment.NewLine}"));
+ });
var second = files[1];
- Assert.AreEqual("nsb_log_2010-10-01_3.txt", Path.GetFileName(second));
- Assert.AreEqual($"Long text3{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(second), Is.EqualTo("nsb_log_2010-10-01_3.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(second), Is.EqualTo($"Long text3{Environment.NewLine}"));
+ });
var third = files[2];
- Assert.AreEqual("nsb_log_2010-10-01_4.txt", Path.GetFileName(third));
- Assert.AreEqual($"Long text4{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(third));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(third), Is.EqualTo("nsb_log_2010-10-01_4.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(third), Is.EqualTo($"Long text4{Environment.NewLine}"));
+ });
}
}
@@ -383,19 +422,28 @@ public void When_many_files_written_over_dates_old_files_are_deleted()
logger.GetDate = () => new DateTimeOffset(2010, 10, 5, 0, 0, 0, TimeSpan.Zero);
logger.WriteLine("Foo5");
var files = tempPath.GetFiles();
- Assert.AreEqual(3, files.Count, "Should be numberOfArchiveFilesToKeep + 1 (the current file) ");
+ Assert.That(files.Count, Is.EqualTo(3), "Should be numberOfArchiveFilesToKeep + 1 (the current file) ");
var first = files[0];
- Assert.AreEqual("nsb_log_2010-10-03_0.txt", Path.GetFileName(first));
- Assert.AreEqual($"Foo3{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(first));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(first), Is.EqualTo("nsb_log_2010-10-03_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(first), Is.EqualTo($"Foo3{Environment.NewLine}"));
+ });
var second = files[1];
- Assert.AreEqual("nsb_log_2010-10-04_0.txt", Path.GetFileName(second));
- Assert.AreEqual($"Foo4{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(second), Is.EqualTo("nsb_log_2010-10-04_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(second), Is.EqualTo($"Foo4{Environment.NewLine}"));
+ });
var third = files[2];
- Assert.AreEqual("nsb_log_2010-10-05_0.txt", Path.GetFileName(third));
- Assert.AreEqual($"Foo5{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(third));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Path.GetFileName(third), Is.EqualTo("nsb_log_2010-10-05_0.txt"));
+ Assert.That(NonLockingFileReader.ReadAllTextWithoutLocking(third), Is.EqualTo($"Foo5{Environment.NewLine}"));
+ });
}
}
@@ -410,7 +458,7 @@ public void When_line_is_write_file_has_correct_name()
};
logger.WriteLine("Foo");
var singleFile = tempPath.GetSingle();
- Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(singleFile));
+ Assert.That(Path.GetFileName(singleFile), Is.EqualTo("nsb_log_2010-10-01_0.txt"));
}
}
class TempPath : IDisposable
diff --git a/src/NServiceBus.Core.Tests/MessageConventionSpecs.cs b/src/NServiceBus.Core.Tests/MessageConventionSpecs.cs
index 4622a6510da..94d44f77bae 100644
--- a/src/NServiceBus.Core.Tests/MessageConventionSpecs.cs
+++ b/src/NServiceBus.Core.Tests/MessageConventionSpecs.cs
@@ -17,10 +17,10 @@ public void Should_cache_the_message_convention()
return false;
});
conventions.IsMessageType(GetType());
- Assert.AreEqual(1, timesCalled);
+ Assert.That(timesCalled, Is.EqualTo(1));
conventions.IsMessageType(GetType());
- Assert.AreEqual(1, timesCalled);
+ Assert.That(timesCalled, Is.EqualTo(1));
}
}
@@ -40,10 +40,10 @@ public void Should_cache_the_message_convention()
});
conventions.IsEventType(GetType());
- Assert.AreEqual(1, timesCalled);
+ Assert.That(timesCalled, Is.EqualTo(1));
conventions.IsEventType(GetType());
- Assert.AreEqual(1, timesCalled);
+ Assert.That(timesCalled, Is.EqualTo(1));
}
}
@@ -63,10 +63,10 @@ public void Should_cache_the_message_convention()
});
conventions.IsCommandType(GetType());
- Assert.AreEqual(1, timesCalled);
+ Assert.That(timesCalled, Is.EqualTo(1));
conventions.IsCommandType(GetType());
- Assert.AreEqual(1, timesCalled);
+ Assert.That(timesCalled, Is.EqualTo(1));
}
}
diff --git a/src/NServiceBus.Core.Tests/MessageMapper/MessageMapperTests.cs b/src/NServiceBus.Core.Tests/MessageMapper/MessageMapperTests.cs
index beabb8bc77d..79502b0e3d7 100644
--- a/src/NServiceBus.Core.Tests/MessageMapper/MessageMapperTests.cs
+++ b/src/NServiceBus.Core.Tests/MessageMapper/MessageMapperTests.cs
@@ -109,7 +109,7 @@ public void Should_fail_for_interface_message_with_illegal_interface_property()
var mapper = new MessageMapper();
var ex = Assert.Throws(() => mapper.Initialize(new[] { typeof(IInterfaceMessageWithIllegalInterfaceProperty) }));
- StringAssert.Contains($"Cannot generate a concrete implementation for '{typeof(IIllegalProperty).FullName}' because it contains methods. Ensure that all interfaces used as messages do not contain methods.", ex.Message);
+ Assert.That(ex.Message, Does.Contain($"Cannot generate a concrete implementation for '{typeof(IIllegalProperty).FullName}' because it contains methods. Ensure that all interfaces used as messages do not contain methods."));
}
[Test]
@@ -118,7 +118,7 @@ public void Should_fail_for_non_public_interface_message()
var mapper = new MessageMapper();
var ex = Assert.Throws(() => mapper.Initialize(new[] { typeof(IPrivateInterfaceMessage) }));
- StringAssert.Contains($"Cannot generate a concrete implementation for '{typeof(IPrivateInterfaceMessage).FullName}' because it is not public. Ensure that all interfaces used as messages are public.", ex.Message);
+ Assert.That(ex.Message, Does.Contain($"Cannot generate a concrete implementation for '{typeof(IPrivateInterfaceMessage).FullName}' because it is not public. Ensure that all interfaces used as messages are public."));
}
[Test]
@@ -128,8 +128,8 @@ public void CreateInstance_should_initialize_interface_message_type_on_demand()
var messageInstance = mapper.CreateInstance();
- Assert.IsNotNull(messageInstance);
- Assert.IsInstanceOf(messageInstance);
+ Assert.That(messageInstance, Is.Not.Null);
+ Assert.That(messageInstance, Is.InstanceOf());
}
[Test]
@@ -139,9 +139,12 @@ public void CreateInstance_should_initialize_message_type_on_demand()
var messageInstance = mapper.CreateInstance();
- Assert.IsNotNull(messageInstance);
- Assert.AreEqual(typeof(SampleMessageClass), messageInstance.GetType());
- Assert.IsTrue(messageInstance.CtorInvoked);
+ Assert.That(messageInstance, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(messageInstance.GetType(), Is.EqualTo(typeof(SampleMessageClass)));
+ Assert.That(messageInstance.CtorInvoked, Is.True);
+ });
}
[Test]
@@ -152,8 +155,8 @@ public void CreateInstance_should_not_initialize_message_type_implementing_IEnum
var messageInstance = mapper.CreateInstance>();
- Assert.IsNotNull(messageInstance);
- Assert.IsFalse(messageInstance.CtorInvoked);
+ Assert.That(messageInstance, Is.Not.Null);
+ Assert.That(messageInstance.CtorInvoked, Is.False);
}
[Test]
@@ -163,8 +166,7 @@ public void Should_create_structs()
var messageInstance = mapper.CreateInstance();
- Assert.IsNotNull(messageInstance);
- Assert.AreEqual(typeof(SampleMessageStruct), messageInstance.GetType());
+ Assert.That(messageInstance.GetType(), Is.EqualTo(typeof(SampleMessageStruct)));
}
[Test]
@@ -174,7 +176,7 @@ public void Should_map_structs()
var mappedType = mapper.GetMappedTypeFor(typeof(SampleMessageStruct));
- Assert.AreEqual(typeof(SampleMessageStruct), mappedType);
+ Assert.That(mappedType, Is.EqualTo(typeof(SampleMessageStruct)));
}
[Test]
@@ -184,7 +186,7 @@ public void Should_handle_interfaces_that_have_attributes_with_nullable_properti
var messageInstance = mapper.CreateInstance();
- Assert.IsNotNull(messageInstance);
+ Assert.That(messageInstance, Is.Not.Null);
}
public class SampleMessageClass
diff --git a/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_ienumerable_implementations.cs b/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_ienumerable_implementations.cs
index cf7a0b5a31b..d51d169d57e 100644
--- a/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_ienumerable_implementations.cs
+++ b/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_ienumerable_implementations.cs
@@ -18,7 +18,7 @@ public void Class_implementing_iEnumerable_string_should_be_mapped()
typeof(ClassImplementingIEnumerable)
});
- Assert.NotNull(mapper.GetMappedTypeFor(typeof(ClassImplementingIEnumerable)));
+ Assert.That(mapper.GetMappedTypeFor(typeof(ClassImplementingIEnumerable)), Is.Not.Null);
}
[Test]
@@ -30,7 +30,7 @@ public void Class_implementing_iEnumerable_string_and_iReturnMyself_should_be_ma
typeof(ClassImplementingIEnumerableAndIReturnMyself)
});
- Assert.NotNull(mapper.GetMappedTypeFor(typeof(ClassImplementingIEnumerableAndIReturnMyself)));
+ Assert.That(mapper.GetMappedTypeFor(typeof(ClassImplementingIEnumerableAndIReturnMyself)), Is.Not.Null);
}
class ClassImplementingIEnumerableAndIReturnMyself : IEnumerable, IReturnMyself>
{
@@ -60,7 +60,7 @@ public void Class_implementing_iEnumerable_returnMyself_should_be_mapped()
typeof(ClassImplementingIEnumerable)
});
- Assert.NotNull(mapper.GetMappedTypeFor(typeof(ClassImplementingIEnumerable)));
+ Assert.That(mapper.GetMappedTypeFor(typeof(ClassImplementingIEnumerable)), Is.Not.Null);
}
[Test]
@@ -72,7 +72,7 @@ public void Class_inheriting_from_iEnumerable_returnMyself_implementation_should
typeof(DerivedReturnMyselfCollectionObject)
});
- Assert.NotNull(mapper.GetMappedTypeFor(typeof(DerivedReturnMyselfCollectionObject)));
+ Assert.That(mapper.GetMappedTypeFor(typeof(DerivedReturnMyselfCollectionObject)), Is.Not.Null);
}
class DerivedReturnMyselfCollectionObject : ClassImplementingIEnumerable
@@ -88,7 +88,7 @@ public void Class_implementing_returnMyself_inheriting_from_iEnumerable_returnMy
typeof(DerivedReturnMyselfCollectionImplementingIReturnMyself)
});
- Assert.NotNull(mapper.GetMappedTypeFor(typeof(DerivedReturnMyselfCollectionImplementingIReturnMyself)));
+ Assert.That(mapper.GetMappedTypeFor(typeof(DerivedReturnMyselfCollectionImplementingIReturnMyself)), Is.Not.Null);
}
class DerivedReturnMyselfCollectionImplementingIReturnMyself : ClassImplementingIEnumerable, IReturnMyself
@@ -109,7 +109,7 @@ public void Class_implementing_base_returnMyself_inheriting_from_iEnumerable_ret
typeof(DerivedReturnMyselfCollectionImplementingBaseIReturnMyself)
});
- Assert.NotNull(mapper.GetMappedTypeFor(typeof(DerivedReturnMyselfCollectionImplementingBaseIReturnMyself)));
+ Assert.That(mapper.GetMappedTypeFor(typeof(DerivedReturnMyselfCollectionImplementingBaseIReturnMyself)), Is.Not.Null);
}
class DerivedReturnMyselfCollectionImplementingBaseIReturnMyself : ClassImplementingIEnumerable, IReturnMyself>
diff --git a/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_interfaces.cs b/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_interfaces.cs
index bf419c138c3..78ff62f6799 100644
--- a/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_interfaces.cs
+++ b/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_interfaces.cs
@@ -14,7 +14,7 @@ public void Interfaces_with_only_properties_should_be_mapped()
var mapper = new MessageMapper();
mapper.Initialize(new[] { typeof(IInterfaceWithOnlyProperties) });
- Assert.NotNull(mapper.GetMappedTypeFor(typeof(IInterfaceWithOnlyProperties)));
+ Assert.That(mapper.GetMappedTypeFor(typeof(IInterfaceWithOnlyProperties)), Is.Not.Null);
}
public interface IInterfaceWithOnlyProperties : IMessage
@@ -30,7 +30,7 @@ public void Interface_should_be_created()
var result = mapper.CreateInstance(null);
- Assert.IsNotNull(result);
+ Assert.That(result, Is.Not.Null);
}
public interface IInterface : IMessage
@@ -59,10 +59,13 @@ public void Attributes_on_properties_should_be_mapped()
{
var mapper = new MessageMapper();
mapper.Initialize(new[] { typeof(IInterfaceWithPropertiesAndAttributes) });
- Assert.IsTrue(PropertyContainsAttribute("SomeProperty", typeof(SomeAttribute), mapper.CreateInstance(typeof(IInterfaceWithPropertiesAndAttributes))));
+ Assert.Multiple(() =>
+ {
+ Assert.That(PropertyContainsAttribute("SomeProperty", typeof(SomeAttribute), mapper.CreateInstance(typeof(IInterfaceWithPropertiesAndAttributes))), Is.True);
- // Doesn't affect properties without attributes
- Assert.IsFalse(PropertyContainsAttribute("SomeOtherProperty", typeof(SomeAttribute), mapper.CreateInstance(typeof(IInterfaceWithPropertiesAndAttributes))));
+ // Doesn't affect properties without attributes
+ Assert.That(PropertyContainsAttribute("SomeOtherProperty", typeof(SomeAttribute), mapper.CreateInstance(typeof(IInterfaceWithPropertiesAndAttributes))), Is.False);
+ });
}
public interface IInterfaceWithPropertiesAndAttributes
@@ -86,7 +89,7 @@ public void Accept_Attributes_with_no_default_ctor_as_long_as_the_parameter_in_c
var instance = mapper.CreateInstance(typeof(IInterfaceWithCustomAttributeThatHasNoDefaultConstructor));
var attributes = instance.GetType().GetProperty("SomeProperty").GetCustomAttributes(typeof(NoDefaultConstructorAttribute), true);
var attr = (NoDefaultConstructorAttribute)attributes[0];
- Assert.AreEqual(attr.Name, "Blah");
+ Assert.That(attr.Name, Is.EqualTo("Blah"));
}
public interface IInterfaceWithCustomAttributeThatHasNoDefaultConstructor
@@ -113,7 +116,7 @@ public void Accept_Attributes_with_no_default_ctor_while_ctor_parameters_are_dif
var instance = mapper.CreateInstance(typeof(IInterfaceWithCustomAttributeThatHasNoDefaultConstructorAndNoMatchingParameters));
var attributes = instance.GetType().GetProperty("SomeProperty").GetCustomAttributes(typeof(NoDefaultConstructorAndNoMatchingParametersAttribute), true);
var attr = (NoDefaultConstructorAndNoMatchingParametersAttribute)attributes[0];
- Assert.AreEqual(attr.Name, "Blah");
+ Assert.That(attr.Name, Is.EqualTo("Blah"));
}
public interface IInterfaceWithCustomAttributeThatHasNoDefaultConstructorAndNoMatchingParameters
{
@@ -142,7 +145,7 @@ public void Generated_type_should_preserve_namespace_to_make_it_easier_for_users
var mapper = new MessageMapper();
mapper.Initialize(new[] { typeof(IInterfaceToGenerate) });
- Assert.AreEqual(typeof(IInterfaceToGenerate).Namespace, mapper.CreateInstance(typeof(IInterfaceToGenerate)).GetType().Namespace);
+ Assert.That(mapper.CreateInstance(typeof(IInterfaceToGenerate)).GetType().Namespace, Is.EqualTo(typeof(IInterfaceToGenerate).Namespace));
}
public interface IInterfaceToGenerate : IMessage
@@ -158,10 +161,10 @@ public void Accept_attributes_with_value_attribute()
var instance = mapper.CreateInstance(typeof(IMyEventWithAttributeWithBoolProperty));
var attributes = instance.GetType().GetProperty("EventId").GetCustomAttributes(typeof(ValuePropertiesAttribute), true);
var attr = attributes[0] as ValuePropertiesAttribute;
- Assert.AreEqual(attr != null && attr.FlagIsSet, true);
+ Assert.That(attr != null && attr.FlagIsSet, Is.EqualTo(true));
if (attr != null)
{
- Assert.AreEqual(attr.MyAge, 21);
+ Assert.That(attr.MyAge, Is.EqualTo(21));
}
}
diff --git a/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_usinggenerics.cs b/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_usinggenerics.cs
index 1670c6fc14d..215c0fe68d9 100644
--- a/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_usinggenerics.cs
+++ b/src/NServiceBus.Core.Tests/MessageMapper/When_mapping_usinggenerics.cs
@@ -14,7 +14,7 @@ public void Class_abstract_generic_with_only_properties_generic_should_not_be_ma
var mapper = new MessageMapper();
var genericClassType = typeof(GenericAbstractCommand<>);
mapper.Initialize(new[] { genericClassType });
- Assert.Null(mapper.GetMappedTypeFor(genericClassType));
+ Assert.That(mapper.GetMappedTypeFor(genericClassType), Is.Null);
}
public abstract class GenericAbstractCommand : IMessage where T : Data
{
@@ -27,7 +27,7 @@ public void Class_generic_with_only_properties_generic_should_not_be_mapped()
var mapper = new MessageMapper();
var abstractClassType = typeof(GenericCommand<>);
mapper.Initialize(new[] { abstractClassType });
- Assert.Null(mapper.GetMappedTypeFor(abstractClassType));
+ Assert.That(mapper.GetMappedTypeFor(abstractClassType), Is.Null);
}
public class GenericCommand : IMessage where T : Data
@@ -42,7 +42,7 @@ public void Class_derived_from_generic_with_only_properties_generic_should_be_ma
var mapper = new MessageMapper();
var abstractClassType = typeof(DerivedGenericCommand);
mapper.Initialize(new[] { abstractClassType });
- Assert.NotNull(mapper.GetMappedTypeFor(abstractClassType));
+ Assert.That(mapper.GetMappedTypeFor(abstractClassType), Is.Not.Null);
}
public abstract class GenericBaseCommand : IMessage where T : Data
{
@@ -59,7 +59,7 @@ public void Class_concrete_generic_with_only_properties_generic_should_be_mapped
var mapper = new MessageMapper();
var abstractClassType = typeof(GenericCommand);
mapper.Initialize(new[] { abstractClassType });
- Assert.NotNull(mapper.GetMappedTypeFor(abstractClassType));
+ Assert.That(mapper.GetMappedTypeFor(abstractClassType), Is.Not.Null);
}
[Test]
@@ -68,7 +68,7 @@ public void Class_abstract_with_only_properties_should_be_mapped()
var mapper = new MessageMapper();
var abstractClassType = typeof(SimpleAbstractClass);
mapper.Initialize(new[] { abstractClassType });
- Assert.NotNull(mapper.GetMappedTypeFor(abstractClassType));
+ Assert.That(mapper.GetMappedTypeFor(abstractClassType), Is.Not.Null);
}
public abstract class SimpleAbstractClass : IMessage
{
@@ -84,7 +84,7 @@ public void Class_abstract_with_methods_should_not_be_mapped()
var mapper = new MessageMapper();
var abstractClassType = typeof(SimpleAbstractClassWithMethods);
mapper.Initialize(new[] { abstractClassType });
- Assert.Null(mapper.GetMappedTypeFor(abstractClassType));
+ Assert.That(mapper.GetMappedTypeFor(abstractClassType), Is.Null);
}
public abstract class SimpleAbstractClassWithMethods : IMessage
{
@@ -100,7 +100,7 @@ public void Interfaces_generic_with_only_properties_should_not_be_mapped()
var mapper = new MessageMapper();
var genericInterfaceType = typeof(IInterfaceGenericWithProperties<>);
mapper.Initialize(new[] { genericInterfaceType });
- Assert.Null(mapper.GetMappedTypeFor(genericInterfaceType));
+ Assert.That(mapper.GetMappedTypeFor(genericInterfaceType), Is.Null);
}
public interface IInterfaceGenericWithProperties : IMessage where T : Data
@@ -115,7 +115,7 @@ public void Interfaces_generic_with_methods_should_not_be_mapped()
var mapper = new MessageMapper();
var genericInterfaceType = typeof(IInterfaceGenericWithMethods<>);
mapper.Initialize(new[] { genericInterfaceType });
- Assert.Null(mapper.GetMappedTypeFor(genericInterfaceType));
+ Assert.That(mapper.GetMappedTypeFor(genericInterfaceType), Is.Null);
}
public interface IInterfaceGenericWithMethods : IMessage where T : Data
{
@@ -129,7 +129,7 @@ public void Interfaces_with_only_properties_should_be_mapped()
var mapper = new MessageMapper();
var simpleInterfaceType = typeof(IInterfaceWithOnlyProperties);
mapper.Initialize(new[] { simpleInterfaceType });
- Assert.NotNull(mapper.GetMappedTypeFor(simpleInterfaceType));
+ Assert.That(mapper.GetMappedTypeFor(simpleInterfaceType), Is.Not.Null);
}
public interface IInterfaceWithOnlyProperties : IMessage
@@ -143,7 +143,7 @@ public void Interfaces_with_inheritance_and_property_overload_should_be_mapped()
var mapper = new MessageMapper();
var genericInterfaceType = typeof(IInterfaceWithGenericProperty);
mapper.Initialize(new[] { genericInterfaceType });
- Assert.NotNull(mapper.GetMappedTypeFor(genericInterfaceType));
+ Assert.That(mapper.GetMappedTypeFor(genericInterfaceType), Is.Not.Null);
}
public interface IInterfaceWithGenericProperty
diff --git a/src/NServiceBus.Core.Tests/MessageMutators/MutateInstanceMessage/MutateIncomingMessageBehaviorTests.cs b/src/NServiceBus.Core.Tests/MessageMutators/MutateInstanceMessage/MutateIncomingMessageBehaviorTests.cs
index aca903a8557..066f624466b 100644
--- a/src/NServiceBus.Core.Tests/MessageMutators/MutateInstanceMessage/MutateIncomingMessageBehaviorTests.cs
+++ b/src/NServiceBus.Core.Tests/MessageMutators/MutateInstanceMessage/MutateIncomingMessageBehaviorTests.cs
@@ -23,8 +23,11 @@ public async Task Should_invoke_all_explicit_mutators()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(mutator.MutateIncomingCalled);
- Assert.True(otherMutator.MutateIncomingCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(mutator.MutateIncomingCalled, Is.True);
+ Assert.That(otherMutator.MutateIncomingCalled, Is.True);
+ });
}
[Test]
@@ -40,8 +43,11 @@ public async Task Should_invoke_both_explicit_and_container_provided_mutators()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(explicitMutator.MutateIncomingCalled);
- Assert.True(containerMutator.MutateIncomingCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(explicitMutator.MutateIncomingCalled, Is.True);
+ Assert.That(containerMutator.MutateIncomingCalled, Is.True);
+ });
}
[Test]
@@ -58,7 +64,7 @@ public async Task Should_not_call_MutateIncoming_when_hasIncomingMessageMutators
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.IsFalse(mutator.MutateIncomingCalled);
+ Assert.That(mutator.MutateIncomingCalled, Is.False);
}
[Test]
@@ -89,7 +95,7 @@ public async Task When_no_mutator_updates_the_body_should_not_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.False(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.False);
}
[Test]
@@ -103,7 +109,7 @@ public async Task When_no_mutator_available_should_not_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.False(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.False);
}
[Test]
@@ -117,7 +123,7 @@ public async Task When_mutator_modifies_the_body_should_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.True);
}
class InterceptUpdateMessageIncomingLogicalMessageContext : TestableIncomingLogicalMessageContext
diff --git a/src/NServiceBus.Core.Tests/MessageMutators/MutateInstanceMessage/MutateOutgoingMessageBehaviorTests.cs b/src/NServiceBus.Core.Tests/MessageMutators/MutateInstanceMessage/MutateOutgoingMessageBehaviorTests.cs
index 0b113a5858c..474f21a22b8 100644
--- a/src/NServiceBus.Core.Tests/MessageMutators/MutateInstanceMessage/MutateOutgoingMessageBehaviorTests.cs
+++ b/src/NServiceBus.Core.Tests/MessageMutators/MutateInstanceMessage/MutateOutgoingMessageBehaviorTests.cs
@@ -23,8 +23,11 @@ public async Task Should_invoke_all_explicit_mutators()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(mutator.MutateOutgoingCalled);
- Assert.True(otherMutator.MutateOutgoingCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(mutator.MutateOutgoingCalled, Is.True);
+ Assert.That(otherMutator.MutateOutgoingCalled, Is.True);
+ });
}
[Test]
@@ -40,8 +43,11 @@ public async Task Should_invoke_both_explicit_and_container_provided_mutators()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(explicitMutator.MutateOutgoingCalled);
- Assert.True(containerMutator.MutateOutgoingCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(explicitMutator.MutateOutgoingCalled, Is.True);
+ Assert.That(containerMutator.MutateOutgoingCalled, Is.True);
+ });
}
[Test]
@@ -58,7 +64,7 @@ public async Task Should_not_call_MutateOutgoing_when_hasOutgoingMessageMutators
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.IsFalse(mutator.MutateOutgoingCalled);
+ Assert.That(mutator.MutateOutgoingCalled, Is.False);
}
[Test]
@@ -85,7 +91,7 @@ public async Task When_no_mutator_updates_the_body_should_not_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.False(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.False);
}
[Test]
@@ -99,7 +105,7 @@ public async Task When_no_mutator_available_should_not_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.False(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.False);
}
[Test]
@@ -113,7 +119,7 @@ public async Task When_mutator_modifies_the_body_should_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.True);
}
class InterceptUpdateMessageOutgoingLogicalMessageContext : TestableOutgoingLogicalMessageContext
diff --git a/src/NServiceBus.Core.Tests/MessageMutators/MutateTransportMessage/MutateIncomingTransportMessageBehaviorTests.cs b/src/NServiceBus.Core.Tests/MessageMutators/MutateTransportMessage/MutateIncomingTransportMessageBehaviorTests.cs
index 9063ea46675..c8255d6d5b3 100644
--- a/src/NServiceBus.Core.Tests/MessageMutators/MutateTransportMessage/MutateIncomingTransportMessageBehaviorTests.cs
+++ b/src/NServiceBus.Core.Tests/MessageMutators/MutateTransportMessage/MutateIncomingTransportMessageBehaviorTests.cs
@@ -22,8 +22,11 @@ public async Task Should_invoke_all_explicit_mutators()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(mutator.MutateIncomingCalled);
- Assert.True(otherMutator.MutateIncomingCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(mutator.MutateIncomingCalled, Is.True);
+ Assert.That(otherMutator.MutateIncomingCalled, Is.True);
+ });
}
[Test]
@@ -39,8 +42,11 @@ public async Task Should_invoke_both_explicit_and_container_provided_mutators()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(explicitMutator.MutateIncomingCalled);
- Assert.True(containerMutator.MutateIncomingCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(explicitMutator.MutateIncomingCalled, Is.True);
+ Assert.That(containerMutator.MutateIncomingCalled, Is.True);
+ });
}
[Test]
@@ -57,7 +63,7 @@ public async Task Should_not_call_MutateIncoming_when_hasIncomingTransportMessag
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.IsFalse(mutator.MutateIncomingCalled);
+ Assert.That(mutator.MutateIncomingCalled, Is.False);
}
[Test]
@@ -83,7 +89,7 @@ public async Task When_no_mutator_updates_the_body_should_not_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.False(context.UpdateMessageBodyCalled);
+ Assert.That(context.UpdateMessageBodyCalled, Is.False);
}
[Test]
@@ -97,7 +103,7 @@ public async Task When_no_mutator_available_should_not_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.False(context.UpdateMessageBodyCalled);
+ Assert.That(context.UpdateMessageBodyCalled, Is.False);
}
[Test]
@@ -111,7 +117,7 @@ public async Task When_mutator_modifies_the_body_should_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(context.UpdateMessageBodyCalled);
+ Assert.That(context.UpdateMessageBodyCalled, Is.True);
}
class InterceptUpdateMessageIncomingPhysicalMessageContext : TestableIncomingPhysicalMessageContext
diff --git a/src/NServiceBus.Core.Tests/MessageMutators/MutateTransportMessage/MutateOutgoingTransportMessageBehaviorTests.cs b/src/NServiceBus.Core.Tests/MessageMutators/MutateTransportMessage/MutateOutgoingTransportMessageBehaviorTests.cs
index 9308e7cc01c..8af6929e045 100644
--- a/src/NServiceBus.Core.Tests/MessageMutators/MutateTransportMessage/MutateOutgoingTransportMessageBehaviorTests.cs
+++ b/src/NServiceBus.Core.Tests/MessageMutators/MutateTransportMessage/MutateOutgoingTransportMessageBehaviorTests.cs
@@ -24,8 +24,11 @@ public async Task Should_invoke_all_explicit_mutators()
await behavior.Invoke(physicalContext, ctx => Task.CompletedTask);
- Assert.True(mutator.MutateOutgoingCalled);
- Assert.True(otherMutator.MutateOutgoingCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(mutator.MutateOutgoingCalled, Is.True);
+ Assert.That(otherMutator.MutateOutgoingCalled, Is.True);
+ });
}
[Test]
@@ -42,8 +45,11 @@ public async Task Should_invoke_both_explicit_and_container_provided_mutators()
await behavior.Invoke(physicalContext, ctx => Task.CompletedTask);
- Assert.True(explicitMutator.MutateOutgoingCalled);
- Assert.True(containerMutator.MutateOutgoingCalled);
+ Assert.Multiple(() =>
+ {
+ Assert.That(explicitMutator.MutateOutgoingCalled, Is.True);
+ Assert.That(containerMutator.MutateOutgoingCalled, Is.True);
+ });
}
[Test]
@@ -61,7 +67,7 @@ public async Task Should_not_call_MutateOutgoing_when_hasOutgoingTransportMessag
await behavior.Invoke(physicalContext, ctx => Task.CompletedTask);
- Assert.IsFalse(mutator.MutateOutgoingCalled);
+ Assert.That(mutator.MutateOutgoingCalled, Is.False);
}
[Test]
@@ -88,7 +94,7 @@ public async Task When_no_mutator_updates_the_body_should_not_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.False(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.False);
}
[Test]
@@ -103,7 +109,7 @@ public async Task When_no_mutator_available_should_not_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.False(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.False);
}
[Test]
@@ -118,7 +124,7 @@ public async Task When_mutator_modifies_the_body_should_update_the_body()
await behavior.Invoke(context, ctx => Task.CompletedTask);
- Assert.True(context.UpdateMessageCalled);
+ Assert.That(context.UpdateMessageCalled, Is.True);
}
class InterceptUpdateMessageOutgoingPhysicalMessageContext : TestableOutgoingPhysicalMessageContext
diff --git a/src/NServiceBus.Core.Tests/MessageMutators/MutatorRegistrationExtensionsTests.cs b/src/NServiceBus.Core.Tests/MessageMutators/MutatorRegistrationExtensionsTests.cs
index d2434eda306..a2f14b34717 100644
--- a/src/NServiceBus.Core.Tests/MessageMutators/MutatorRegistrationExtensionsTests.cs
+++ b/src/NServiceBus.Core.Tests/MessageMutators/MutatorRegistrationExtensionsTests.cs
@@ -14,9 +14,9 @@ public void Should_throw_ArgumentException_when_registering_non_mutator_type()
var endpointConfiguration = new EndpointConfiguration("test");
var exception = Assert.Throws(() => endpointConfiguration.RegisterMessageMutator(new object()));
- StringAssert.Contains(
- "The given instance is not a valid message mutator. Implement one of the following mutator interfaces: NServiceBus.MessageMutator.IMutateIncomingMessages, NServiceBus.MessageMutator.IMutateIncomingTransportMessages, NServiceBus.MessageMutator.IMutateOutgoingMessages or NServiceBus.MessageMutator.IMutateOutgoingTransportMessages",
- exception.Message);
+ Assert.That(
+ exception.Message,
+ Does.Contain("The given instance is not a valid message mutator. Implement one of the following mutator interfaces: NServiceBus.MessageMutator.IMutateIncomingMessages, NServiceBus.MessageMutator.IMutateIncomingTransportMessages, NServiceBus.MessageMutator.IMutateOutgoingMessages or NServiceBus.MessageMutator.IMutateOutgoingTransportMessages"));
}
[TestCase(typeof(IncomingMessageMutator))]
@@ -47,22 +47,22 @@ public void Should_only_invoke_instances_once_even_if_registered_multiple_times(
if (mutatorType == typeof(IncomingMessageMutator))
{
- Assert.AreEqual(1, registry.IncomingMessage.Count);
+ Assert.That(registry.IncomingMessage.Count, Is.EqualTo(1));
}
if (mutatorType == typeof(IncomingTransportMessageMutator))
{
- Assert.AreEqual(1, registry.IncomingTransportMessage.Count);
+ Assert.That(registry.IncomingTransportMessage.Count, Is.EqualTo(1));
}
if (mutatorType == typeof(OutgoingMessageMutator))
{
- Assert.AreEqual(1, registry.OutgoingMessage.Count);
+ Assert.That(registry.OutgoingMessage.Count, Is.EqualTo(1));
}
if (mutatorType == typeof(OutgoingTransportMessageMutator))
{
- Assert.AreEqual(1, registry.OutgoingTransportMessage.Count);
+ Assert.That(registry.OutgoingTransportMessage.Count, Is.EqualTo(1));
}
}
diff --git a/src/NServiceBus.Core.Tests/MessageSessionTests.cs b/src/NServiceBus.Core.Tests/MessageSessionTests.cs
index 9896d4cfb60..26ad11081af 100644
--- a/src/NServiceBus.Core.Tests/MessageSessionTests.cs
+++ b/src/NServiceBus.Core.Tests/MessageSessionTests.cs
@@ -32,7 +32,7 @@ public async Task Should_not_share_root_context_across_operations()
await session.Send(new object());
await session.Send(new object());
- Assert.IsEmpty(readValues, "writes should not leak to other pipeline invocations");
+ Assert.That(readValues, Is.Empty, "writes should not leak to other pipeline invocations");
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj b/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj
index 2c4e56c6907..64108410862 100644
--- a/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj
+++ b/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj
@@ -15,7 +15,8 @@
-
+
+
diff --git a/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityDecoratorTests.cs b/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityDecoratorTests.cs
index 99d39465462..a18be0f0eb8 100644
--- a/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityDecoratorTests.cs
+++ b/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityDecoratorTests.cs
@@ -52,8 +52,11 @@ public void PromoteHeadersToTags_should_promote_promotable_headers_to_tags()
var tags = activity.Tags.ToImmutableDictionary();
- Assert.AreEqual(2, tags.Count, "should only contain approved NServiceBus headers");
- Assert.AreEqual(headers[Headers.MessageId], tags["nservicebus.message_id"]);
- Assert.AreEqual(headers[Headers.ControlMessageHeader], tags["nservicebus.control_message"]);
+ Assert.That(tags.Count, Is.EqualTo(2), "should only contain approved NServiceBus headers");
+ Assert.Multiple(() =>
+ {
+ Assert.That(tags["nservicebus.message_id"], Is.EqualTo(headers[Headers.MessageId]));
+ Assert.That(tags["nservicebus.control_message"], Is.EqualTo(headers[Headers.ControlMessageHeader]));
+ });
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityExtensionsTests.cs b/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityExtensionsTests.cs
index f737e4f4987..a0549ba7db6 100644
--- a/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityExtensionsTests.cs
+++ b/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityExtensionsTests.cs
@@ -14,8 +14,11 @@ public void TryGetRecordingPipelineActivity_should_return_false_when_key_not_fou
ambientActivity.Start();
var contextBag = new ContextBag();
- Assert.IsFalse(contextBag.TryGetRecordingOutgoingPipelineActivity(out var activity));
- Assert.IsNull(activity);
+ Assert.Multiple(() =>
+ {
+ Assert.That(contextBag.TryGetRecordingOutgoingPipelineActivity(out var activity), Is.False);
+ Assert.That(activity, Is.Null);
+ });
}
[Test]
@@ -27,8 +30,11 @@ public void TryGetRecordingPipelineActivity_should_return_false_when_value_null(
var contextBag = new ContextBag();
contextBag.SetOutgoingPipelineActitvity(null);
- Assert.IsFalse(contextBag.TryGetRecordingOutgoingPipelineActivity(out var activity));
- Assert.IsNull(activity);
+ Assert.Multiple(() =>
+ {
+ Assert.That(contextBag.TryGetRecordingOutgoingPipelineActivity(out var activity), Is.False);
+ Assert.That(activity, Is.Null);
+ });
}
[Test]
@@ -43,7 +49,10 @@ public void TryGetRecordingPipelineActivity_should_return_false_when_not_recordi
var contextBag = new ContextBag();
contextBag.SetOutgoingPipelineActitvity(recordingActivity);
- Assert.IsTrue(contextBag.TryGetRecordingOutgoingPipelineActivity(out var activity));
- Assert.AreEqual(recordingActivity, activity);
+ Assert.Multiple(() =>
+ {
+ Assert.That(contextBag.TryGetRecordingOutgoingPipelineActivity(out var activity), Is.True);
+ Assert.That(activity, Is.EqualTo(recordingActivity));
+ });
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityFactoryTests.cs b/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityFactoryTests.cs
index dca19ddcd12..73d5d97a7ae 100644
--- a/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityFactoryTests.cs
+++ b/src/NServiceBus.Core.Tests/OpenTelemetry/ActivityFactoryTests.cs
@@ -44,9 +44,12 @@ public void Should_attach_to_context_activity_when_activity_on_context()
var activity = activityFactory.StartIncomingPipelineActivity(CreateMessageContext(contextBag: contextBag));
- Assert.NotNull(activity, "should create activity for receive pipeline");
- Assert.AreEqual(contextActivity.Id, activity.ParentId, "should use context activity as parent");
- Assert.AreEqual(0, activity.Links.Count(), "should not link to logical send span");
+ Assert.That(activity, Is.Not.Null, "should create activity for receive pipeline");
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.ParentId, Is.EqualTo(contextActivity.Id), "should use context activity as parent");
+ Assert.That(activity.Links.Count(), Is.EqualTo(0), "should not link to logical send span");
+ });
}
[Test]
@@ -62,11 +65,14 @@ public void Should_attach_to_context_activity_when_activity_on_context_and_trace
var activity = activityFactory.StartIncomingPipelineActivity(CreateMessageContext(messageHeaders, contextBag));
- Assert.NotNull(activity, "should create activity for receive pipeline");
- Assert.AreEqual(contextActivity.Id, activity.ParentId, "should use context activity as parent");
- Assert.AreEqual(1, activity.Links.Count(), "should link to logical send span");
- Assert.AreEqual(sendActivity.TraceId, activity.Links.Single().Context.TraceId);
- Assert.AreEqual(sendActivity.SpanId, activity.Links.Single().Context.SpanId);
+ Assert.That(activity, Is.Not.Null, "should create activity for receive pipeline");
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.ParentId, Is.EqualTo(contextActivity.Id), "should use context activity as parent");
+ Assert.That(activity.Links.Count(), Is.EqualTo(1), "should link to logical send span");
+ Assert.That(activity.Links.Single().Context.TraceId, Is.EqualTo(sendActivity.TraceId));
+ Assert.That(activity.Links.Single().Context.SpanId, Is.EqualTo(sendActivity.SpanId));
+ });
}
[Test]
@@ -77,28 +83,31 @@ public void Should_attach_to_context_activity_when_activity_on_context_and_ambie
contextBag.Set(contextActivity);
using var ambientActivity = ActivitySources.Main.StartActivity("ambient activity");
- Assert.AreEqual(ambientActivity, Activity.Current);
+ Assert.That(Activity.Current, Is.EqualTo(ambientActivity));
var activity = activityFactory.StartIncomingPipelineActivity(CreateMessageContext(contextBag: contextBag));
- Assert.NotNull(activity, "should create activity for receive pipeline");
- Assert.AreEqual(contextActivity.Id, activity.ParentId, "should use context activity as parent");
+ Assert.That(activity, Is.Not.Null, "should create activity for receive pipeline");
+ Assert.That(activity.ParentId, Is.EqualTo(contextActivity.Id), "should use context activity as parent");
}
[Test]
public void Should_start_new_trace_when_activity_on_context_uses_legacy_id_format()
{
using var contextActivity = CreateCompletedActivity("transport receive activity", ActivityIdFormat.Hierarchical);
- Assert.AreEqual(ActivityIdFormat.Hierarchical, contextActivity.IdFormat);
+ Assert.That(contextActivity.IdFormat, Is.EqualTo(ActivityIdFormat.Hierarchical));
var contextBag = new ContextBag();
contextBag.Set(contextActivity);
var activity = activityFactory.StartIncomingPipelineActivity(CreateMessageContext(contextBag: contextBag));
- Assert.NotNull(activity, "should create activity for receive pipeline");
- Assert.IsNull(activity.ParentId, "should create a new trace");
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
+ Assert.That(activity, Is.Not.Null, "should create activity for receive pipeline");
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.ParentId, Is.Null, "should create a new trace");
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ });
}
[Test]
@@ -110,9 +119,12 @@ public void Should_attach_to_header_trace_when_no_activity_on_context_and_trace_
var activity = activityFactory.StartIncomingPipelineActivity(CreateMessageContext(messageHeaders));
- Assert.NotNull(activity, "should create activity for receive pipeline");
- Assert.AreEqual(sendActivity.Id, activity.ParentId);
- Assert.AreEqual(0, activity.Links.Count(), "should not link to logical send span");
+ Assert.That(activity, Is.Not.Null, "should create activity for receive pipeline");
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.ParentId, Is.EqualTo(sendActivity.Id));
+ Assert.That(activity.Links.Count(), Is.EqualTo(0), "should not link to logical send span");
+ });
}
[TestCase(ActivityIdFormat.W3C)]
@@ -125,9 +137,12 @@ public void Should_attach_to_ambient_trace_when_no_activity_on_context_and_no_tr
var activity = activityFactory.StartIncomingPipelineActivity(CreateMessageContext());
- Assert.NotNull(activity, "should create activity for receive pipeline");
- Assert.AreEqual(ambientActivity.Id, activity.ParentId, "should attach to ambient activity");
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
+ Assert.That(activity, Is.Not.Null, "should create activity for receive pipeline");
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.ParentId, Is.EqualTo(ambientActivity.Id), "should attach to ambient activity");
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ });
}
[Test]
@@ -135,9 +150,12 @@ public void Should_start_new_trace_when_no_activity_on_context_and_no_trace_mess
{
var activity = activityFactory.StartIncomingPipelineActivity(CreateMessageContext());
- Assert.NotNull(activity, "should create activity for receive pipeline");
- Assert.IsNull(activity.ParentId, "should start a new trace");
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
+ Assert.That(activity, Is.Not.Null, "should create activity for receive pipeline");
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.ParentId, Is.Null, "should start a new trace");
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ });
}
[Test]
@@ -147,9 +165,12 @@ public void Should_start_new_trace_when_trace_header_contains_invalid_data()
var activity = activityFactory.StartIncomingPipelineActivity(CreateMessageContext(messageHeaders));
- Assert.NotNull(activity, "should create activity for receive pipeline");
- Assert.IsNull(activity.ParentId, "should start new trace");
- Assert.AreEqual(0, activity.Links.Count(), "should not link to logical send span");
+ Assert.That(activity, Is.Not.Null, "should create activity for receive pipeline");
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.ParentId, Is.Null, "should start new trace");
+ Assert.That(activity.Links.Count(), Is.EqualTo(0), "should not link to logical send span");
+ });
}
[Test]
@@ -159,7 +180,7 @@ public void Should_add_native_message_id_tag()
var activity = activityFactory.StartIncomingPipelineActivity(messageContext);
- Assert.AreEqual(messageContext.NativeMessageId, activity.Tags.ToImmutableDictionary()["nservicebus.native_message_id"]);
+ Assert.That(activity.Tags.ToImmutableDictionary()["nservicebus.native_message_id"], Is.EqualTo(messageContext.NativeMessageId));
}
static Activity CreateCompletedActivity(string activityName, ActivityIdFormat idFormat = ActivityIdFormat.W3C)
@@ -193,7 +214,7 @@ public void Should_attach_ambient_activity()
var activity = activityFactory.StartOutgoingPipelineActivity("activityName", "activityDisplayName", new FakeRootContext());
- Assert.AreEqual(ambientActivity.Id, activity.ParentId);
+ Assert.That(activity.ParentId, Is.EqualTo(ambientActivity.Id));
}
[Test]
@@ -205,8 +226,11 @@ public void Should_always_create_a_w3c_id()
var activity = activityFactory.StartOutgoingPipelineActivity("activityName", "activityDisplayName", new FakeRootContext());
- Assert.AreEqual(ambientActivity.Id, activity.ParentId);
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.ParentId, Is.EqualTo(ambientActivity.Id));
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ });
}
[Test]
@@ -215,7 +239,7 @@ public void Should_set_activity_in_context()
var context = new FakeRootContext();
activityFactory.StartOutgoingPipelineActivity("activityName", "activityDisplayName", context);
- Assert.IsNotNull(context.Extensions.Get(ActivityExtensions.OutgoingActivityKey));
+ Assert.That(context.Extensions.Get(ActivityExtensions.OutgoingActivityKey), Is.Not.Null);
}
}
@@ -227,7 +251,7 @@ public void Should_not_start_activity_when_no_parent_activity_exists()
Type handlerType = typeof(StartHandlerActivity);
var activity = activityFactory.StartHandlerActivity(new MessageHandler((_, _, _) => Task.CompletedTask, handlerType), null);
- Assert.IsNull(activity, "should not start handler activity when no parent activity exists");
+ Assert.That(activity, Is.Null, "should not start handler activity when no parent activity exists");
}
[Test]
@@ -240,9 +264,9 @@ public void Should_set_handler_type_as_tag()
var activity = activityFactory.StartHandlerActivity(new MessageHandler((_, _, _) => Task.CompletedTask, handlerType), null);
- Assert.IsNotNull(activity);
+ Assert.That(activity, Is.Not.Null);
var tags = activity.Tags.ToImmutableDictionary();
- Assert.AreEqual(handlerType.FullName, tags[ActivityTags.HandlerType]);
+ Assert.That(tags[ActivityTags.HandlerType], Is.EqualTo(handlerType.FullName));
}
[Test]
@@ -255,10 +279,10 @@ public void Should_set_saga_id_when_saga()
var activity = activityFactory.StartHandlerActivity(new MessageHandler((_, _, _) => Task.CompletedTask, typeof(StartHandlerActivity)), sagaInstance);
- Assert.IsNotNull(activity);
+ Assert.That(activity, Is.Not.Null);
var tags = activity.Tags.ToImmutableDictionary();
- Assert.AreEqual(sagaInstance.SagaId, tags[ActivityTags.HandlerSagaId]);
+ Assert.That(tags[ActivityTags.HandlerSagaId], Is.EqualTo(sagaInstance.SagaId));
}
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/OpenTelemetry/ContextPropagationTests.cs b/src/NServiceBus.Core.Tests/OpenTelemetry/ContextPropagationTests.cs
index 57bf9d3e73c..cdefaac5700 100644
--- a/src/NServiceBus.Core.Tests/OpenTelemetry/ContextPropagationTests.cs
+++ b/src/NServiceBus.Core.Tests/OpenTelemetry/ContextPropagationTests.cs
@@ -22,7 +22,7 @@ public void Propagate_activity_id_to_header()
ContextPropagation.PropagateContextToHeaders(activity, headers, new ContextBag());
- Assert.AreEqual(headers[Headers.DiagnosticsTraceParent], activity.Id);
+ Assert.That(activity.Id, Is.EqualTo(headers[Headers.DiagnosticsTraceParent]));
}
[Test]
@@ -32,7 +32,7 @@ public void Should_not_set_header_without_activity()
ContextPropagation.PropagateContextToHeaders(null, headers, new ContextBag());
- Assert.IsEmpty(headers);
+ Assert.That(headers, Is.Empty);
}
[Test]
@@ -47,8 +47,11 @@ public void Should_set_start_new_trace_header_when_adding_trace_parent_header()
contextBag.Set(Headers.StartNewTrace, bool.TrueString);
ContextPropagation.PropagateContextToHeaders(activity, headers, contextBag);
- Assert.IsTrue(headers.ContainsKey(Headers.StartNewTrace), bool.TrueString);
- Assert.AreEqual(headers[Headers.StartNewTrace], bool.TrueString);
+ Assert.Multiple(() =>
+ {
+ Assert.That(headers.ContainsKey(Headers.StartNewTrace), Is.True, bool.TrueString);
+ Assert.That(bool.TrueString, Is.EqualTo(headers[Headers.StartNewTrace]));
+ });
}
[Test]
@@ -59,7 +62,7 @@ public void Should_not_set_start_new_trace_header_when_no_trace_parent_header_is
contextBag.Set(Headers.StartNewTrace, bool.TrueString);
ContextPropagation.PropagateContextToHeaders(null, headers, contextBag);
- Assert.IsFalse(headers.ContainsKey(Headers.StartNewTrace));
+ Assert.That(headers.ContainsKey(Headers.StartNewTrace), Is.False);
}
[Test]
@@ -76,13 +79,13 @@ public void Overwrites_existing_propagation_header()
ContextPropagation.PropagateContextToHeaders(activity, headers, new ContextBag());
- Assert.AreEqual(headers[Headers.DiagnosticsTraceParent], activity.Id);
+ Assert.That(activity.Id, Is.EqualTo(headers[Headers.DiagnosticsTraceParent]));
}
[TestCaseSource(nameof(TestCases))]
public void Can_propagate_baggage_from_header_to_activity(ContextPropagationTestCase testCase)
{
- TestContext.WriteLine($"Baggage header: {testCase.BaggageHeaderValue}");
+ TestContext.Out.WriteLine($"Baggage header: {testCase.BaggageHeaderValue}");
var headers = new Dictionary();
@@ -99,15 +102,15 @@ public void Can_propagate_baggage_from_header_to_activity(ContextPropagationTest
{
var key = baggageItem.Key;
var actualValue = activity.GetBaggageItem(key);
- Assert.IsNotNull(actualValue, $"Baggage is missing item with key |{key}|");
- Assert.AreEqual(baggageItem.Value, actualValue, $"Baggage item |{key}| has the wrong value");
+ Assert.That(actualValue, Is.Not.Null, $"Baggage is missing item with key |{key}|");
+ Assert.That(actualValue, Is.EqualTo(baggageItem.Value), $"Baggage item |{key}| has the wrong value");
}
}
[TestCaseSource(nameof(TestCases))]
public void Can_propagate_baggage_from_activity_to_header(ContextPropagationTestCase testCase)
{
- TestContext.WriteLine($"Baggage header: {testCase.BaggageHeaderValue}");
+ TestContext.Out.WriteLine($"Baggage header: {testCase.BaggageHeaderValue}");
var headers = new Dictionary();
@@ -124,20 +127,23 @@ public void Can_propagate_baggage_from_activity_to_header(ContextPropagationTest
if (testCase.HasBaggage)
{
- Assert.IsTrue(baggageHeaderSet, "Should have a baggage header if there is baggage");
+ Assert.Multiple(() =>
+ {
+ Assert.That(baggageHeaderSet, Is.True, "Should have a baggage header if there is baggage");
- Assert.AreEqual(testCase.BaggageHeaderValueWithoutOptionalWhitespace, baggageValue, "baggage header is set but is not correct");
+ Assert.That(baggageValue, Is.EqualTo(testCase.BaggageHeaderValueWithoutOptionalWhitespace), "baggage header is set but is not correct");
+ });
}
else
{
- Assert.IsFalse(baggageHeaderSet, "baggage header should not be set if there is no baggage");
+ Assert.That(baggageHeaderSet, Is.False, "baggage header should not be set if there is no baggage");
}
}
[TestCaseSource(nameof(TestCases))]
public void Can_roundtrip_baggage(ContextPropagationTestCase testCase)
{
- TestContext.WriteLine($"Baggage header: {testCase.BaggageHeaderValue}");
+ TestContext.Out.WriteLine($"Baggage header: {testCase.BaggageHeaderValue}");
var outgoingHeaders = new Dictionary();
var outgoingActivity = new Activity(ActivityNames.OutgoingMessageActivityName);
@@ -159,8 +165,8 @@ public void Can_roundtrip_baggage(ContextPropagationTestCase testCase)
{
var key = baggageItem.Key;
var actualValue = incomingActivity.GetBaggageItem(key);
- Assert.IsNotNull(actualValue, $"Baggage is missing item with key |{key}|");
- Assert.AreEqual(baggageItem.Value, actualValue, $"Baggage item |{key}| has the wrong value");
+ Assert.That(actualValue, Is.Not.Null, $"Baggage is missing item with key |{key}|");
+ Assert.That(actualValue, Is.EqualTo(baggageItem.Value), $"Baggage item |{key}| has the wrong value");
}
}
diff --git a/src/NServiceBus.Core.Tests/OpenTelemetry/Helpers/TestingMetricListener.cs b/src/NServiceBus.Core.Tests/OpenTelemetry/Helpers/TestingMetricListener.cs
index a03c8ff6cd1..0268b0aaa25 100644
--- a/src/NServiceBus.Core.Tests/OpenTelemetry/Helpers/TestingMetricListener.cs
+++ b/src/NServiceBus.Core.Tests/OpenTelemetry/Helpers/TestingMetricListener.cs
@@ -22,7 +22,7 @@ public TestingMetricListener(string sourceName)
{
if (instrument.Meter.Name == sourceName)
{
- TestContext.WriteLine($"Subscribing to {instrument.Meter.Name}\\{instrument.Name}");
+ TestContext.Out.WriteLine($"Subscribing to {instrument.Meter.Name}\\{instrument.Name}");
listener.EnableMeasurementEvents(instrument);
metrics.Add(instrument);
version = instrument.Meter.Version;
@@ -36,7 +36,7 @@ public TestingMetricListener(string sourceName)
ReadOnlySpan> t,
object _) =>
{
- TestContext.WriteLine($"{instrument.Meter.Name}\\{instrument.Name}:{measurement}");
+ TestContext.Out.WriteLine($"{instrument.Meter.Name}\\{instrument.Name}:{measurement}");
var tags = t.ToArray();
ReportedMeters.AddOrUpdate(instrument.Name, measurement, (_, val) => val + measurement);
@@ -63,12 +63,15 @@ public void AssertMetric(string metricName, long expected)
{
if (expected == 0)
{
- Assert.False(ReportedMeters.ContainsKey(metricName), $"Should not have '{metricName}' metric reported.");
+ Assert.That(ReportedMeters.ContainsKey(metricName), Is.False, $"Should not have '{metricName}' metric reported.");
}
else
{
- Assert.True(ReportedMeters.ContainsKey(metricName), $"'{metricName}' metric was not reported.");
- Assert.AreEqual(expected, ReportedMeters[metricName]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ReportedMeters.ContainsKey(metricName), Is.True, $"'{metricName}' metric was not reported.");
+ Assert.That(ReportedMeters[metricName], Is.EqualTo(expected));
+ });
}
}
diff --git a/src/NServiceBus.Core.Tests/OpenTelemetry/MessageOperationsTests.cs b/src/NServiceBus.Core.Tests/OpenTelemetry/MessageOperationsTests.cs
index 9ab8cd6b7e5..0c5621cb3ae 100644
--- a/src/NServiceBus.Core.Tests/OpenTelemetry/MessageOperationsTests.cs
+++ b/src/NServiceBus.Core.Tests/OpenTelemetry/MessageOperationsTests.cs
@@ -37,15 +37,18 @@ public async Task Send_should_create_span()
await operations.Send(new FakeRootContext(), new object(), new SendOptions());
- Assert.IsNotNull(activity);
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
- Assert.AreEqual(ActivityStatusCode.Ok, activity.Status);
- Assert.AreEqual(activity.RootId, activity.TraceId.ToString());
+ Assert.That(activity, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ Assert.That(activity.Status, Is.EqualTo(ActivityStatusCode.Ok));
+ Assert.That(activity.TraceId.ToString(), Is.EqualTo(activity.RootId));
- Assert.AreEqual(ActivityNames.OutgoingMessageActivityName, activity.OperationName);
- Assert.AreEqual("send message", activity.DisplayName);
+ Assert.That(activity.OperationName, Is.EqualTo(ActivityNames.OutgoingMessageActivityName));
+ Assert.That(activity.DisplayName, Is.EqualTo("send message"));
- Assert.AreEqual(activity, operations.SendPipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey));
+ Assert.That(operations.SendPipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey), Is.EqualTo(activity));
+ });
}
[Test]
@@ -60,15 +63,18 @@ public async Task Publish_should_create_span()
await operations.Publish(new FakeRootContext(), new object(), new PublishOptions());
- Assert.IsNotNull(activity);
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
- Assert.AreEqual(ActivityStatusCode.Ok, activity.Status);
- Assert.AreEqual(activity.RootId, activity.TraceId.ToString());
+ Assert.That(activity, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ Assert.That(activity.Status, Is.EqualTo(ActivityStatusCode.Ok));
+ Assert.That(activity.TraceId.ToString(), Is.EqualTo(activity.RootId));
- Assert.AreEqual(ActivityNames.OutgoingEventActivityName, activity.OperationName);
- Assert.AreEqual("publish event", activity.DisplayName);
+ Assert.That(activity.OperationName, Is.EqualTo(ActivityNames.OutgoingEventActivityName));
+ Assert.That(activity.DisplayName, Is.EqualTo("publish event"));
- Assert.AreEqual(activity, operations.PublishPipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey));
+ Assert.That(operations.PublishPipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey), Is.EqualTo(activity));
+ });
}
[Test]
@@ -83,15 +89,18 @@ public async Task Reply_should_create_span()
await operations.Reply(new FakeRootContext(), new object(), new ReplyOptions());
- Assert.IsNotNull(activity);
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
- Assert.AreEqual(ActivityStatusCode.Ok, activity.Status);
- Assert.AreEqual(activity.RootId, activity.TraceId.ToString());
+ Assert.That(activity, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ Assert.That(activity.Status, Is.EqualTo(ActivityStatusCode.Ok));
+ Assert.That(activity.TraceId.ToString(), Is.EqualTo(activity.RootId));
- Assert.AreEqual(ActivityNames.OutgoingMessageActivityName, activity.OperationName);
- Assert.AreEqual("reply", activity.DisplayName);
+ Assert.That(activity.OperationName, Is.EqualTo(ActivityNames.OutgoingMessageActivityName));
+ Assert.That(activity.DisplayName, Is.EqualTo("reply"));
- Assert.AreEqual(activity, operations.ReplyPipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey));
+ Assert.That(operations.ReplyPipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey), Is.EqualTo(activity));
+ });
}
[Test]
@@ -106,15 +115,18 @@ public async Task Subscribe_should_create_span()
await operations.Subscribe(new FakeRootContext(), typeof(object), new SubscribeOptions());
- Assert.IsNotNull(activity);
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
- Assert.AreEqual(ActivityStatusCode.Ok, activity.Status);
- Assert.AreEqual(activity.RootId, activity.TraceId.ToString());
+ Assert.That(activity, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ Assert.That(activity.Status, Is.EqualTo(ActivityStatusCode.Ok));
+ Assert.That(activity.TraceId.ToString(), Is.EqualTo(activity.RootId));
- Assert.AreEqual(ActivityNames.SubscribeActivityName, activity.OperationName);
- Assert.AreEqual("subscribe event", activity.DisplayName);
+ Assert.That(activity.OperationName, Is.EqualTo(ActivityNames.SubscribeActivityName));
+ Assert.That(activity.DisplayName, Is.EqualTo("subscribe event"));
- Assert.AreEqual(activity, operations.SubscribePipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey));
+ Assert.That(operations.SubscribePipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey), Is.EqualTo(activity));
+ });
}
[Test]
@@ -129,15 +141,18 @@ public async Task Unsubscribe_should_create_span()
await operations.Unsubscribe(new FakeRootContext(), typeof(object), new UnsubscribeOptions());
- Assert.IsNotNull(activity);
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
- Assert.AreEqual(ActivityStatusCode.Ok, activity.Status);
- Assert.AreEqual(activity.RootId, activity.TraceId.ToString());
+ Assert.That(activity, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ Assert.That(activity.Status, Is.EqualTo(ActivityStatusCode.Ok));
+ Assert.That(activity.TraceId.ToString(), Is.EqualTo(activity.RootId));
- Assert.AreEqual(ActivityNames.UnsubscribeActivityName, activity.OperationName);
- Assert.AreEqual("unsubscribe event", activity.DisplayName);
+ Assert.That(activity.OperationName, Is.EqualTo(ActivityNames.UnsubscribeActivityName));
+ Assert.That(activity.DisplayName, Is.EqualTo("unsubscribe event"));
- Assert.AreEqual(activity, operations.UnsubscribePipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey));
+ Assert.That(operations.UnsubscribePipeline.LastContext.Extensions.Get(ActivityExtensions.OutgoingActivityKey), Is.EqualTo(activity));
+ });
}
[Test]
@@ -153,10 +168,13 @@ public void Should_set_span_error_state_on_failure()
var ex = Assert.ThrowsAsync(async () => await operations.Send(new FakeRootContext(), new object(), new SendOptions()));
- Assert.AreEqual(ActivityStatusCode.Error, activity.Status);
+ Assert.That(activity.Status, Is.EqualTo(ActivityStatusCode.Error));
var tags = activity.Tags.ToImmutableDictionary();
- Assert.AreEqual("ERROR", tags["otel.status_code"]);
- Assert.AreEqual(ex.Message, tags["otel.status_description"]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(tags["otel.status_code"], Is.EqualTo("ERROR"));
+ Assert.That(tags["otel.status_description"], Is.EqualTo(ex.Message));
+ });
}
[Test]
@@ -172,13 +190,16 @@ public async Task Should_always_create_w3c_id_span()
using var ambientActivity = new Activity("ambient activity");
ambientActivity.SetIdFormat(ActivityIdFormat.Hierarchical);
ambientActivity.Start();
- Assert.AreEqual(ambientActivity.IdFormat, ActivityIdFormat.Hierarchical);
+ Assert.That(ambientActivity.IdFormat, Is.EqualTo(ActivityIdFormat.Hierarchical));
await operations.Send(new FakeRootContext(), new object(), new SendOptions());
- Assert.IsNotNull(activity);
- Assert.AreEqual(ActivityIdFormat.W3C, activity.IdFormat);
- Assert.AreEqual(ambientActivity.Id, activity.ParentId);
- Assert.AreNotEqual(ambientActivity.TraceId, activity.TraceId);
+ Assert.That(activity, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(activity.IdFormat, Is.EqualTo(ActivityIdFormat.W3C));
+ Assert.That(activity.ParentId, Is.EqualTo(ambientActivity.Id));
+ Assert.That(activity.TraceId, Is.Not.EqualTo(ambientActivity.TraceId));
+ });
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/OpenTelemetry/TracingExtensionsTests.cs b/src/NServiceBus.Core.Tests/OpenTelemetry/TracingExtensionsTests.cs
index 6b2c06ee34f..19b81ef54ea 100644
--- a/src/NServiceBus.Core.Tests/OpenTelemetry/TracingExtensionsTests.cs
+++ b/src/NServiceBus.Core.Tests/OpenTelemetry/TracingExtensionsTests.cs
@@ -23,7 +23,7 @@ public async Task Invoke_should_invoke_pipeline_when_activity_null()
await pipeline.Invoke(new FakeRootContext(), null);
- Assert.IsTrue(invokedPipeline);
+ Assert.That(invokedPipeline, Is.True);
}
[Test]
@@ -35,7 +35,7 @@ public async Task Invoke_should_set_success_status_when_no_exception()
await pipeline.Invoke(new FakeRootContext(), activity);
- Assert.AreEqual(ActivityStatusCode.Ok, activity.Status);
+ Assert.That(activity.Status, Is.EqualTo(ActivityStatusCode.Ok));
}
[Test]
@@ -48,14 +48,17 @@ public void Invoke_should_set_error_status_and_tags_when_exception()
Assert.ThrowsAsync(() => pipeline.Invoke(new FakeRootContext(), activity));
- Assert.AreEqual(ActivityStatusCode.Error, activity.Status);
+ Assert.That(activity.Status, Is.EqualTo(ActivityStatusCode.Error));
var tags = activity.Tags.ToImmutableDictionary();
- Assert.AreEqual("ERROR", tags["otel.status_code"]);
- Assert.AreEqual(exception.Message, tags["otel.status_description"]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(tags["otel.status_code"], Is.EqualTo("ERROR"));
+ Assert.That(tags["otel.status_description"], Is.EqualTo(exception.Message));
+ });
var errorEvent = activity.Events.Single();
- Assert.AreEqual("exception", errorEvent.Name);
+ Assert.That(errorEvent.Name, Is.EqualTo("exception"));
}
class FakePipeline : IPipeline
diff --git a/src/NServiceBus.Core.Tests/Performance/TimeToBeReceived/TimeToBeReceivedAttributeTests.cs b/src/NServiceBus.Core.Tests/Performance/TimeToBeReceived/TimeToBeReceivedAttributeTests.cs
index 5410494228d..250513c0cd6 100644
--- a/src/NServiceBus.Core.Tests/Performance/TimeToBeReceived/TimeToBeReceivedAttributeTests.cs
+++ b/src/NServiceBus.Core.Tests/Performance/TimeToBeReceived/TimeToBeReceivedAttributeTests.cs
@@ -13,8 +13,11 @@ public void Should_use_TimeToBeReceived_from_bottom_of_tree_when_initialized()
typeof(InheritedClassWithAttribute)
}, TimeToBeReceivedMappings.DefaultConvention, true);
- Assert.True(mappings.TryGetTimeToBeReceived(typeof(InheritedClassWithAttribute), out var timeToBeReceived));
- Assert.AreEqual(TimeSpan.FromSeconds(2), timeToBeReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(mappings.TryGetTimeToBeReceived(typeof(InheritedClassWithAttribute), out var timeToBeReceived), Is.True);
+ Assert.That(timeToBeReceived, Is.EqualTo(TimeSpan.FromSeconds(2)));
+ });
}
[Test]
@@ -25,8 +28,11 @@ public void Should_use_inherited_TimeToBeReceived_when_initialized()
typeof(InheritedClassWithNoAttribute)
}, TimeToBeReceivedMappings.DefaultConvention, true);
- Assert.True(mappings.TryGetTimeToBeReceived(typeof(InheritedClassWithNoAttribute), out var timeToBeReceived));
- Assert.AreEqual(TimeSpan.FromSeconds(1), timeToBeReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(mappings.TryGetTimeToBeReceived(typeof(InheritedClassWithNoAttribute), out var timeToBeReceived), Is.True);
+ Assert.That(timeToBeReceived, Is.EqualTo(TimeSpan.FromSeconds(1)));
+ });
}
[Test]
@@ -43,8 +49,11 @@ public void Should_use_TimeToBeReceived_from_bottom_of_tree_when_tryget()
{
var mappings = new TimeToBeReceivedMappings(Array.Empty(), TimeToBeReceivedMappings.DefaultConvention, true);
- Assert.True(mappings.TryGetTimeToBeReceived(typeof(InheritedClassWithAttribute), out var timeToBeReceived));
- Assert.AreEqual(TimeSpan.FromSeconds(2), timeToBeReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(mappings.TryGetTimeToBeReceived(typeof(InheritedClassWithAttribute), out var timeToBeReceived), Is.True);
+ Assert.That(timeToBeReceived, Is.EqualTo(TimeSpan.FromSeconds(2)));
+ });
}
[Test]
@@ -52,8 +61,11 @@ public void Should_use_inherited_TimeToBeReceived_when_tryget()
{
var mappings = new TimeToBeReceivedMappings(Array.Empty(), TimeToBeReceivedMappings.DefaultConvention, true);
- Assert.True(mappings.TryGetTimeToBeReceived(typeof(InheritedClassWithNoAttribute), out var timeToBeReceived));
- Assert.AreEqual(TimeSpan.FromSeconds(1), timeToBeReceived);
+ Assert.Multiple(() =>
+ {
+ Assert.That(mappings.TryGetTimeToBeReceived(typeof(InheritedClassWithNoAttribute), out var timeToBeReceived), Is.True);
+ Assert.That(timeToBeReceived, Is.EqualTo(TimeSpan.FromSeconds(1)));
+ });
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/Persistence/PersistenceStartupTests.cs b/src/NServiceBus.Core.Tests/Persistence/PersistenceStartupTests.cs
index e4e6b3f61cc..ebf9f69f983 100644
--- a/src/NServiceBus.Core.Tests/Persistence/PersistenceStartupTests.cs
+++ b/src/NServiceBus.Core.Tests/Persistence/PersistenceStartupTests.cs
@@ -16,7 +16,7 @@ public void Should_return_false_when_checking_if_persistence_supports_storage_ty
var supported = PersistenceStartup.HasSupportFor(settings);
- Assert.IsFalse(supported);
+ Assert.That(supported, Is.False);
}
}
diff --git a/src/NServiceBus.Core.Tests/Persistence/PersistenceStorageMergerTests.cs b/src/NServiceBus.Core.Tests/Persistence/PersistenceStorageMergerTests.cs
index 401f16e6303..01983883b82 100644
--- a/src/NServiceBus.Core.Tests/Persistence/PersistenceStorageMergerTests.cs
+++ b/src/NServiceBus.Core.Tests/Persistence/PersistenceStorageMergerTests.cs
@@ -46,10 +46,13 @@ public void Should_replace_default_storages_by_overrides()
var resultedEnabledPersistences = PersistenceStorageMerger.Merge(persistences, config.Settings);
- Assert.That(resultedEnabledPersistences[0].SelectedStorages, Is.EquivalentTo(
- new List { typeof(StorageType.Subscriptions) }));
- Assert.That(resultedEnabledPersistences[1].SelectedStorages, Is.EquivalentTo(
- new List { typeof(StorageType.Sagas) }));
+ Assert.Multiple(() =>
+ {
+ Assert.That(resultedEnabledPersistences[0].SelectedStorages, Is.EquivalentTo(
+ new List { typeof(StorageType.Subscriptions) }));
+ Assert.That(resultedEnabledPersistences[1].SelectedStorages, Is.EquivalentTo(
+ new List { typeof(StorageType.Sagas) }));
+ });
}
class FakePersistence2 : PersistenceDefinition
@@ -84,7 +87,7 @@ public void Should_not_use_other_supported_storages()
var resultedEnabledPersistences = PersistenceStorageMerger.Merge(persistences, config.Settings);
- Assert.IsFalse(resultedEnabledPersistences.Any(p => p.SelectedStorages.Contains(typeof(StorageType.Subscriptions))));
+ Assert.That(resultedEnabledPersistences.Any(p => p.SelectedStorages.Contains(typeof(StorageType.Subscriptions))), Is.False);
}
class FakePersistence : PersistenceDefinition
diff --git a/src/NServiceBus.Core.Tests/Pipeline/BehaviorRegistrationsCoordinatorTests.cs b/src/NServiceBus.Core.Tests/Pipeline/BehaviorRegistrationsCoordinatorTests.cs
index 372c9c581ae..905e2edbb4e 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/BehaviorRegistrationsCoordinatorTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/BehaviorRegistrationsCoordinatorTests.cs
@@ -32,7 +32,7 @@ public void Registrations_Count()
var model = coordinator.BuildPipelineModelFor();
- Assert.AreEqual(3, model.Count);
+ Assert.That(model.Count, Is.EqualTo(3));
}
[Test]
@@ -44,9 +44,12 @@ public void Registrations_Order()
var model = coordinator.BuildPipelineModelFor().ToList();
- Assert.AreEqual("1", model[0].StepId);
- Assert.AreEqual("2", model[1].StepId);
- Assert.AreEqual("3", model[2].StepId);
+ Assert.Multiple(() =>
+ {
+ Assert.That(model[0].StepId, Is.EqualTo("1"));
+ Assert.That(model[1].StepId, Is.EqualTo("2"));
+ Assert.That(model[2].StepId, Is.EqualTo("3"));
+ });
}
[Test]
@@ -61,9 +64,12 @@ public void Registrations_Replace()
var model = coordinator.BuildPipelineModelFor().ToList();
- Assert.AreEqual(typeof(ReplacedBehavior).FullName, model[0].BehaviorType.FullName);
- Assert.AreEqual("new", model[0].Description);
- Assert.AreEqual("2", model[1].Description);
+ Assert.Multiple(() =>
+ {
+ Assert.That(model[0].BehaviorType.FullName, Is.EqualTo(typeof(ReplacedBehavior).FullName));
+ Assert.That(model[0].Description, Is.EqualTo("new"));
+ Assert.That(model[1].Description, Is.EqualTo("2"));
+ });
}
[Test]
@@ -73,9 +79,12 @@ public void Registrations_AddOrReplace_WhenDoesNotExist()
var model = coordinator.BuildPipelineModelFor().ToList();
- Assert.AreEqual(1, model.Count);
- Assert.AreEqual(typeof(ReplacedBehavior).FullName, model[0].BehaviorType.FullName);
- Assert.AreEqual("new", model[0].Description);
+ Assert.That(model.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(model[0].BehaviorType.FullName, Is.EqualTo(typeof(ReplacedBehavior).FullName));
+ Assert.That(model[0].Description, Is.EqualTo("new"));
+ });
}
[Test]
@@ -87,9 +96,12 @@ public void Registrations_AddOrReplace_WhenExists()
var model = coordinator.BuildPipelineModelFor().ToList();
- Assert.AreEqual(1, model.Count);
- Assert.AreEqual(typeof(ReplacedBehavior).FullName, model[0].BehaviorType.FullName);
- Assert.AreEqual("new", model[0].Description);
+ Assert.That(model.Count, Is.EqualTo(1));
+ Assert.Multiple(() =>
+ {
+ Assert.That(model[0].BehaviorType.FullName, Is.EqualTo(typeof(ReplacedBehavior).FullName));
+ Assert.That(model[0].Description, Is.EqualTo("new"));
+ });
}
[Test]
@@ -105,12 +117,15 @@ public void Registrations_Order_with_befores_and_afters()
var model = coordinator.BuildPipelineModelFor().ToList();
- Assert.AreEqual("1", model[0].StepId);
- Assert.AreEqual("1.5", model[1].StepId);
- Assert.AreEqual("2", model[2].StepId);
- Assert.AreEqual("2.5", model[3].StepId);
- Assert.AreEqual("3", model[4].StepId);
- Assert.AreEqual("3.5", model[5].StepId);
+ Assert.Multiple(() =>
+ {
+ Assert.That(model[0].StepId, Is.EqualTo("1"));
+ Assert.That(model[1].StepId, Is.EqualTo("1.5"));
+ Assert.That(model[2].StepId, Is.EqualTo("2"));
+ Assert.That(model[3].StepId, Is.EqualTo("2.5"));
+ Assert.That(model[4].StepId, Is.EqualTo("3"));
+ Assert.That(model[5].StepId, Is.EqualTo("3.5"));
+ });
}
[Test]
@@ -125,11 +140,14 @@ public void Registrations_Order_with_befores_only()
var model = coordinator.BuildPipelineModelFor().ToList();
- Assert.AreEqual("1", model[0].StepId);
- Assert.AreEqual("1.5", model[1].StepId);
- Assert.AreEqual("2", model[2].StepId);
- Assert.AreEqual("2.5", model[3].StepId);
- Assert.AreEqual("3", model[4].StepId);
+ Assert.Multiple(() =>
+ {
+ Assert.That(model[0].StepId, Is.EqualTo("1"));
+ Assert.That(model[1].StepId, Is.EqualTo("1.5"));
+ Assert.That(model[2].StepId, Is.EqualTo("2"));
+ Assert.That(model[3].StepId, Is.EqualTo("2.5"));
+ Assert.That(model[4].StepId, Is.EqualTo("3"));
+ });
}
[Test]
@@ -145,12 +163,15 @@ public void Registrations_Order_with_multi_afters()
var model = coordinator.BuildPipelineModelFor().ToList();
- Assert.AreEqual("1", model[0].StepId);
- Assert.AreEqual("1.5", model[1].StepId);
- Assert.AreEqual("2", model[2].StepId);
- Assert.AreEqual("2.5", model[3].StepId);
- Assert.AreEqual("3", model[4].StepId);
- Assert.AreEqual("3.5", model[5].StepId);
+ Assert.Multiple(() =>
+ {
+ Assert.That(model[0].StepId, Is.EqualTo("1"));
+ Assert.That(model[1].StepId, Is.EqualTo("1.5"));
+ Assert.That(model[2].StepId, Is.EqualTo("2"));
+ Assert.That(model[3].StepId, Is.EqualTo("2.5"));
+ Assert.That(model[4].StepId, Is.EqualTo("3"));
+ Assert.That(model[5].StepId, Is.EqualTo("3.5"));
+ });
}
[Test]
@@ -166,12 +187,15 @@ public void Registrations_Order_with_afters_only()
var model = coordinator.BuildPipelineModelFor().ToList();
- Assert.AreEqual("1", model[0].StepId);
- Assert.AreEqual("1.1", model[1].StepId);
- Assert.AreEqual("1.5", model[2].StepId);
- Assert.AreEqual("1.6", model[3].StepId);
- Assert.AreEqual("2", model[4].StepId);
- Assert.AreEqual("3", model[5].StepId);
+ Assert.Multiple(() =>
+ {
+ Assert.That(model[0].StepId, Is.EqualTo("1"));
+ Assert.That(model[1].StepId, Is.EqualTo("1.1"));
+ Assert.That(model[2].StepId, Is.EqualTo("1.5"));
+ Assert.That(model[3].StepId, Is.EqualTo("1.6"));
+ Assert.That(model[4].StepId, Is.EqualTo("2"));
+ Assert.That(model[5].StepId, Is.EqualTo("3"));
+ });
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/Pipeline/EnsureNativeBehaviors.cs b/src/NServiceBus.Core.Tests/Pipeline/EnsureNativeBehaviors.cs
index 91e9fdf9509..eeed94e346d 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/EnsureNativeBehaviors.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/EnsureNativeBehaviors.cs
@@ -23,7 +23,7 @@ public static void CoreBehaviorsMustNotUseAbstractClasses()
Console.Error.WriteLine($"Violators of {nameof(CoreBehaviorsMustNotUseAbstractClasses)}:{Environment.NewLine}{string.Join(Environment.NewLine, violators)}");
- Assert.IsEmpty(violators, $"For performance reasons, built-in behaviors are not allowed to inherit from abstract behavior classes. Implement IBehavior directly, using the same context type for both TIn and TOut.");
+ Assert.That(violators, Is.Empty, $"For performance reasons, built-in behaviors are not allowed to inherit from abstract behavior classes. Implement IBehavior directly, using the same context type for both TIn and TOut.");
}
static bool UsesAbstractClass(Type type)
diff --git a/src/NServiceBus.Core.Tests/Pipeline/HandlerTransactionScopeWrapperBehaviorTests.cs b/src/NServiceBus.Core.Tests/Pipeline/HandlerTransactionScopeWrapperBehaviorTests.cs
index b54932b6af7..018100a274e 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/HandlerTransactionScopeWrapperBehaviorTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/HandlerTransactionScopeWrapperBehaviorTests.cs
@@ -29,7 +29,7 @@ public Task ShouldWrapInnerBehaviorsIfNoAmbientExists()
return behavior.Invoke(null, ctx =>
{
- Assert.NotNull(Transaction.Current);
+ Assert.That(Transaction.Current, Is.Not.Null);
return Task.CompletedTask;
});
}
diff --git a/src/NServiceBus.Core.Tests/Pipeline/HeaderOptionExtensionsTests.cs b/src/NServiceBus.Core.Tests/Pipeline/HeaderOptionExtensionsTests.cs
index ff332a45cad..d767d59a392 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/HeaderOptionExtensionsTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/HeaderOptionExtensionsTests.cs
@@ -14,8 +14,8 @@ public void GetHeaders_Should_Return_Configured_Headers()
var result = options.GetHeaders();
- Assert.AreEqual(2, result.Count);
- CollectionAssert.Contains(result.Values, "custom header value 1");
- CollectionAssert.Contains(result.Values, "custom header value 2");
+ Assert.That(result.Count, Is.EqualTo(2));
+ Assert.That(result.Values, Has.Member("custom header value 1"));
+ Assert.That(result.Values, Has.Member("custom header value 2"));
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/Pipeline/Incoming/InvokeHandlerTerminatorTest.cs b/src/NServiceBus.Core.Tests/Pipeline/Incoming/InvokeHandlerTerminatorTest.cs
index f1715defdc7..96935f4f0d8 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/Incoming/InvokeHandlerTerminatorTest.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/Incoming/InvokeHandlerTerminatorTest.cs
@@ -25,7 +25,7 @@ public async Task When_saga_found_and_handler_is_saga_should_invoke_handler()
await terminator.Invoke(behaviorContext, _ => Task.CompletedTask);
- Assert.IsTrue(handlerInvoked);
+ Assert.That(handlerInvoked, Is.True);
}
[Test]
@@ -41,7 +41,7 @@ public async Task When_saga_not_found_and_handler_is_saga_should_not_invoke_hand
await terminator.Invoke(behaviorContext, _ => Task.CompletedTask);
- Assert.IsFalse(handlerInvoked);
+ Assert.That(handlerInvoked, Is.False);
}
[Test]
@@ -56,7 +56,7 @@ public async Task When_saga_not_found_and_handler_is_not_saga_should_invoke_hand
await terminator.Invoke(behaviorContext, _ => Task.CompletedTask);
- Assert.IsTrue(handlerInvoked);
+ Assert.That(handlerInvoked, Is.True);
}
[Test]
@@ -69,7 +69,7 @@ public async Task When_no_saga_should_invoke_handler()
await terminator.Invoke(behaviorContext, _ => Task.CompletedTask);
- Assert.IsTrue(handlerInvoked);
+ Assert.That(handlerInvoked, Is.True);
}
[Test]
@@ -81,7 +81,7 @@ public async Task Should_invoke_handler_with_current_message()
await terminator.Invoke(behaviorContext, _ => Task.CompletedTask);
- Assert.AreSame(behaviorContext.MessageBeingHandled, receivedMessage);
+ Assert.That(receivedMessage, Is.SameAs(behaviorContext.MessageBeingHandled));
}
[Test]
@@ -93,11 +93,14 @@ public void Should_rethrow_exception_with_additional_data()
var caughtException = Assert.ThrowsAsync(async () => await terminator.Invoke(behaviorContext, _ => Task.CompletedTask));
- Assert.AreSame(thrownException, caughtException);
- Assert.AreEqual("System.Object", caughtException.Data["Message type"]);
- Assert.AreEqual("NServiceBus.Core.Tests.Pipeline.Incoming.InvokeHandlerTerminatorTest+FakeMessageHandler", caughtException.Data["Handler type"]);
- Assert.That(DateTimeOffsetHelper.ToDateTimeOffset((string)caughtException.Data["Handler start time"]), Is.EqualTo(DateTimeOffset.UtcNow).Within(TimeSpan.FromSeconds(5)));
- Assert.That(DateTimeOffsetHelper.ToDateTimeOffset((string)caughtException.Data["Handler failure time"]), Is.EqualTo(DateTimeOffset.UtcNow).Within(TimeSpan.FromSeconds(5)));
+ Assert.That(caughtException, Is.SameAs(thrownException));
+ Assert.Multiple(() =>
+ {
+ Assert.That(caughtException.Data["Message type"], Is.EqualTo("System.Object"));
+ Assert.That(caughtException.Data["Handler type"], Is.EqualTo("NServiceBus.Core.Tests.Pipeline.Incoming.InvokeHandlerTerminatorTest+FakeMessageHandler"));
+ Assert.That(DateTimeOffsetHelper.ToDateTimeOffset((string)caughtException.Data["Handler start time"]), Is.EqualTo(DateTimeOffset.UtcNow).Within(TimeSpan.FromSeconds(5)));
+ Assert.That(DateTimeOffsetHelper.ToDateTimeOffset((string)caughtException.Data["Handler failure time"]), Is.EqualTo(DateTimeOffset.UtcNow).Within(TimeSpan.FromSeconds(5)));
+ });
}
[Test]
diff --git a/src/NServiceBus.Core.Tests/Pipeline/Incoming/MessageTypeEnricherTest.cs b/src/NServiceBus.Core.Tests/Pipeline/Incoming/MessageTypeEnricherTest.cs
index 35309447585..a3aa90adedd 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/Incoming/MessageTypeEnricherTest.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/Incoming/MessageTypeEnricherTest.cs
@@ -14,12 +14,15 @@ public async Task When_processing_message_without_enclosed_message_type_header_i
var behavior = new InferredMessageTypeEnricherBehavior();
var context = new TestableIncomingLogicalMessageContext();
- Assert.IsFalse(context.Headers.ContainsKey(Headers.EnclosedMessageTypes));
+ Assert.That(context.Headers.ContainsKey(Headers.EnclosedMessageTypes), Is.False);
await behavior.Invoke(context, messageContext => Task.CompletedTask);
- Assert.IsTrue(context.Headers.ContainsKey(Headers.EnclosedMessageTypes));
- Assert.AreEqual(context.Headers[Headers.EnclosedMessageTypes], typeof(object).FullName);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Headers.ContainsKey(Headers.EnclosedMessageTypes), Is.True);
+ Assert.That(typeof(object).FullName, Is.EqualTo(context.Headers[Headers.EnclosedMessageTypes]));
+ });
}
[Test]
@@ -31,8 +34,11 @@ public async Task When_processing_message_with_enclosed_message_type_header_it_i
await mutator.Invoke(context, messageContext => Task.CompletedTask);
- Assert.IsTrue(context.Headers.ContainsKey(Headers.EnclosedMessageTypes));
- Assert.AreEqual(context.Headers[Headers.EnclosedMessageTypes], typeof(string).FullName);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Headers.ContainsKey(Headers.EnclosedMessageTypes), Is.True);
+ Assert.That(typeof(string).FullName, Is.EqualTo(context.Headers[Headers.EnclosedMessageTypes]));
+ });
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/Pipeline/Incoming/SerializeMessageConnectorTests.cs b/src/NServiceBus.Core.Tests/Pipeline/Incoming/SerializeMessageConnectorTests.cs
index 81d8491a7fe..a79993f3eb8 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/Incoming/SerializeMessageConnectorTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/Incoming/SerializeMessageConnectorTests.cs
@@ -32,7 +32,7 @@ public async Task Should_set_content_type_header()
await behavior.Invoke(context, c => Task.CompletedTask);
- Assert.AreEqual("myContentType", context.Headers[Headers.ContentType]);
+ Assert.That(context.Headers[Headers.ContentType], Is.EqualTo("myContentType"));
}
class FakeSerializer : IMessageSerializer
diff --git a/src/NServiceBus.Core.Tests/Pipeline/IncomingPipelineMetricTagsTests.cs b/src/NServiceBus.Core.Tests/Pipeline/IncomingPipelineMetricTagsTests.cs
index 356863fb4e4..487e673d668 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/IncomingPipelineMetricTagsTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/IncomingPipelineMetricTagsTests.cs
@@ -16,7 +16,7 @@ namespace NServiceBus.Core.Tests.Pipeline.Incoming;
public class IncomingPipelineMetricTagsTests
{
[Test]
- public async Task Should_not_fail_when_handling_more_than_one_logical_message()
+ public void Should_not_fail_when_handling_more_than_one_logical_message()
{
var registry = new MessageMetadataRegistry(new Conventions().IsMessageType, true);
@@ -36,13 +36,11 @@ public async Task Should_not_fail_when_handling_more_than_one_logical_message()
var messageMapper = new MessageMapper();
var behavior = new DeserializeMessageConnector(new MessageDeserializerResolver(new FakeSerializer(), []), new LogicalMessageFactory(registry, messageMapper), registry, messageMapper, false);
- await behavior.Invoke(context, c =>
+ Assert.DoesNotThrowAsync(async () => await behavior.Invoke(context, c =>
{
c.Extensions.Get().Add("Same", "Same");
return Task.CompletedTask;
- });
-
- Assert.That(true, Is.True);
+ }));
}
class MyMessage : IMessage { }
diff --git a/src/NServiceBus.Core.Tests/Pipeline/MainPipelineExecutorTests.cs b/src/NServiceBus.Core.Tests/Pipeline/MainPipelineExecutorTests.cs
index 0b05c46af5d..d3c401e42e2 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/MainPipelineExecutorTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/MainPipelineExecutorTests.cs
@@ -25,7 +25,7 @@ public async Task Should_share_message_context_extension_values()
messageContext.Extensions.Set("existing value", existingValue);
await executor.Invoke(messageContext);
- Assert.AreEqual(existingValue, receivePipeline.LastContext.Extensions.Get("existing value"));
+ Assert.That(receivePipeline.LastContext.Extensions.Get("existing value"), Is.EqualTo(existingValue));
}
[Test]
@@ -42,7 +42,7 @@ public async Task Should_use_message_context_extensions_as_context_root()
await executor.Invoke(messageContext);
- Assert.AreEqual(newValue, messageContext.Extensions.Get("new value"));
+ Assert.That(messageContext.Extensions.Get("new value"), Is.EqualTo(newValue));
}
class When_activity_listener_registered
@@ -70,10 +70,13 @@ public async Task Should_start_Activity_when_invoking_pipeline()
await executor.Invoke(messageContext);
- Assert.NotNull(receivePipeline.PipelineAcitivty);
- Assert.AreEqual(ActivityNames.IncomingMessageActivityName, receivePipeline.PipelineAcitivty.OperationName);
- Assert.AreEqual("process message", receivePipeline.PipelineAcitivty.DisplayName);
- Assert.AreEqual(receivePipeline.PipelineAcitivty, receivePipeline.TransportReceiveContext.Extensions.Get(ActivityExtensions.IncomingActivityKey));
+ Assert.That(receivePipeline.PipelineAcitivty, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(receivePipeline.PipelineAcitivty.OperationName, Is.EqualTo(ActivityNames.IncomingMessageActivityName));
+ Assert.That(receivePipeline.PipelineAcitivty.DisplayName, Is.EqualTo("process message"));
+ Assert.That(receivePipeline.TransportReceiveContext.Extensions.Get(ActivityExtensions.IncomingActivityKey), Is.EqualTo(receivePipeline.PipelineAcitivty));
+ });
}
[Test]
@@ -84,7 +87,7 @@ public async Task Should_set_ok_status_on_activity_when_pipeline_successful()
await executor.Invoke(CreateMessageContext());
- Assert.AreEqual(ActivityStatusCode.Ok, receivePipeline.PipelineAcitivty.Status);
+ Assert.That(receivePipeline.PipelineAcitivty.Status, Is.EqualTo(ActivityStatusCode.Ok));
}
[Test]
@@ -96,7 +99,7 @@ public void Should_set_error_status_on_activity_when_pipeline_throws_exception()
Assert.ThrowsAsync(async () => await executor.Invoke(CreateMessageContext()));
- Assert.AreEqual(ActivityStatusCode.Error, receivePipeline.PipelineAcitivty.Status);
+ Assert.That(receivePipeline.PipelineAcitivty.Status, Is.EqualTo(ActivityStatusCode.Error));
}
}
diff --git a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/AttachSenderRelatedInfoOnMessageTests.cs b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/AttachSenderRelatedInfoOnMessageTests.cs
index 3f33f92406f..ed501bdfdfa 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/AttachSenderRelatedInfoOnMessageTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/AttachSenderRelatedInfoOnMessageTests.cs
@@ -19,7 +19,7 @@ public async Task Should_set_the_time_sent_headerAsync()
{
var message = await InvokeBehaviorAsync();
- Assert.True(message.Headers.ContainsKey(Headers.TimeSent));
+ Assert.That(message.Headers.ContainsKey(Headers.TimeSent), Is.True);
}
[Test]
@@ -32,8 +32,11 @@ public async Task Should_not_override_the_time_sent_headerAsync()
{Headers.TimeSent, timeSent}
});
- Assert.True(message.Headers.ContainsKey(Headers.TimeSent));
- Assert.AreEqual(timeSent, message.Headers[Headers.TimeSent]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(message.Headers.ContainsKey(Headers.TimeSent), Is.True);
+ Assert.That(message.Headers[Headers.TimeSent], Is.EqualTo(timeSent));
+ });
}
[Test]
@@ -41,7 +44,7 @@ public async Task Should_set_the_nsb_version_headerAsync()
{
var message = await InvokeBehaviorAsync();
- Assert.True(message.Headers.ContainsKey(Headers.NServiceBusVersion));
+ Assert.That(message.Headers.ContainsKey(Headers.NServiceBusVersion), Is.True);
}
[Test]
@@ -53,8 +56,11 @@ public async Task Should_not_override_nsb_version_headerAsync()
{Headers.NServiceBusVersion, nsbVersion}
});
- Assert.True(message.Headers.ContainsKey(Headers.NServiceBusVersion));
- Assert.AreEqual(nsbVersion, message.Headers[Headers.NServiceBusVersion]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(message.Headers.ContainsKey(Headers.NServiceBusVersion), Is.True);
+ Assert.That(message.Headers[Headers.NServiceBusVersion], Is.EqualTo(nsbVersion));
+ });
}
[Test]
@@ -65,7 +71,7 @@ public async Task Should_set_deliver_At_header_when_delay_delivery_with_setAsync
DelayDeliveryWith = new DelayDeliveryWith(TimeSpan.FromSeconds(2))
});
- Assert.True(message.Headers.ContainsKey(Headers.DeliverAt));
+ Assert.That(message.Headers.ContainsKey(Headers.DeliverAt), Is.True);
}
[Test]
@@ -77,8 +83,11 @@ public async Task Should_set_deliver_at_header_when_do_not_deliver_before_is_set
DoNotDeliverBefore = new DoNotDeliverBefore(doNotDeliverBefore)
});
- Assert.True(message.Headers.ContainsKey(Headers.DeliverAt));
- Assert.AreEqual(DateTimeOffsetHelper.ToWireFormattedString(doNotDeliverBefore), message.Headers[Headers.DeliverAt]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(message.Headers.ContainsKey(Headers.DeliverAt), Is.True);
+ Assert.That(message.Headers[Headers.DeliverAt], Is.EqualTo(DateTimeOffsetHelper.ToWireFormattedString(doNotDeliverBefore)));
+ });
}
[Test]
@@ -93,8 +102,11 @@ public async Task Should_not_override_deliver_at_headerAsync()
DelayDeliveryWith = new DelayDeliveryWith(TimeSpan.FromSeconds(2))
});
- Assert.True(message.Headers.ContainsKey(Headers.DeliverAt));
- Assert.AreEqual(DateTimeOffsetHelper.ToWireFormattedString(doNotDeliverBefore), message.Headers[Headers.DeliverAt]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(message.Headers.ContainsKey(Headers.DeliverAt), Is.True);
+ Assert.That(message.Headers[Headers.DeliverAt], Is.EqualTo(DateTimeOffsetHelper.ToWireFormattedString(doNotDeliverBefore)));
+ });
}
static async Task InvokeBehaviorAsync(Dictionary headers = null, DispatchProperties dispatchProperties = null, CancellationToken cancellationToken = default)
diff --git a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/ImmediateDispatchOptionExtensionsTests.cs b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/ImmediateDispatchOptionExtensionsTests.cs
index fa10abca3b0..9b47fbc8586 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/ImmediateDispatchOptionExtensionsTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/ImmediateDispatchOptionExtensionsTests.cs
@@ -10,7 +10,7 @@ public void RequiresImmediateDispatch_Should_Return_False_When_No_Immediate_Disp
{
var options = new SendOptions();
- Assert.IsFalse(options.IsImmediateDispatchSet());
+ Assert.That(options.IsImmediateDispatchSet(), Is.False);
}
[Test]
@@ -19,6 +19,6 @@ public void RequiresImmediateDispatch_Should_Return_True_When_Immediate_Dispatch
var options = new SendOptions();
options.RequireImmediateDispatch();
- Assert.IsTrue(options.IsImmediateDispatchSet());
+ Assert.That(options.IsImmediateDispatchSet(), Is.True);
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/MessageIdExtensionsTests.cs b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/MessageIdExtensionsTests.cs
index 73e2d29ce50..f3b04bf346c 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/MessageIdExtensionsTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/MessageIdExtensionsTests.cs
@@ -10,7 +10,7 @@ public void GetMessageId_Should_Return_Generated_Id_When_No_Id_Specified()
{
var options = new SendOptions();
- Assert.IsNotEmpty(options.GetMessageId());
+ Assert.That(options.GetMessageId(), Is.Not.Empty);
}
[Test]
@@ -20,6 +20,6 @@ public void GetMessageId_Should_Return_Defined_Id()
var options = new PublishOptions();
options.SetMessageId(expectedMessageID);
- Assert.AreEqual(expectedMessageID, options.GetMessageId());
+ Assert.That(options.GetMessageId(), Is.EqualTo(expectedMessageID));
}
}
\ No newline at end of file
diff --git a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/OutgoingLogicalMessageContextTests.cs b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/OutgoingLogicalMessageContextTests.cs
index ec2e73d4e09..db1a96492c7 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/OutgoingLogicalMessageContextTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/OutgoingLogicalMessageContextTests.cs
@@ -28,8 +28,11 @@ public void Updating_the_message_proxy_instance_with_a_new_property_value_should
context.UpdateMessage(newMessage);
- Assert.AreEqual(typeof(IMyMessage), context.Message.MessageType);
- Assert.AreEqual(newMessageId, ((IMyMessage)context.Message.Instance).Id);
+ Assert.Multiple(() =>
+ {
+ Assert.That(context.Message.MessageType, Is.EqualTo(typeof(IMyMessage)));
+ Assert.That(((IMyMessage)context.Message.Instance).Id, Is.EqualTo(newMessageId));
+ });
}
[Test]
@@ -47,7 +50,7 @@ public void Updating_the_message_to_a_new_type_should_update_the_MessageType()
context.UpdateMessage(differentMessage);
- Assert.AreEqual(typeof(MyDifferentMessage), context.Message.MessageType);
+ Assert.That(context.Message.MessageType, Is.EqualTo(typeof(MyDifferentMessage)));
}
class MyDifferentMessage
diff --git a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/OutgoingPublishContextTests.cs b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/OutgoingPublishContextTests.cs
index c6ba7d03ed9..1ff90a93a67 100644
--- a/src/NServiceBus.Core.Tests/Pipeline/Outgoing/OutgoingPublishContextTests.cs
+++ b/src/NServiceBus.Core.Tests/Pipeline/Outgoing/OutgoingPublishContextTests.cs
@@ -18,12 +18,18 @@ public void ShouldShallowCloneContext()
testee.Extensions.Set("someKey", "updatedValue");
testee.Extensions.Set("anotherKey", "anotherValue");
options.Context.TryGet("someKey", out string value);
- Assert.AreEqual("someValue", value);
- Assert.IsFalse(options.Context.TryGet("anotherKey", out string _));
+ Assert.Multiple(() =>
+ {
+ Assert.That(value, Is.EqualTo("someValue"));
+ Assert.That(options.Context.TryGet("anotherKey", out string _), Is.False);
+ });
testee.Extensions.TryGet("someKey", out string updatedValue);
testee.Extensions.TryGet("anotherKey", out string anotherValue2);
- Assert.AreEqual("updatedValue", updatedValue);
- Assert.AreEqual("anotherValue", anotherValue2);
+ Assert.Multiple(() =>
+ {
+ Assert.That(updatedValue, Is.EqualTo("updatedValue"));
+ Assert.That(anotherValue2, Is.EqualTo("anotherValue"));
+ });
}
[Test]
@@ -39,7 +45,7 @@ public void ShouldNotMergeOptionsToParentContext()
var valueFound = parentContext.TryGet("someKey", out string _);
- Assert.IsFalse(valueFound);
+ Assert.That(valueFound, Is.False);
}
[Test]
@@ -53,7 +59,7 @@ public void ShouldExposePublishOptionsExtensionsAsOperationProperties()
var publishContext = new OutgoingPublishContext(message, "message-id", [], options, parentContext);
var operationProperties = publishContext.GetOperationProperties();
- Assert.AreEqual("some value", operationProperties.Get("some key"));
+ Assert.That(operationProperties.Get("some key"), Is.EqualTo("some value"));
}
[Test]
@@ -70,13 +76,19 @@ public void ShouldNotLeakParentsOperationProperties()
var innerContext = new OutgoingPublishContext(new OutgoingLogicalMessage(typeof(object), new object()), "message-id", [], innerOptions, parentContext);
var innerOperationProperties = innerContext.GetOperationProperties();
- Assert.AreEqual("inner value", innerOperationProperties.Get("inner key"));
- Assert.AreEqual("inner shared value", innerOperationProperties.Get("shared key"));
- Assert.IsFalse(innerOperationProperties.TryGet("outer key", out string _));
+ Assert.Multiple(() =>
+ {
+ Assert.That(innerOperationProperties.Get("inner key"), Is.EqualTo("inner value"));
+ Assert.That(innerOperationProperties.Get("shared key"), Is.EqualTo("inner shared value"));
+ Assert.That(innerOperationProperties.TryGet("outer key", out string _), Is.False);
+ });
var outerOperationProperties = parentContext.GetOperationProperties();
- Assert.AreEqual("outer value", outerOperationProperties.Get("outer key"));
- Assert.AreEqual("outer shared value", outerOperationProperties.Get