diff --git a/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj b/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj index f1b86e53..d29f3cdd 100644 --- a/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj +++ b/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/IntegrationTests.HostV4/When_starting_the_function_host.cs b/src/IntegrationTests.HostV4/When_starting_the_function_host.cs index 4615e882..59c0cef9 100644 --- a/src/IntegrationTests.HostV4/When_starting_the_function_host.cs +++ b/src/IntegrationTests.HostV4/When_starting_the_function_host.cs @@ -192,12 +192,12 @@ public async Task Should_not_blow_up() } } - Assert.Multiple(() => + using (Assert.EnterMultipleScope()) { Assert.That(hostFailed, Is.False, "Host should startup without errors"); Assert.That(hasResult, Is.True, "Http trigger should respond successfully"); Assert.That(commandHandlerCalled, Is.True, $"{nameof(SomeOtherMessageHandler)} should have been called"); Assert.That(eventHandlerCalled, Is.True, $"{nameof(SomeEventMessageHandler)} should have been called"); - }); + }; } } \ No newline at end of file diff --git a/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests.csproj b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests.csproj index 62c09223..79b30328 100644 --- a/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests.csproj +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj b/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj index 7974abcc..560eb47c 100644 --- a/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj +++ b/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/ServiceBus.AcceptanceTests/When_failing_to_process_message.cs b/src/ServiceBus.AcceptanceTests/When_failing_to_process_message.cs index e9609173..7448f4b0 100644 --- a/src/ServiceBus.AcceptanceTests/When_failing_to_process_message.cs +++ b/src/ServiceBus.AcceptanceTests/When_failing_to_process_message.cs @@ -21,11 +21,11 @@ public async Task Should_not_publish_to_subscribers(TransportTransactionMode tra .Done(c => c.TerminatingEventReceived) .Run(); - Assert.Multiple(() => + using (Assert.EnterMultipleScope()) { Assert.That(context.TerminatingEventReceived, Is.True); Assert.That(context.AbortedEventReceived, Is.False); - }); + }; } [TestCase(TransportTransactionMode.ReceiveOnly)] @@ -37,11 +37,11 @@ public async Task Should_publish_to_subscribers(TransportTransactionMode transac .Done(c => c.TerminatingEventReceived) .Run(); - Assert.Multiple(() => + using (Assert.EnterMultipleScope()) { Assert.That(context.TerminatingEventReceived, Is.True); Assert.That(context.AbortedEventReceived, Is.True); - }); + }; } class Context : ScenarioContext diff --git a/src/ServiceBus.AcceptanceTests/When_incoming_message_is_not_acknowledged.cs b/src/ServiceBus.AcceptanceTests/When_incoming_message_is_not_acknowledged.cs index 49ff7cd0..edcf70ae 100644 --- a/src/ServiceBus.AcceptanceTests/When_incoming_message_is_not_acknowledged.cs +++ b/src/ServiceBus.AcceptanceTests/When_incoming_message_is_not_acknowledged.cs @@ -20,11 +20,11 @@ public async Task Should_dispatch_outgoing_messages_from_the_outbox(TransportTra .Done(c => c.MessageReceived && c.MessageRetried) .Run(); - Assert.Multiple(() => + using (Assert.EnterMultipleScope()) { Assert.That(context.MessageRetried, Is.True); Assert.That(context.MessageReceived, Is.True); - }); + }; } public class Context : ScenarioContext diff --git a/src/ServiceBus.AcceptanceTests/When_message_fails_with_disabled_error_queue.cs b/src/ServiceBus.AcceptanceTests/When_message_fails_with_disabled_error_queue.cs index 8641aaac..d97c9624 100644 --- a/src/ServiceBus.AcceptanceTests/When_message_fails_with_disabled_error_queue.cs +++ b/src/ServiceBus.AcceptanceTests/When_message_fails_with_disabled_error_queue.cs @@ -12,13 +12,13 @@ public class When_message_fails_with_disabled_error_queue [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] public void Should_throw_exception(TransportTransactionMode transactionMode) { - var exception = Assert.ThrowsAsync(() => + var exception = Assert.ThrowsAsync((Func)(() => { return Scenario.Define() .WithComponent(new DisabledErrorQueueFunction(transactionMode)) .Done(c => c.EndpointsStarted) .Run(); - }); + })); Assert.That(exception.Message, Does.Contain("Failed to process message")); Assert.That(exception.InnerException, Is.InstanceOf()); diff --git a/src/ServiceBus.AcceptanceTests/When_message_is_failing_all_processing_attempts.cs b/src/ServiceBus.AcceptanceTests/When_message_is_failing_all_processing_attempts.cs index 6c1615e4..a9c8e3a0 100644 --- a/src/ServiceBus.AcceptanceTests/When_message_is_failing_all_processing_attempts.cs +++ b/src/ServiceBus.AcceptanceTests/When_message_is_failing_all_processing_attempts.cs @@ -1,5 +1,6 @@ namespace ServiceBus.Tests; +using System; using System.Linq; using System.Threading.Tasks; using NServiceBus; @@ -14,20 +15,20 @@ public class When_message_is_failing_all_processing_attempts public void Should_be_moved_to_the_error_queue(TransportTransactionMode transactionMode) { Context testContext = null; - var exception = Assert.ThrowsAsync(() => + var exception = Assert.ThrowsAsync((Func)(() => { return Scenario.Define(c => testContext = c) .WithComponent(new MoveToErrorQueueFunction(transactionMode)) .Done(c => c.EndpointsStarted) .Run(); - }); + })); - Assert.Multiple(() => + using (Assert.EnterMultipleScope()) { Assert.That(testContext.HandlerInvocations, Is.EqualTo(1), "the handler should only be invoked once"); Assert.That(exception.InnerException, Is.InstanceOf(), "it should be the exception from the handler"); Assert.That(testContext.FailedMessages.Single().Value, Has.Count.EqualTo(1), "there should be only one failed message"); - }); + }; } class Context : ScenarioContext diff --git a/src/ServiceBus.AcceptanceTests/When_no_connection_string_is_provided.cs b/src/ServiceBus.AcceptanceTests/When_no_connection_string_is_provided.cs index 2f3f3f9a..79fbd1ca 100644 --- a/src/ServiceBus.AcceptanceTests/When_no_connection_string_is_provided.cs +++ b/src/ServiceBus.AcceptanceTests/When_no_connection_string_is_provided.cs @@ -1,6 +1,7 @@ namespace ServiceBus.Tests; using System; +using System.Threading.Tasks; using NServiceBus.AcceptanceTesting; using NServiceBus.AzureFunctions.InProcess.ServiceBus; using NUnit.Framework; @@ -20,10 +21,10 @@ public void SetUp() [Test] public void Should_guide_user_towards_success() { - var exception = Assert.ThrowsAsync(async () => await Scenario.Define() + var exception = Assert.ThrowsAsync((Func)(async () => await Scenario.Define() .WithComponent(new FunctionWithoutConnectionString()) .Done(c => c.EndpointsStarted) - .Run(), + .Run()), "Exception should be thrown at endpoint creation so that the error will be found during functions startup" ); diff --git a/src/ServiceBus.AcceptanceTests/When_receiving_with_sendonly.cs b/src/ServiceBus.AcceptanceTests/When_receiving_with_sendonly.cs index 83d8da44..891cdc24 100644 --- a/src/ServiceBus.AcceptanceTests/When_receiving_with_sendonly.cs +++ b/src/ServiceBus.AcceptanceTests/When_receiving_with_sendonly.cs @@ -12,10 +12,10 @@ public class When_receiving_with_sendonly [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] public void Should_invoke_the_handler_to_process_it(TransportTransactionMode transactionMode) { - var exception = Assert.ThrowsAsync(() => Scenario.Define() + var exception = Assert.ThrowsAsync((Func)(() => Scenario.Define() .WithComponent(new FunctionWithSendOnlyConfiguration(transactionMode)) .Done(c => c.EndpointsStarted) - .Run()); + .Run())); Assert.That(exception.Message, Does.Contain("This endpoint cannot process messages because it is configured in send-only mode.")); } diff --git a/src/ServiceBus.AcceptanceTests/When_shipping_handlers_in_dedicated_assembly.cs b/src/ServiceBus.AcceptanceTests/When_shipping_handlers_in_dedicated_assembly.cs index 249b83f0..9fbc5977 100644 --- a/src/ServiceBus.AcceptanceTests/When_shipping_handlers_in_dedicated_assembly.cs +++ b/src/ServiceBus.AcceptanceTests/When_shipping_handlers_in_dedicated_assembly.cs @@ -36,13 +36,13 @@ await Scenario.Define() var dummyMessageType = registry.GetMessageTypes().FirstOrDefault(t => t.FullName == "Testing.Handlers.DummyMessage"); Assert.That(dummyMessageType, Is.Not.Null); var dummyMessageHandler = registry.GetHandlersFor(dummyMessageType).SingleOrDefault(); - Assert.Multiple(() => + using (Assert.EnterMultipleScope()) { Assert.That(dummyMessageHandler.HandlerType.FullName, Is.EqualTo("Testing.Handlers.DummyMessageHandler")); // ensure the assembly is loaded into the right context Assert.That(AssemblyLoadContext.GetLoadContext(dummyMessageType.Assembly), Is.EqualTo(AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly()))); - }); + }; } class FunctionWithHandlersInDedicatedAssembly : FunctionEndpointComponent diff --git a/src/ServiceBus.AcceptanceTests/When_using_processatomic_with_outbox.cs b/src/ServiceBus.AcceptanceTests/When_using_processatomic_with_outbox.cs index 5016ac75..eeae8668 100644 --- a/src/ServiceBus.AcceptanceTests/When_using_processatomic_with_outbox.cs +++ b/src/ServiceBus.AcceptanceTests/When_using_processatomic_with_outbox.cs @@ -15,14 +15,14 @@ public class When_using_processatomic_with_outbox [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] public void Should_dispatch_outgoing_messages_from_the_outbox(TransportTransactionMode transactionMode) { - var exception = Assert.ThrowsAsync(() => + var exception = Assert.ThrowsAsync((Func)(() => { return Scenario.Define() .WithComponent(new FunctionHandler(transactionMode)) .WithEndpoint() .Done(c => c.MessageReceived && c.MessageRetried) .Run(); - }); + })); Assert.That(exception.InnerException.Message, Does.Contain("Atomic sends with receive is not supported when the Outbox is enabled as it would risk message loss. Set `SendsAtomicWithReceive` to `false` on the `NServiceBusTriggerFunction` attribute or make sure to call `ProcessNonAtomic` instead of `ProcessAtomic` if using a custom trigger.")); } diff --git a/src/ServiceBus.Tests/LoggingTests.cs b/src/ServiceBus.Tests/LoggingTests.cs index 5a1ed9ef..f78ee71d 100644 --- a/src/ServiceBus.Tests/LoggingTests.cs +++ b/src/ServiceBus.Tests/LoggingTests.cs @@ -64,11 +64,11 @@ public void Only_first_logger_gets_deferred_messages() FunctionsLoggerFactory.Instance.SetCurrentLogger(firstLogger); FunctionsLoggerFactory.Instance.SetCurrentLogger(secondLogger); - Assert.Multiple(() => + using (Assert.EnterMultipleScope()) { Assert.That(firstLogger.CapturedLogs, Has.Count.EqualTo(1)); Assert.That(secondLogger.CapturedLogs.Count, Is.EqualTo(0)); - }); + }; } [Test] @@ -83,11 +83,11 @@ public async Task Concurrent_loggers_are_isolated() var firstLogger = firstLoggerTask.Result; var secondLogger = secondLoggerTask.Result; - Assert.Multiple(() => + using (Assert.EnterMultipleScope()) { Assert.That(firstLogger.CapturedLogs, Has.Count.EqualTo(1)); Assert.That(secondLogger.CapturedLogs, Has.Count.EqualTo(1)); - }); + }; firstLogger.CapturedLogs.TryDequeue(out var firstLog); Assert.That(firstLog.message, Is.EqualTo("Running task 1")); diff --git a/src/ServiceBus.Tests/ServiceBus.Tests.csproj b/src/ServiceBus.Tests/ServiceBus.Tests.csproj index 7064b180..6bcfbedd 100644 --- a/src/ServiceBus.Tests/ServiceBus.Tests.csproj +++ b/src/ServiceBus.Tests/ServiceBus.Tests.csproj @@ -13,7 +13,7 @@ - +