Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.13.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.13.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.13.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exception>(() =>
var exception = Assert.ThrowsAsync<Exception>((Func<Task>)(() =>
{
return Scenario.Define<ScenarioContext>()
.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<SimulatedException>());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace ServiceBus.Tests;

using System;
using System.Linq;
using System.Threading.Tasks;
using NServiceBus;
Expand All @@ -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<MessageFailedException>(() =>
var exception = Assert.ThrowsAsync<MessageFailedException>((Func<Task>)(() =>
{
return Scenario.Define<Context>(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<SimulatedException>(), "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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace ServiceBus.Tests;

using System;
using System.Threading.Tasks;
using NServiceBus.AcceptanceTesting;
using NServiceBus.AzureFunctions.InProcess.ServiceBus;
using NUnit.Framework;
Expand All @@ -20,10 +21,10 @@ public void SetUp()
[Test]
public void Should_guide_user_towards_success()
{
var exception = Assert.ThrowsAsync<Exception>(async () => await Scenario.Define<ScenarioContext>()
var exception = Assert.ThrowsAsync<Exception>((Func<Task>)(async () => await Scenario.Define<ScenarioContext>()
.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"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InvalidOperationException>(() => Scenario.Define<ScenarioContext>()
var exception = Assert.ThrowsAsync<InvalidOperationException>((Func<Task>)(() => Scenario.Define<ScenarioContext>()
.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."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ await Scenario.Define<ScenarioContext>()
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MessageFailedException>(() =>
var exception = Assert.ThrowsAsync<MessageFailedException>((Func<Task>)(() =>
{
return Scenario.Define<Context>()
.WithComponent(new FunctionHandler(transactionMode))
.WithEndpoint<SpyEndpoint>()
.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."));
}
Expand Down
8 changes: 4 additions & 4 deletions src/ServiceBus.Tests/LoggingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceBus.Tests/ServiceBus.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.13.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />
</ItemGroup>
Expand Down