diff --git a/Directory.Build.props b/Directory.Build.props
index 4ebe0a388..21736dd43 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -10,11 +10,7 @@
http://github.com/jasperfx/wolverine
MIT
net9.0;net10.0
-
- 1570;1571;1572;1573;1574;1587;1591;1701;1702;1711;1735;0618;VSTHRD200;xUnit1051
+ 1570;1571;1572;1573;1574;1587;1591;1701;1702;1711;1735;0618;VSTHRD200
true
true
enable
diff --git a/Directory.Build.targets b/Directory.Build.targets
index c442ae210..835073ce4 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -1,6 +1,25 @@
+
+
+ $(NoWarn);xUnit1051
+
+
+ true
Exe
false
diff --git a/src/Extensions/Wolverine.DataAnnotationsValidation.Tests/configuration_specs.cs b/src/Extensions/Wolverine.DataAnnotationsValidation.Tests/configuration_specs.cs
index 316113b9a..ea50afd72 100644
--- a/src/Extensions/Wolverine.DataAnnotationsValidation.Tests/configuration_specs.cs
+++ b/src/Extensions/Wolverine.DataAnnotationsValidation.Tests/configuration_specs.cs
@@ -19,7 +19,7 @@ public async Task add_the_default_services()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
host.Services.GetRequiredService>()
.ShouldBeOfType>();
@@ -32,7 +32,7 @@ public async Task place_or_not_place_the_middleware_correctly()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var wolverineOptions = host.Services.GetRequiredService()
.As().Options;
diff --git a/src/Extensions/Wolverine.DataAnnotationsValidation.Tests/end_to_end.cs b/src/Extensions/Wolverine.DataAnnotationsValidation.Tests/end_to_end.cs
index 0c5c1c8e3..351690316 100644
--- a/src/Extensions/Wolverine.DataAnnotationsValidation.Tests/end_to_end.cs
+++ b/src/Extensions/Wolverine.DataAnnotationsValidation.Tests/end_to_end.cs
@@ -13,7 +13,7 @@ public async Task invoke_happy_path_with_multiple_validators()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command1
{
@@ -31,7 +31,7 @@ public async Task invoke_sad_path_with_multiple_validators()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command1
{
@@ -48,7 +48,7 @@ public async Task invoke_happy_path_with_single_validator()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command2
{
@@ -66,7 +66,7 @@ public async Task invoke_sad_path_with_single_validator()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command2
{
@@ -83,7 +83,7 @@ public async Task invoke_sad_path_validator_with_async_rule()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command4
{
@@ -91,7 +91,7 @@ public async Task invoke_sad_path_validator_with_async_rule()
};
await Should.ThrowAsync(() => host.InvokeAsync(command));
- await host.StopAsync();
+ await host.StopAsync(TestContext.Current.CancellationToken);
}
[Fact]
@@ -101,7 +101,7 @@ public async Task invoke_happy_path_validator_with_async_rule()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command4
{
@@ -109,6 +109,6 @@ public async Task invoke_happy_path_validator_with_async_rule()
};
await Should.NotThrowAsync(() => host.InvokeAsync(command));
- await host.StopAsync();
+ await host.StopAsync(TestContext.Current.CancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Extensions/Wolverine.FluentValidation.Tests/Samples.cs b/src/Extensions/Wolverine.FluentValidation.Tests/Samples.cs
index a8264d45f..a027a38d5 100644
--- a/src/Extensions/Wolverine.FluentValidation.Tests/Samples.cs
+++ b/src/Extensions/Wolverine.FluentValidation.Tests/Samples.cs
@@ -24,7 +24,7 @@ public async Task register_the_middleware()
// Just a prerequisite for some of the test validators
opts.Services.AddSingleton();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
#endregion
}
@@ -49,7 +49,7 @@ public async Task register_the_middleware_with_validator_options()
// Just a prerequisite for some of the test validators
opts.Services.AddSingleton();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
#endregion
}
@@ -70,7 +70,7 @@ public async Task register_the_middleware_with_override_failure_condition()
// Just a prerequisite for some of the test validators
opts.Services.AddSingleton();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
#endregion
}
diff --git a/src/Extensions/Wolverine.FluentValidation.Tests/Wolverine.FluentValidation.Tests.csproj b/src/Extensions/Wolverine.FluentValidation.Tests/Wolverine.FluentValidation.Tests.csproj
index 9d01fae69..6368a5917 100644
--- a/src/Extensions/Wolverine.FluentValidation.Tests/Wolverine.FluentValidation.Tests.csproj
+++ b/src/Extensions/Wolverine.FluentValidation.Tests/Wolverine.FluentValidation.Tests.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
false
diff --git a/src/Extensions/Wolverine.FluentValidation.Tests/configuration_specs.cs b/src/Extensions/Wolverine.FluentValidation.Tests/configuration_specs.cs
index 5da268ef5..b04d075e2 100644
--- a/src/Extensions/Wolverine.FluentValidation.Tests/configuration_specs.cs
+++ b/src/Extensions/Wolverine.FluentValidation.Tests/configuration_specs.cs
@@ -34,7 +34,7 @@ public async Task register_validators_in_application_assembly()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var container = host.Services.GetRequiredService();
@@ -55,7 +55,7 @@ public async Task add_the_default_services()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
host.Services.GetRequiredService>()
.ShouldBeOfType>();
@@ -70,7 +70,7 @@ public async Task place_or_not_place_the_middleware_correctly()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var wolverineOptions = host.Services.GetRequiredService()
.As().Options;
@@ -110,7 +110,7 @@ public async Task configure_validator_options_via_action_overload()
});
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
ValidatorOptions.Global.DefaultRuleLevelCascadeMode.ShouldBe(CascadeMode.Stop);
ValidatorOptions.Global.DefaultClassLevelCascadeMode.ShouldBe(CascadeMode.Stop);
@@ -129,7 +129,7 @@ public async Task configure_registration_behavior_via_action_overload()
{
fv.RegistrationBehavior = RegistrationBehavior.ExplicitRegistration;
});
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var container = host.Services.GetRequiredService();
@@ -150,7 +150,7 @@ public async Task action_overload_still_applies_middleware()
});
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var wolverineOptions = host.Services.GetRequiredService()
.As().Options;
@@ -177,7 +177,7 @@ public async Task discover_internal_validators_when_include_internal_types_is_tr
});
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var container = host.Services.GetRequiredService();
@@ -196,7 +196,7 @@ public async Task do_not_discover_internal_validators_by_default()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var container = host.Services.GetRequiredService();
@@ -216,7 +216,7 @@ public async Task discover_internal_validator_with_dependencies_as_scoped()
});
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var container = host.Services.GetRequiredService();
diff --git a/src/Extensions/Wolverine.FluentValidation.Tests/end_to_end.cs b/src/Extensions/Wolverine.FluentValidation.Tests/end_to_end.cs
index ebba5c5ba..941250c47 100644
--- a/src/Extensions/Wolverine.FluentValidation.Tests/end_to_end.cs
+++ b/src/Extensions/Wolverine.FluentValidation.Tests/end_to_end.cs
@@ -16,7 +16,7 @@ public async Task invoke_happy_path_with_multiple_validators()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command1
{
@@ -36,7 +36,7 @@ public async Task invoke_sad_path_with_multiple_validators()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command1
{
@@ -55,7 +55,7 @@ public async Task invoke_happy_path_with_single_validator()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command2
{
@@ -75,7 +75,7 @@ public async Task invoke_sad_path_with_single_validator()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command2
{
@@ -94,7 +94,7 @@ public async Task invoke_sad_path_validator_with_async_rule()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command4
{
@@ -102,7 +102,7 @@ public async Task invoke_sad_path_validator_with_async_rule()
};
await Should.ThrowAsync(() => host.InvokeAsync(command));
- await host.StopAsync();
+ await host.StopAsync(TestContext.Current.CancellationToken);
}
[Fact]
@@ -114,7 +114,7 @@ public async Task invoke_happy_path_validator_with_async_rule()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command4
{
@@ -122,7 +122,7 @@ public async Task invoke_happy_path_validator_with_async_rule()
};
await Should.NotThrowAsync(() => host.InvokeAsync(command));
- await host.StopAsync();
+ await host.StopAsync(TestContext.Current.CancellationToken);
}
[Fact]
@@ -134,7 +134,7 @@ public async Task invoke_sad_path_multiple_validators_with_async_rule()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command5
{
@@ -143,7 +143,7 @@ public async Task invoke_sad_path_multiple_validators_with_async_rule()
};
await Should.ThrowAsync(() => host.InvokeAsync(command));
- await host.StopAsync();
+ await host.StopAsync(TestContext.Current.CancellationToken);
}
[Fact]
@@ -155,7 +155,7 @@ public async Task invoke_happy_path_multiple_validators_with_async_rule()
opts.UseFluentValidation();
opts.Services.AddScoped();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var command = new Command5
{
@@ -164,6 +164,6 @@ public async Task invoke_happy_path_multiple_validators_with_async_rule()
};
await Should.NotThrowAsync(() => host.InvokeAsync(command));
- await host.StopAsync();
+ await host.StopAsync(TestContext.Current.CancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Extensions/Wolverine.FluentValidation.Tests/internals_tests.cs b/src/Extensions/Wolverine.FluentValidation.Tests/internals_tests.cs
index 68160cb55..64bc068b5 100644
--- a/src/Extensions/Wolverine.FluentValidation.Tests/internals_tests.cs
+++ b/src/Extensions/Wolverine.FluentValidation.Tests/internals_tests.cs
@@ -11,7 +11,7 @@ public async Task default_validation_action_throws_exception()
var validator = new Command1Validator();
var command = new Command1();
- var result = await validator.ValidateAsync(command);
+ var result = await validator.ValidateAsync(command, TestContext.Current.CancellationToken);
var ex = Should.Throw(() =>
{
diff --git a/src/Extensions/Wolverine.MemoryPack.Tests/Wolverine.MemoryPack.Tests.csproj b/src/Extensions/Wolverine.MemoryPack.Tests/Wolverine.MemoryPack.Tests.csproj
index 789abc94e..f2ebb91f4 100644
--- a/src/Extensions/Wolverine.MemoryPack.Tests/Wolverine.MemoryPack.Tests.csproj
+++ b/src/Extensions/Wolverine.MemoryPack.Tests/Wolverine.MemoryPack.Tests.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
false
diff --git a/src/Extensions/Wolverine.MemoryPack.Tests/serialization_configuration.cs b/src/Extensions/Wolverine.MemoryPack.Tests/serialization_configuration.cs
index d898ec265..eb91bab47 100644
--- a/src/Extensions/Wolverine.MemoryPack.Tests/serialization_configuration.cs
+++ b/src/Extensions/Wolverine.MemoryPack.Tests/serialization_configuration.cs
@@ -18,7 +18,7 @@ public async Task can_override_the_default_app_wide()
opts.UseMemoryPackSerialization();
opts.PublishAllMessages().To("stub://one");
opts.ListenForMessagesFrom("stub://two");
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var root = host.Services.GetRequiredService();
root.Endpoints.EndpointFor("stub://one".ToUri())
@@ -36,7 +36,7 @@ public async Task can_override_the_serialization_on_just_one_endpoint()
opts.PublishAllMessages().To("stub://one").UseMemoryPackSerialization();
opts.ListenForMessagesFrom("stub://two").UseMemoryPackSerialization();
opts.ListenForMessagesFrom("stub://three");
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var root = host.Services.GetRequiredService();
root.Endpoints.EndpointFor("stub://one".ToUri())
diff --git a/src/Extensions/Wolverine.MessagePack.Tests/Wolverine.MessagePack.Tests.csproj b/src/Extensions/Wolverine.MessagePack.Tests/Wolverine.MessagePack.Tests.csproj
index 1cbc36506..90b9c4dda 100644
--- a/src/Extensions/Wolverine.MessagePack.Tests/Wolverine.MessagePack.Tests.csproj
+++ b/src/Extensions/Wolverine.MessagePack.Tests/Wolverine.MessagePack.Tests.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
false
diff --git a/src/Extensions/Wolverine.MessagePack.Tests/serialization_configuration.cs b/src/Extensions/Wolverine.MessagePack.Tests/serialization_configuration.cs
index b5f5b0f7f..d97907854 100644
--- a/src/Extensions/Wolverine.MessagePack.Tests/serialization_configuration.cs
+++ b/src/Extensions/Wolverine.MessagePack.Tests/serialization_configuration.cs
@@ -19,7 +19,7 @@ public async Task can_override_the_default_app_wide()
opts.UseMessagePackSerialization();
opts.PublishAllMessages().To("stub://one");
opts.ListenForMessagesFrom("stub://two");
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var root = host.Services.GetRequiredService();
root.Endpoints.EndpointFor("stub://one".ToUri())
@@ -37,7 +37,7 @@ public async Task can_override_the_serialization_on_just_one_endpoint()
opts.PublishAllMessages().To("stub://one").UseMessagePackSerialization();
opts.ListenForMessagesFrom("stub://two").UseMessagePackSerialization();
opts.ListenForMessagesFrom("stub://three");
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var root = host.Services.GetRequiredService();
root.Endpoints.EndpointFor("stub://one".ToUri())
diff --git a/src/Extensions/Wolverine.Protobuf.Tests/Wolverine.Protobuf.Tests.csproj b/src/Extensions/Wolverine.Protobuf.Tests/Wolverine.Protobuf.Tests.csproj
index b8f92baf0..e001c967c 100644
--- a/src/Extensions/Wolverine.Protobuf.Tests/Wolverine.Protobuf.Tests.csproj
+++ b/src/Extensions/Wolverine.Protobuf.Tests/Wolverine.Protobuf.Tests.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
false
diff --git a/src/Http/Wolverine.Http.AspVersioning.Tests/Wolverine.Http.AspVersioning.Tests.csproj b/src/Http/Wolverine.Http.AspVersioning.Tests/Wolverine.Http.AspVersioning.Tests.csproj
index a6eb9f1dd..d09e78946 100644
--- a/src/Http/Wolverine.Http.AspVersioning.Tests/Wolverine.Http.AspVersioning.Tests.csproj
+++ b/src/Http/Wolverine.Http.AspVersioning.Tests/Wolverine.Http.AspVersioning.Tests.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
net10.0
false
diff --git a/src/Http/Wolverine.Http.Tests/Bugs/Bug_1295_aggregate_handler_should_not_try_to_use_query_string.cs b/src/Http/Wolverine.Http.Tests/Bugs/Bug_1295_aggregate_handler_should_not_try_to_use_query_string.cs
index 9db094915..eed9b238b 100644
--- a/src/Http/Wolverine.Http.Tests/Bugs/Bug_1295_aggregate_handler_should_not_try_to_use_query_string.cs
+++ b/src/Http/Wolverine.Http.Tests/Bugs/Bug_1295_aggregate_handler_should_not_try_to_use_query_string.cs
@@ -46,7 +46,7 @@ public async Task run_end_to_end()
await using var session = host.DocumentStore().LightweightSession();
var streamKey = Guid.NewGuid().ToString();
session.Events.StartStream(streamKey, new TestEvent());
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await host.Scenario(x =>
{
diff --git a/src/Http/Wolverine.Http.Tests/Bugs/Bug_2205_multiple_document_args.cs b/src/Http/Wolverine.Http.Tests/Bugs/Bug_2205_multiple_document_args.cs
index 4752da3aa..baaf70e04 100644
--- a/src/Http/Wolverine.Http.Tests/Bugs/Bug_2205_multiple_document_args.cs
+++ b/src/Http/Wolverine.Http.Tests/Bugs/Bug_2205_multiple_document_args.cs
@@ -17,7 +17,7 @@ public async Task multiple_documents_should_return_both()
await using var session = Store.LightweightSession();
session.Store(new Invoice { Id = invoiceId });
session.Store(new Receipt { Id = receiptId });
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var result = await Scenario(x =>
{
@@ -37,7 +37,7 @@ public async Task multiple_documents_returns_404_when_first_missing()
await using var session = Store.LightweightSession();
session.Store(new Receipt { Id = receiptId });
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Scenario(x =>
{
@@ -53,7 +53,7 @@ public async Task multiple_documents_returns_404_when_second_missing()
await using var session = Store.LightweightSession();
session.Store(new Invoice { Id = invoiceId });
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Scenario(x =>
{
@@ -71,7 +71,7 @@ public async Task document_and_aggregate_should_return_both()
await using var session = Store.LightweightSession();
session.Store(new Invoice { Id = invoiceId });
session.Events.StartStream(orderId, new OrderCreated([new Item { Name = "Widget" }]));
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var result = await Scenario(x =>
{
diff --git a/src/Http/Wolverine.Http.Tests/Bugs/Bug_281_erroneous_215.cs b/src/Http/Wolverine.Http.Tests/Bugs/Bug_281_erroneous_215.cs
index fbce99c60..cd0c0e5b4 100644
--- a/src/Http/Wolverine.Http.Tests/Bugs/Bug_281_erroneous_215.cs
+++ b/src/Http/Wolverine.Http.Tests/Bugs/Bug_281_erroneous_215.cs
@@ -23,7 +23,7 @@ await Scenario(x =>
});
var client = Host.Server.CreateClient();
- var response = await client.PostAsJsonAsync("/users/sign-up", signUpRequest);
+ var response = await client.PostAsJsonAsync("/users/sign-up", signUpRequest, cancellationToken: TestContext.Current.CancellationToken);
response.StatusCode.As().ShouldBe(204);
}
}
\ No newline at end of file
diff --git a/src/Http/Wolverine.Http.Tests/Bugs/Bug_608_using_route_variables_in_middleware_without_argument.cs b/src/Http/Wolverine.Http.Tests/Bugs/Bug_608_using_route_variables_in_middleware_without_argument.cs
index 0d93e30d1..bfb2f9720 100644
--- a/src/Http/Wolverine.Http.Tests/Bugs/Bug_608_using_route_variables_in_middleware_without_argument.cs
+++ b/src/Http/Wolverine.Http.Tests/Bugs/Bug_608_using_route_variables_in_middleware_without_argument.cs
@@ -13,7 +13,7 @@ public async Task can_use_route_argument_in_middleware()
{
using var session = Store.LightweightSession();
session.Store(new SomeDocument{Id = "ball"});
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Scenario(x =>
{
diff --git a/src/Http/Wolverine.Http.Tests/Bugs/Bug_using_fromquery_with_aggregatehandler.cs b/src/Http/Wolverine.Http.Tests/Bugs/Bug_using_fromquery_with_aggregatehandler.cs
index 2af5d5891..5d52e83d9 100644
--- a/src/Http/Wolverine.Http.Tests/Bugs/Bug_using_fromquery_with_aggregatehandler.cs
+++ b/src/Http/Wolverine.Http.Tests/Bugs/Bug_using_fromquery_with_aggregatehandler.cs
@@ -70,7 +70,7 @@ public async Task run_end_to_end()
await using var session = host.DocumentStore().LightweightSession();
var aggregateId = Guid.NewGuid();
session.Events.StartStream(aggregateId, new FromQueryAggregateHandlerEvent(Guid.NewGuid(), "Something1"));
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var body = await host.Scenario(x => x.Get.Url("/getusingfromqueryandaggregatehandler?id=" + aggregateId +"&something=Something2"));
diff --git a/src/Http/Wolverine.Http.Tests/Bugs/Bug_using_host_stop.cs b/src/Http/Wolverine.Http.Tests/Bugs/Bug_using_host_stop.cs
index ff0cdf696..d1b96e5b1 100644
--- a/src/Http/Wolverine.Http.Tests/Bugs/Bug_using_host_stop.cs
+++ b/src/Http/Wolverine.Http.Tests/Bugs/Bug_using_host_stop.cs
@@ -33,7 +33,7 @@ public async Task wolverine_runtime_stops_when_host_is_stopped(HostType type)
var checkPoints = new bool[2];
checkPoints[0] = IsRunning(wolverineRuntime);
- await host.StopAsync();
+ await host.StopAsync(TestContext.Current.CancellationToken);
checkPoints[1] = IsRunning(wolverineRuntime);
checkPoints.ShouldBe([true, false]);
diff --git a/src/Http/Wolverine.Http.Tests/Marten/compiled_query_writer.cs b/src/Http/Wolverine.Http.Tests/Marten/compiled_query_writer.cs
index f069ec4aa..91ee131ff 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/compiled_query_writer.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/compiled_query_writer.cs
@@ -120,7 +120,7 @@ public async Task endpoint_returning_compiled_list_query_should_return_query_res
session.Store(invoice);
}
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var approvedInvoiceList = await Host.GetAsJson>("/invoices/approved");
approvedInvoiceList.ShouldNotBeNull();
@@ -141,7 +141,7 @@ public async Task endpoint_returning_compiled_primitive_query_should_return_quer
session.Store(invoice);
}
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var invoiceCountString = await Host.GetAsText("/invoices/compiled/count");
invoiceCountString.ShouldNotBeNull();
@@ -224,7 +224,7 @@ public async Task endpoint_returning_compiled_query_should_return_query_result()
};
using var session = Store.LightweightSession();
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var invoiceCompiled = await Host.GetAsJson($"/invoices/compiled/{invoice.Id}");
diff --git a/src/Http/Wolverine.Http.Tests/Marten/document_attribute_usage.cs b/src/Http/Wolverine.Http.Tests/Marten/document_attribute_usage.cs
index 205941cb3..bbb089cdf 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/document_attribute_usage.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/document_attribute_usage.cs
@@ -28,10 +28,10 @@ public async Task returns_404_when_soft_deleted()
var invoice = new Invoice();
using var session = Store.LightweightSession();
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
session.Delete(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Scenario(x =>
{
@@ -46,7 +46,7 @@ public async Task default_to_id_route()
var invoice = new Invoice();
using var session = Store.LightweightSession();
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var invoice2 = await Host.GetAsJson("/invoices/" + invoice.Id);
@@ -59,7 +59,7 @@ public async Task try_to_use_document_name_id_naming_convention()
var invoice = new Invoice();
using var session = Store.LightweightSession();
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Host.Scenario(x =>
{
@@ -67,7 +67,7 @@ await Host.Scenario(x =>
x.StatusCodeShouldBe(204);
});
- var loaded = await session.LoadAsync(invoice.Id);
+ var loaded = await session.LoadAsync(invoice.Id, TestContext.Current.CancellationToken);
loaded!.Paid.ShouldBeTrue();
}
@@ -77,7 +77,7 @@ public async Task use_explicit_path_argument()
var invoice = new Invoice();
await using var session = Store.LightweightSession();
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Host.Scenario(x =>
{
@@ -85,7 +85,7 @@ await Host.Scenario(x =>
x.StatusCodeShouldBe(204);
});
- var loaded = await session.LoadAsync(invoice.Id);
+ var loaded = await session.LoadAsync(invoice.Id, TestContext.Current.CancellationToken);
loaded!.Approved.ShouldBeTrue();
}
}
\ No newline at end of file
diff --git a/src/Http/Wolverine.Http.Tests/Marten/message_publishing_with_entity_attribute_usage.cs b/src/Http/Wolverine.Http.Tests/Marten/message_publishing_with_entity_attribute_usage.cs
index 30a9d1bd9..25cd6ba6d 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/message_publishing_with_entity_attribute_usage.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/message_publishing_with_entity_attribute_usage.cs
@@ -17,7 +17,7 @@ public async Task call_with_completed_todo()
var todo = new Todo2 { Id = Guid.NewGuid().ToString(), IsComplete = true};
using var session = Host.DocumentStore().LightweightSession();
session.Store(todo);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var (tracked, response) = await TrackedHttpCall(x =>
{
diff --git a/src/Http/Wolverine.Http.Tests/Marten/multi_tenanted_session_factory_without_wolverine.cs b/src/Http/Wolverine.Http.Tests/Marten/multi_tenanted_session_factory_without_wolverine.cs
index 87cbec7fb..a3864b961 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/multi_tenanted_session_factory_without_wolverine.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/multi_tenanted_session_factory_without_wolverine.cs
@@ -52,7 +52,7 @@ public async Task can_do_the_tenancy_detection()
Number = 1
});
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
// Store the green doc
@@ -64,7 +64,7 @@ public async Task can_do_the_tenancy_detection()
Number = 2
});
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var blueDoc = await host.GetAsJson("/color?tenant=blue");
@@ -117,7 +117,7 @@ public async Task can_do_the_tenancy_detection_with_custom_metadata()
Number = 1
});
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
// Store the green doc
@@ -129,7 +129,7 @@ public async Task can_do_the_tenancy_detection_with_custom_metadata()
Number = 2
});
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var blueDoc = await host.GetAsJson("/color?tenant=blue");
diff --git a/src/Http/Wolverine.Http.Tests/Marten/soft_deleted_attribute_usage.cs b/src/Http/Wolverine.Http.Tests/Marten/soft_deleted_attribute_usage.cs
index 14fe44ced..76ba87063 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/soft_deleted_attribute_usage.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/soft_deleted_attribute_usage.cs
@@ -23,7 +23,7 @@ await Scenario(x =>
using var session = Host.DocumentStore().LightweightSession();
var invoice = new Invoice();
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
// second, a hit
var response = await Scenario(x =>
diff --git a/src/Http/Wolverine.Http.Tests/Marten/streaming_endpoints.cs b/src/Http/Wolverine.Http.Tests/Marten/streaming_endpoints.cs
index 9b2511cc7..c06dc654f 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/streaming_endpoints.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/streaming_endpoints.cs
@@ -27,7 +27,7 @@ public async Task stream_one_returns_matching_document_as_json()
await using (var session = Store.LightweightSession())
{
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var body = await Host.GetAsJson($"/streaming/invoice/{invoice.Id}");
@@ -44,7 +44,7 @@ public async Task stream_one_sets_content_type_and_status_on_hit()
await using (var session = Store.LightweightSession())
{
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var result = await Host.Scenario(x =>
@@ -75,7 +75,7 @@ public async Task stream_one_respects_custom_on_found_status()
await using (var session = Store.LightweightSession())
{
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
await Host.Scenario(x =>
@@ -92,7 +92,7 @@ public async Task stream_one_respects_custom_content_type()
await using (var session = Store.LightweightSession())
{
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
await Host.Scenario(x =>
@@ -110,7 +110,7 @@ public async Task stream_one_emits_etag_header_by_default()
await using (var session = Store.LightweightSession())
{
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var result = await Host.Scenario(x =>
@@ -129,7 +129,7 @@ public async Task stream_one_omits_etag_header_when_disabled()
await using (var session = Store.LightweightSession())
{
session.Store(invoice);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var result = await Host.Scenario(x =>
@@ -152,7 +152,7 @@ public async Task stream_many_returns_json_array()
await using (var session = Store.LightweightSession())
{
foreach (var id in ids) session.Store(new Invoice { Id = id, Approved = true });
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var body = await Host.GetAsJson>("/streaming/invoices/approved");
@@ -215,7 +215,7 @@ public async Task stream_paged_returns_paged_envelope()
await using (var session = Store.LightweightSession())
{
foreach (var id in ids) session.Store(new Invoice { Id = id });
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var result = await Host.Scenario(x =>
@@ -242,7 +242,7 @@ public async Task stream_paged_by_cursor_returns_items_and_next_cursor()
await using (var session = Store.LightweightSession())
{
foreach (var id in ids) session.Store(new Invoice { Id = id });
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var result = await Host.Scenario(x =>
diff --git a/src/Http/Wolverine.Http.Tests/Marten/strong_typed_identifiers.cs b/src/Http/Wolverine.Http.Tests/Marten/strong_typed_identifiers.cs
index 9b797a95e..d77a7c95a 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/strong_typed_identifiers.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/strong_typed_identifiers.cs
@@ -18,7 +18,7 @@ public async Task use_read_aggregate_by_itself()
using var session = Host.DocumentStore().LightweightSession();
session.Events.StartStream(streamId, new AEvent(), new BEvent(), new CEvent(),
new CEvent());
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var result = await Scenario(x =>
{
@@ -39,7 +39,7 @@ public async Task single_usage_of_write_aggregate()
using var session = Host.DocumentStore().LightweightSession();
session.Events.StartStream(streamId, new AEvent(), new BEvent(), new CEvent(),
new CEvent());
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Scenario(x =>
{
@@ -70,7 +70,7 @@ public async Task batch_query_usage_of_write_aggregate()
session.Events.StartStream(stream2Id, new AEvent(), new BEvent(), new BEvent(),
new AEvent());
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Scenario(x =>
{
@@ -78,10 +78,10 @@ await Scenario(x =>
x.StatusCodeShouldBe(204);
});
- var aggregate1 = await session.Events.FetchLatest(stream1Id);
+ var aggregate1 = await session.Events.FetchLatest(stream1Id, TestContext.Current.CancellationToken);
aggregate1!.BCount.ShouldBe(2);
- var aggregate2 = await session.Events.FetchLatest(stream2Id);
+ var aggregate2 = await session.Events.FetchLatest(stream2Id, TestContext.Current.CancellationToken);
aggregate2!.BCount.ShouldBe(3);
}
@@ -97,7 +97,7 @@ public async Task batch_query_with_both_read_and_write_aggregate()
session.Events.StartStream(stream2Id, new AEvent(), new BEvent(), new BEvent(),
new AEvent(), new DEvent());
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Host.Scenario(x =>
{
@@ -106,12 +106,12 @@ await Host.Scenario(x =>
x.StatusCodeShouldBe(204);
});
- var aggregate1 = await session.Events.FetchLatest(stream1Id);
+ var aggregate1 = await session.Events.FetchLatest(stream1Id, TestContext.Current.CancellationToken);
aggregate1!.BCount.ShouldBe(3);
aggregate1.ACount.ShouldBe(3);
aggregate1.DCount.ShouldBe(1);
- var aggregate2 = await session.Events.FetchLatest(stream2Id);
+ var aggregate2 = await session.Events.FetchLatest(stream2Id, TestContext.Current.CancellationToken);
aggregate2!.BCount.ShouldBe(2);
}
@@ -121,7 +121,7 @@ public async Task use_entity_or_document_attribute()
var toy = new Toy { Id = ToyId.New(), Name = "My toy" };
using var session = Host.DocumentStore().LightweightSession();
session.Store(toy);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
var result = await Scenario(x => x.Get.Url("/toys/" + toy.Id.Value));
diff --git a/src/Http/Wolverine.Http.Tests/Marten/using_aggregate_handler_workflow.cs b/src/Http/Wolverine.Http.Tests/Marten/using_aggregate_handler_workflow.cs
index ffc78d0c0..84d89fb1d 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/using_aggregate_handler_workflow.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/using_aggregate_handler_workflow.cs
@@ -30,7 +30,7 @@ await Scenario(x =>
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(status1.OrderId);
+ var order = await session.Events.AggregateStreamAsync(status1.OrderId, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Items["Socks"].Ready.ShouldBeTrue();
@@ -105,7 +105,7 @@ await Scenario(x =>
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(id);
+ var order = await session.Events.AggregateStreamAsync(id, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Items["Socks"].Ready.ShouldBeTrue();
@@ -130,7 +130,7 @@ await Scenario(x =>
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(status1.OrderId);
+ var order = await session.Events.AggregateStreamAsync(status1.OrderId, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Shipped.HasValue.ShouldBeTrue();
@@ -156,7 +156,7 @@ await Scenario(x =>
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(status1.OrderId);
+ var order = await session.Events.AggregateStreamAsync(status1.OrderId, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Shipped.HasValue.ShouldBeTrue();
@@ -182,7 +182,7 @@ await Scenario(x =>
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(status1.OrderId);
+ var order = await session.Events.AggregateStreamAsync(status1.OrderId, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Shipped.HasValue.ShouldBeTrue();
@@ -219,7 +219,7 @@ await Scenario(x =>
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(status1.OrderId);
+ var order = await session.Events.AggregateStreamAsync(status1.OrderId, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Shipped.HasValue.ShouldBeTrue();
@@ -245,7 +245,7 @@ await Scenario(x =>
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(status1.OrderId);
+ var order = await session.Events.AggregateStreamAsync(status1.OrderId, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Shipped.HasValue.ShouldBeTrue();
@@ -348,7 +348,7 @@ public async Task return_updated_aggregate_in_tuple()
order.IsConfirmed.ShouldBeTrue();
using var session = Host.DocumentStore().LightweightSession();
- var stream = await session.Events.FetchStreamAsync(status.OrderId);
+ var stream = await session.Events.FetchStreamAsync(status.OrderId, token: TestContext.Current.CancellationToken);
stream.Select(x => x.Data).OfType().Any().ShouldBeFalse();
}
diff --git a/src/Http/Wolverine.Http.Tests/Marten/using_ancillary_stores.cs b/src/Http/Wolverine.Http.Tests/Marten/using_ancillary_stores.cs
index ac43d094a..dc43c59a2 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/using_ancillary_stores.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/using_ancillary_stores.cs
@@ -26,7 +26,7 @@ public async Task create_new_thing_with_different_identity()
var store = Host.DocumentStore();
using var session = store.LightweightSession();
- var thing = await session.Events.FetchLatest(response.Id);
+ var thing = await session.Events.FetchLatest(response.Id, TestContext.Current.CancellationToken);
thing.ShouldNotBeNull();
}
}
\ No newline at end of file
diff --git a/src/Http/Wolverine.Http.Tests/Marten/using_version_source_override.cs b/src/Http/Wolverine.Http.Tests/Marten/using_version_source_override.cs
index 7ae0b44a9..230731bf5 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/using_version_source_override.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/using_version_source_override.cs
@@ -32,7 +32,7 @@ await Scenario(x =>
});
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(orderId);
+ var order = await session.Events.AggregateStreamAsync(orderId, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Shipped.HasValue.ShouldBeTrue();
}
@@ -64,7 +64,7 @@ await Scenario(x =>
});
await using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(orderId);
+ var order = await session.Events.AggregateStreamAsync(orderId, token: TestContext.Current.CancellationToken);
order.ShouldNotBeNull();
order.Shipped.HasValue.ShouldBeTrue();
}
diff --git a/src/Http/Wolverine.Http.Tests/Marten/write_aggregate_with_asparameters.cs b/src/Http/Wolverine.Http.Tests/Marten/write_aggregate_with_asparameters.cs
index cfe4c7238..f00bc023b 100644
--- a/src/Http/Wolverine.Http.Tests/Marten/write_aggregate_with_asparameters.cs
+++ b/src/Http/Wolverine.Http.Tests/Marten/write_aggregate_with_asparameters.cs
@@ -32,7 +32,7 @@ await Scenario(x =>
// The OrderShipped event was appended to the resolved stream
using var session = Store.LightweightSession();
- var order = await session.Events.AggregateStreamAsync(id);
+ var order = await session.Events.AggregateStreamAsync(id, token: TestContext.Current.CancellationToken);
order!.IsShipped().ShouldBeTrue();
}
}
diff --git a/src/Http/Wolverine.Http.Tests/MultiTenancy/multi_tenancy_detection_and_integration.cs b/src/Http/Wolverine.Http.Tests/MultiTenancy/multi_tenancy_detection_and_integration.cs
index af607a48c..57ac254bd 100644
--- a/src/Http/Wolverine.Http.Tests/MultiTenancy/multi_tenancy_detection_and_integration.cs
+++ b/src/Http/Wolverine.Http.Tests/MultiTenancy/multi_tenancy_detection_and_integration.cs
@@ -300,7 +300,7 @@ await configure(opts =>
await theHost.Services.GetRequiredService().Advanced.Clean
- .DeleteDocumentsByTypeAsync(typeof(TenantTodo));
+ .DeleteDocumentsByTypeAsync(typeof(TenantTodo), TestContext.Current.CancellationToken);
// Create todo to "red"
await theHost.Scenario(x =>
diff --git a/src/Http/Wolverine.Http.Tests/Transport/HttpScheduledMessageTests.cs b/src/Http/Wolverine.Http.Tests/Transport/HttpScheduledMessageTests.cs
index a8c4ccdda..8bbb409a9 100644
--- a/src/Http/Wolverine.Http.Tests/Transport/HttpScheduledMessageTests.cs
+++ b/src/Http/Wolverine.Http.Tests/Transport/HttpScheduledMessageTests.cs
@@ -63,7 +63,7 @@ public async Task should_delay_execution_of_scheduled_message()
await bus.ScheduleAsync(command, scheduledTime);
}
- await Task.Delay(500); // some delay for batching
+ await Task.Delay(500, TestContext.Current.CancellationToken); // some delay for batching
tracker.ReceivedMessages.Count.ShouldBe(count);
}
}
diff --git a/src/Http/Wolverine.Http.Tests/Transport/HttpTransportConfigurationTests.cs b/src/Http/Wolverine.Http.Tests/Transport/HttpTransportConfigurationTests.cs
index 65afad9cf..f973bb9ee 100644
--- a/src/Http/Wolverine.Http.Tests/Transport/HttpTransportConfigurationTests.cs
+++ b/src/Http/Wolverine.Http.Tests/Transport/HttpTransportConfigurationTests.cs
@@ -20,7 +20,7 @@ public async Task to_http_endpoint_creates_endpoint_with_correct_uri()
opts.PublishAllMessages()
.ToHttpEndpoint("https://external-service.com/api");
})
- .StartAsync();
+ .StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var runtime = host.GetRuntime();
var transport = runtime.Options.Transports.GetOrCreate();
@@ -39,7 +39,7 @@ public async Task to_http_endpoint_with_native_scheduled_send_sets_flag()
opts.PublishAllMessages()
.ToHttpEndpoint("https://scheduler.com/api", supportsNativeScheduledSend: true);
})
- .StartAsync();
+ .StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var runtime = host.GetRuntime();
var transport = runtime.Options.Transports.GetOrCreate();
@@ -57,7 +57,7 @@ public async Task to_http_endpoint_without_native_scheduled_send_defaults_to_fal
opts.PublishAllMessages()
.ToHttpEndpoint("https://regular.com/api");
})
- .StartAsync();
+ .StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var runtime = host.GetRuntime();
var transport = runtime.Options.Transports.GetOrCreate();
@@ -83,7 +83,7 @@ public async Task to_http_endpoint_with_cloud_events_sets_serializer_options()
useCloudEvents: true,
options: customOptions);
})
- .StartAsync();
+ .StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var runtime = host.GetRuntime();
var transport = runtime.Options.Transports.GetOrCreate();
@@ -104,7 +104,7 @@ public async Task to_http_endpoint_without_cloud_events_keeps_default_options()
opts.PublishAllMessages()
.ToHttpEndpoint("https://binary.com/api");
})
- .StartAsync();
+ .StartAsync(cancellationToken: TestContext.Current.CancellationToken);
#endregion
@@ -128,7 +128,7 @@ public async Task to_http_endpoint_returns_subscriber_configuration()
config.ShouldBeOfType();
})
- .StartAsync();
+ .StartAsync(cancellationToken: TestContext.Current.CancellationToken);
}
[Fact]
@@ -142,7 +142,7 @@ public async Task can_chain_subscriber_configuration_methods()
.SendInline()
.CustomizeOutgoing(e => e.CorrelationId = "test-correlation");
})
- .StartAsync();
+ .StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var runtime = host.GetRuntime();
var transport = runtime.Options.Transports.GetOrCreate();
diff --git a/src/Http/Wolverine.Http.Tests/Transport/inline_request_reply_sender.cs b/src/Http/Wolverine.Http.Tests/Transport/inline_request_reply_sender.cs
index 197d84834..faf44953e 100644
--- a/src/Http/Wolverine.Http.Tests/Transport/inline_request_reply_sender.cs
+++ b/src/Http/Wolverine.Http.Tests/Transport/inline_request_reply_sender.cs
@@ -35,9 +35,9 @@ private static IHostBuilder ConfigureSender(IWolverineHttpTransportClient client
[Fact]
public async Task invoke_reads_reply_from_the_http_response_slot()
{
- using var host = await ConfigureSender(new EchoingInlineClient()).StartAsync();
+ using var host = await ConfigureSender(new EchoingInlineClient()).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
- var response = await host.MessageBus().InvokeAsync(new InlineProbeRequest("Egwene"));
+ var response = await host.MessageBus().InvokeAsync(new InlineProbeRequest("Egwene"), TestContext.Current.CancellationToken);
response.ShouldNotBeNull();
response.Name.ShouldBe("Egwene");
@@ -46,7 +46,7 @@ public async Task invoke_reads_reply_from_the_http_response_slot()
[Fact]
public async Task handler_failure_surfaces_as_request_reply_exception()
{
- using var host = await ConfigureSender(new FailingInlineClient()).StartAsync();
+ using var host = await ConfigureSender(new FailingInlineClient()).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var ex = await Should.ThrowAsync(async () =>
await host.MessageBus().InvokeAsync(new InlineProbeRequest("Nynaeve")));
diff --git a/src/Http/Wolverine.Http.Tests/Wolverine.Http.Tests.csproj b/src/Http/Wolverine.Http.Tests/Wolverine.Http.Tests.csproj
index dea0721a5..57862e216 100644
--- a/src/Http/Wolverine.Http.Tests/Wolverine.Http.Tests.csproj
+++ b/src/Http/Wolverine.Http.Tests/Wolverine.Http.Tests.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
false
net9.0
diff --git a/src/Http/Wolverine.Http.Tests/accepts_content_type_negative_cases_3649.cs b/src/Http/Wolverine.Http.Tests/accepts_content_type_negative_cases_3649.cs
index f4481fe9e..dffa2797b 100644
--- a/src/Http/Wolverine.Http.Tests/accepts_content_type_negative_cases_3649.cs
+++ b/src/Http/Wolverine.Http.Tests/accepts_content_type_negative_cases_3649.cs
@@ -145,7 +145,7 @@ public async Task a_method_mismatch_is_still_405_not_415()
// GET /content-negotiation/items carries no Content-Type, so the 415 substitution must not swallow the
// 405 that HttpMethodMatcherPolicy (Order 0) has already decided on. The policy only records candidates
// that were valid when it saw them, which is what keeps these two apart.
- var response = await Host.Server.CreateClient().GetAsync("/content-negotiation/items");
+ var response = await Host.Server.CreateClient().GetAsync("/content-negotiation/items", TestContext.Current.CancellationToken);
response.StatusCode.ShouldBe(HttpStatusCode.MethodNotAllowed);
}
diff --git a/src/Http/Wolverine.Http.Tests/api_explorer_before_host_start.cs b/src/Http/Wolverine.Http.Tests/api_explorer_before_host_start.cs
index bc1fc382b..c7132c205 100644
--- a/src/Http/Wolverine.Http.Tests/api_explorer_before_host_start.cs
+++ b/src/Http/Wolverine.Http.Tests/api_explorer_before_host_start.cs
@@ -72,7 +72,7 @@ public async Task publishing_endpoints_early_does_not_duplicate_them_when_the_ho
// Forces the early publish, exactly as a build-time OpenAPI read or a monitoring snapshot would
readDescriptions(app).ShouldNotBeEmpty();
- await app.StartAsync();
+ await app.StartAsync(TestContext.Current.CancellationToken);
var routes = app.Services.GetRequiredService().Endpoints
.OfType()
@@ -84,9 +84,9 @@ public async Task publishing_endpoints_early_does_not_duplicate_them_when_the_ho
// The proof that matters: an ambiguous match would throw here rather than answer
var client = app.GetTestServer().CreateClient();
- (await client.GetAsync("/minimal/hello")).EnsureSuccessStatusCode();
+ (await client.GetAsync("/minimal/hello", TestContext.Current.CancellationToken)).EnsureSuccessStatusCode();
- await app.StopAsync();
+ await app.StopAsync(TestContext.Current.CancellationToken);
}
// Endpoints are only ever published from the application's root route builder. MapWolverineEndpoints()
@@ -103,7 +103,7 @@ public async Task wolverine_endpoints_mapped_into_a_route_group_are_registered_e
// Forces the publish, exactly as a build-time OpenAPI read or a monitoring snapshot would
readDescriptions(app).ShouldNotBeEmpty();
- await app.StartAsync();
+ await app.StartAsync(TestContext.Current.CancellationToken);
var routes = app.Services.GetRequiredService().Endpoints
.OfType()
@@ -113,7 +113,7 @@ public async Task wolverine_endpoints_mapped_into_a_route_group_are_registered_e
routes.Count(x => x == "/api/validate2/customer").ShouldBe(1);
routes.ShouldNotContain("/validate2/customer");
- await app.StopAsync();
+ await app.StopAsync(TestContext.Current.CancellationToken);
}
// Wolverine reaches RouteOptions.EndpointDataSources — internal to Microsoft.AspNetCore.Routing —
diff --git a/src/Http/Wolverine.Http.Tests/building_a_saga_and_publishing_other_messages_from_http_endpoint.cs b/src/Http/Wolverine.Http.Tests/building_a_saga_and_publishing_other_messages_from_http_endpoint.cs
index ae3675416..8d7bbc42b 100644
--- a/src/Http/Wolverine.Http.Tests/building_a_saga_and_publishing_other_messages_from_http_endpoint.cs
+++ b/src/Http/Wolverine.Http.Tests/building_a_saga_and_publishing_other_messages_from_http_endpoint.cs
@@ -15,7 +15,7 @@ public building_a_saga_and_publishing_other_messages_from_http_endpoint(AppFixtu
public async Task can_create_saga_and_publish_message()
{
await Host.GetRuntime().Storage.Admin.ClearAllAsync();
- await Store.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Reservation));
+ await Store.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Reservation), TestContext.Current.CancellationToken);
IScenarioResult result = null!;
@@ -34,7 +34,7 @@ await Host
.ExecuteAndWaitAsync(action);
using var session = Store.LightweightSession();
- var reservation = await session.LoadAsync("dinner");
+ var reservation = await session.LoadAsync("dinner", TestContext.Current.CancellationToken);
reservation.ShouldNotBeNull();
var @event = await result.ReadAsJsonAsync();
diff --git a/src/Http/Wolverine.Http.Tests/from_form_file_binding.cs b/src/Http/Wolverine.Http.Tests/from_form_file_binding.cs
index f699b6895..a58abee90 100644
--- a/src/Http/Wolverine.Http.Tests/from_form_file_binding.cs
+++ b/src/Http/Wolverine.Http.Tests/from_form_file_binding.cs
@@ -16,8 +16,8 @@ public async Task bind_single_file_on_complex_model()
content.Add(new StringContent("test-name"), "Name");
content.Add(new ByteArrayContent(new byte[] { 1, 2, 3 }), "File", "test.txt");
- var response = await Host.Server.CreateClient().PostAsync("/api/fromform-file", content);
- var text = await response.Content.ReadAsStringAsync();
+ var response = await Host.Server.CreateClient().PostAsync("/api/fromform-file", content, TestContext.Current.CancellationToken);
+ var text = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
response.EnsureSuccessStatusCode();
text.ShouldBe("test-name|test.txt|3");
}
@@ -30,9 +30,9 @@ public async Task bind_file_collection_on_complex_model()
content.Add(new ByteArrayContent(new byte[] { 1, 2, 3 }), "Files", "file1.txt");
content.Add(new ByteArrayContent(new byte[] { 4, 5 }), "Files", "file2.txt");
- var response = await Host.Server.CreateClient().PostAsync("/api/fromform-files", content);
+ var response = await Host.Server.CreateClient().PostAsync("/api/fromform-files", content, TestContext.Current.CancellationToken);
response.EnsureSuccessStatusCode();
- var text = await response.Content.ReadAsStringAsync();
+ var text = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
text.ShouldBe("test-name|2");
}
@@ -42,9 +42,9 @@ public async Task bind_file_on_complex_model_when_no_file_sent()
var content = new MultipartFormDataContent();
content.Add(new StringContent("test-name"), "Name");
- var response = await Host.Server.CreateClient().PostAsync("/api/fromform-file", content);
+ var response = await Host.Server.CreateClient().PostAsync("/api/fromform-file", content, TestContext.Current.CancellationToken);
response.EnsureSuccessStatusCode();
- var text = await response.Content.ReadAsStringAsync();
+ var text = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
text.ShouldBe("test-name||");
}
@@ -55,9 +55,9 @@ public async Task bind_multiple_named_files()
content.Add(new ByteArrayContent(new byte[] { 1, 2, 3 }), "document", "doc.pdf");
content.Add(new ByteArrayContent(new byte[] { 4, 5 }), "thumbnail", "thumb.jpg");
- var response = await Host.Server.CreateClient().PostAsync("/upload/named-files", content);
+ var response = await Host.Server.CreateClient().PostAsync("/upload/named-files", content, TestContext.Current.CancellationToken);
response.EnsureSuccessStatusCode();
- var text = await response.Content.ReadAsStringAsync();
+ var text = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
text.ShouldBe("doc.pdf|3|thumb.jpg|2");
}
@@ -69,9 +69,9 @@ public async Task bind_fromform_complex_type_with_separate_file()
content.Add(new StringContent("A description"), "Description");
content.Add(new ByteArrayContent(new byte[] { 1, 2, 3 }), "file", "test.pdf");
- var response = await Host.Server.CreateClient().PostAsync("/upload/mixed", content);
+ var response = await Host.Server.CreateClient().PostAsync("/upload/mixed", content, TestContext.Current.CancellationToken);
response.EnsureSuccessStatusCode();
- var text = await response.Content.ReadAsStringAsync();
+ var text = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
text.ShouldBe("My Document|A description|test.pdf|3");
}
@@ -83,9 +83,9 @@ public async Task bind_iform_collection()
content.Add(new StringContent("value2"), "key2");
content.Add(new ByteArrayContent(new byte[] { 1 }), "file", "test.txt");
- var response = await Host.Server.CreateClient().PostAsync("/upload/form-collection", content);
+ var response = await Host.Server.CreateClient().PostAsync("/upload/form-collection", content, TestContext.Current.CancellationToken);
response.EnsureSuccessStatusCode();
- var text = await response.Content.ReadAsStringAsync();
+ var text = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
text.ShouldBe("keys:key1,key2|files:1");
}
}
diff --git a/src/Http/Wolverine.Http.Tests/query_verb_support.cs b/src/Http/Wolverine.Http.Tests/query_verb_support.cs
index e5150da11..b0bb9f191 100644
--- a/src/Http/Wolverine.Http.Tests/query_verb_support.cs
+++ b/src/Http/Wolverine.Http.Tests/query_verb_support.cs
@@ -28,10 +28,10 @@ public async Task query_endpoint_reads_request_body_and_returns_result()
Content = JsonContent.Create(new SearchRequest("widget", 3))
};
- var response = await client.SendAsync(request);
+ var response = await client.SendAsync(request, TestContext.Current.CancellationToken);
response.StatusCode.ShouldBe(HttpStatusCode.OK);
- var results = await response.Content.ReadFromJsonAsync();
+ var results = await response.Content.ReadFromJsonAsync(cancellationToken: TestContext.Current.CancellationToken);
results.ShouldNotBeNull();
results.Term.ShouldBe("widget");
results.Page.ShouldBe(3);
diff --git a/src/Http/Wolverine.Http.Tests/todo_endpoint_specs.cs b/src/Http/Wolverine.Http.Tests/todo_endpoint_specs.cs
index 93c2f30b8..caf850018 100644
--- a/src/Http/Wolverine.Http.Tests/todo_endpoint_specs.cs
+++ b/src/Http/Wolverine.Http.Tests/todo_endpoint_specs.cs
@@ -22,7 +22,7 @@ public async Task wolverine_can_handle_route_constraints(string baseUrl)
await using var session = Store.LightweightSession();
var todo = new Todo { Name = "First", IsComplete = false };
session.Store(todo);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Scenario(opts =>
{
@@ -30,7 +30,7 @@ await Scenario(opts =>
opts.StatusCodeShouldBe(204);
});
- var changes = await session.LoadAsync(todo.Id);
+ var changes = await session.LoadAsync(todo.Id, TestContext.Current.CancellationToken);
changes!.IsComplete.ShouldBeTrue();
changes.Name.ShouldBe("Second");
}
@@ -41,14 +41,14 @@ public async Task bug_466_codegen_error()
await using var session = Store.LightweightSession();
var todo = new Todo { Name = "First", IsComplete = false };
session.Store(todo);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
await Scenario(opts =>
{
opts.Put.Json(new UpdateRequest("Second", true)).ToUrl("/todos2/" + todo.Id);
});
- var changes = await session.LoadAsync(todo.Id);
+ var changes = await session.LoadAsync(todo.Id, TestContext.Current.CancellationToken);
changes!.IsComplete.ShouldBeTrue();
changes.Name.ShouldBe("Second");
}
diff --git a/src/Http/Wolverine.Http.Tests/using_create_response_and_metadata_derived_from_response_type.cs b/src/Http/Wolverine.Http.Tests/using_create_response_and_metadata_derived_from_response_type.cs
index 76e5b63ed..17410c9db 100644
--- a/src/Http/Wolverine.Http.Tests/using_create_response_and_metadata_derived_from_response_type.cs
+++ b/src/Http/Wolverine.Http.Tests/using_create_response_and_metadata_derived_from_response_type.cs
@@ -36,7 +36,7 @@ public void read_metadata_from_IEndpointMetadataProvider()
[Fact]
public async Task make_the_request()
{
- await Store.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Issue));
+ await Store.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Issue), TestContext.Current.CancellationToken);
var result = await Scenario(x =>
{
@@ -48,7 +48,7 @@ public async Task make_the_request()
created.ShouldNotBeNull();
using var session = Store.LightweightSession();
- var issue = await session.LoadAsync(created.Id);
+ var issue = await session.LoadAsync(created.Id, TestContext.Current.CancellationToken);
issue.ShouldNotBeNull();
issue.Title.ShouldBe("It's bad");
diff --git a/src/Http/Wolverine.Http.Tests/using_efcore.cs b/src/Http/Wolverine.Http.Tests/using_efcore.cs
index 53c70c7b9..f3566774e 100644
--- a/src/Http/Wolverine.Http.Tests/using_efcore.cs
+++ b/src/Http/Wolverine.Http.Tests/using_efcore.cs
@@ -35,7 +35,7 @@ await Scenario(x =>
using var nested = Host.Services.CreateScope();
var context = nested.ServiceProvider.GetRequiredService();
- var item = await context.Items.Where(x => x.Name == command.Name).FirstOrDefaultAsync();
+ var item = await context.Items.Where(x => x.Name == command.Name).FirstOrDefaultAsync(cancellationToken: TestContext.Current.CancellationToken);
item.ShouldNotBeNull();
}
@@ -55,7 +55,7 @@ public async Task using_db_context_with_outbox()
using var nested = Host.Services.CreateScope();
var context = nested.ServiceProvider.GetRequiredService();
- var item = await context.Items.Where(x => x.Name == command.Name).FirstOrDefaultAsync();
+ var item = await context.Items.Where(x => x.Name == command.Name).FirstOrDefaultAsync(cancellationToken: TestContext.Current.CancellationToken);
item.ShouldNotBeNull();
tracked.Sent.SingleMessage()
@@ -100,7 +100,7 @@ public async Task using_db_context_with_outbox_schedule()
using var nested = Host.Services.CreateScope();
var context = nested.ServiceProvider.GetRequiredService();
- var item = await context.Items.Where(x => x.Name == command.Name).FirstOrDefaultAsync();
+ var item = await context.Items.Where(x => x.Name == command.Name).FirstOrDefaultAsync(cancellationToken: TestContext.Current.CancellationToken);
item.ShouldBeNull();
var records = tracked.AllRecordsInOrder().ToArray();
@@ -126,7 +126,7 @@ public async Task using_db_context_with_outbox_schedule2()
using var nested = Host.Services.CreateScope();
var context = nested.ServiceProvider.GetRequiredService();
- var item = await context.Items.Where(x => x.Name == command.Name).FirstOrDefaultAsync();
+ var item = await context.Items.Where(x => x.Name == command.Name).FirstOrDefaultAsync(cancellationToken: TestContext.Current.CancellationToken);
item.ShouldBeNull();
var scheduledMessage = tracked.Scheduled.SingleEnvelope();
diff --git a/src/Http/Wolverine.Http.Tests/using_marten.cs b/src/Http/Wolverine.Http.Tests/using_marten.cs
index e2ed47ec7..bc1fd3224 100644
--- a/src/Http/Wolverine.Http.Tests/using_marten.cs
+++ b/src/Http/Wolverine.Http.Tests/using_marten.cs
@@ -18,7 +18,7 @@ public async Task use_marten_document_session_without_outbox()
using (var session = Store.LightweightSession())
{
session.Store(data);
- await session.SaveChangesAsync();
+ await session.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var result = await Host.GetAsJson($"/data/{data.Id}");
@@ -42,7 +42,7 @@ public async Task use_marten_document_session_with_outbox()
published.Name.ShouldBe(input.Name);
using var session = Store.LightweightSession();
- var loaded = await session.LoadAsync(input.Id);
+ var loaded = await session.LoadAsync(input.Id, TestContext.Current.CancellationToken);
loaded.ShouldNotBeNull();
}
diff --git a/src/Persistence/CosmosDbTests/CosmosDbTests.csproj b/src/Persistence/CosmosDbTests/CosmosDbTests.csproj
index 883522e96..85cc1c48b 100644
--- a/src/Persistence/CosmosDbTests/CosmosDbTests.csproj
+++ b/src/Persistence/CosmosDbTests/CosmosDbTests.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
net9.0
enable
diff --git a/src/Persistence/CosmosDbTests/end_to_end.cs b/src/Persistence/CosmosDbTests/end_to_end.cs
index 8dddea92b..b0361842c 100644
--- a/src/Persistence/CosmosDbTests/end_to_end.cs
+++ b/src/Persistence/CosmosDbTests/end_to_end.cs
@@ -29,7 +29,7 @@ public async Task can_send_and_receive_messages()
opts.UseCosmosDbPersistence(AppFixture.DatabaseName);
opts.Services.AddSingleton(_fixture.Client);
opts.Discovery.IncludeAssembly(GetType().Assembly);
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var tracked = await host.InvokeMessageAndWaitAsync(new SmokeTestMessage("Hello, CosmosDb!"));
diff --git a/src/Persistence/CosmosDbTests/saga_optimistic_concurrency.cs b/src/Persistence/CosmosDbTests/saga_optimistic_concurrency.cs
index 66b8228e0..5e33369b6 100644
--- a/src/Persistence/CosmosDbTests/saga_optimistic_concurrency.cs
+++ b/src/Persistence/CosmosDbTests/saga_optimistic_concurrency.cs
@@ -51,7 +51,7 @@ public async Task stale_write_is_surfaced_as_SagaConcurrencyException()
var bus = host.MessageBus();
var id = Guid.NewGuid().ToString();
- await bus.InvokeAsync(new StartCounter(id));
+ await bus.InvokeAsync(new StartCounter(id), TestContext.Current.CancellationToken);
// Interfere exactly the way a second node would: the handler reads the saga, then another writer
// commits a new revision of the same document before this message gets to write. Without the
@@ -73,7 +73,7 @@ public async Task concurrent_messages_against_one_saga_both_get_applied()
opts.Policies.OnException().RetryTimes(5));
var id = Guid.NewGuid().ToString();
- await host.MessageBus().InvokeAsync(new StartCounter(id));
+ await host.MessageBus().InvokeAsync(new StartCounter(id), TestContext.Current.CancellationToken);
// Both handlers pause between the saga read and the saga write, so both genuinely read Count = 0.
// Pre-fix, the loser's blind upsert overwrote the winner and Count ended at 1 with no error at all.
@@ -81,8 +81,10 @@ public async Task concurrent_messages_against_one_saga_both_get_applied()
// driven concurrently.
var pause = TimeSpan.FromMilliseconds(500);
await Task.WhenAll(
- host.MessageBus().InvokeAsync(new IncrementCounter(id) { Delay = pause }),
- host.MessageBus().InvokeAsync(new IncrementCounter(id) { Delay = pause }));
+ host.MessageBus().InvokeAsync(new IncrementCounter(id) { Delay = pause },
+ TestContext.Current.CancellationToken),
+ host.MessageBus().InvokeAsync(new IncrementCounter(id) { Delay = pause },
+ TestContext.Current.CancellationToken));
var saga = await loadAsync(id);
saga!.Count.ShouldBe(2);
@@ -97,7 +99,7 @@ public async Task stale_delete_of_a_completed_saga_is_surfaced_as_SagaConcurrenc
var bus = host.MessageBus();
var id = Guid.NewGuid().ToString();
- await bus.InvokeAsync(new StartCounter(id));
+ await bus.InvokeAsync(new StartCounter(id), TestContext.Current.CancellationToken);
// Completing a saga deletes the document. A blind delete would drop the interfering writer's
// revision just as silently as a blind upsert would.
diff --git a/src/Persistence/CosmosDbTests/saga_partitioning.cs b/src/Persistence/CosmosDbTests/saga_partitioning.cs
index 6c10d938d..d2b5bb8fd 100644
--- a/src/Persistence/CosmosDbTests/saga_partitioning.cs
+++ b/src/Persistence/CosmosDbTests/saga_partitioning.cs
@@ -37,7 +37,7 @@ public async Task partitioned_saga_lives_in_the_partition_keyed_by_its_own_id()
using var host = await buildHostAsync(partitionById: true);
var id = Guid.NewGuid().ToString();
- await host.MessageBus().InvokeAsync(new StartPartitioned(id));
+ await host.MessageBus().InvokeAsync(new StartPartitioned(id), TestContext.Current.CancellationToken);
// The point read CosmosDB is at its best on: id and partition key are the same value
var saga = await loadAsync(id, new PartitionKey(id));
@@ -61,7 +61,7 @@ public async Task saga_stays_in_the_undefined_partition_by_default()
using var host = await buildHostAsync(partitionById: false);
var id = Guid.NewGuid().ToString();
- await host.MessageBus().InvokeAsync(new StartPartitioned(id));
+ await host.MessageBus().InvokeAsync(new StartPartitioned(id), TestContext.Current.CancellationToken);
(await loadAsync(id, PartitionKey.None)).ShouldNotBeNull();
(await loadAsync(id, new PartitionKey(id))).ShouldBeNull();
@@ -77,14 +77,14 @@ public async Task partitioned_saga_can_be_updated_and_completed()
using var host = await buildHostAsync(partitionById: true);
var id = Guid.NewGuid().ToString();
- await host.MessageBus().InvokeAsync(new StartPartitioned(id));
- await host.MessageBus().InvokeAsync(new IncrementPartitioned(id));
- await host.MessageBus().InvokeAsync(new IncrementPartitioned(id));
+ await host.MessageBus().InvokeAsync(new StartPartitioned(id), TestContext.Current.CancellationToken);
+ await host.MessageBus().InvokeAsync(new IncrementPartitioned(id), TestContext.Current.CancellationToken);
+ await host.MessageBus().InvokeAsync(new IncrementPartitioned(id), TestContext.Current.CancellationToken);
var saga = await loadAsync(id, new PartitionKey(id));
saga!.Count.ShouldBe(2);
- await host.MessageBus().InvokeAsync(new CompletePartitioned(id));
+ await host.MessageBus().InvokeAsync(new CompletePartitioned(id), TestContext.Current.CancellationToken);
(await loadAsync(id, new PartitionKey(id))).ShouldBeNull();
}
@@ -100,7 +100,7 @@ public async Task optimistic_concurrency_still_holds_for_a_partitioned_saga()
var bus = host.MessageBus();
var id = Guid.NewGuid().ToString();
- await bus.InvokeAsync(new StartPartitioned(id));
+ await bus.InvokeAsync(new StartPartitioned(id), TestContext.Current.CancellationToken);
// Commit a competing revision of the document between this message's read and its write, exactly as a
// second node handling another message for this saga would
@@ -122,7 +122,7 @@ public async Task saga_stored_through_a_storage_action_lands_in_its_own_partitio
using var host = await buildHostAsync(partitionById: true);
var id = Guid.NewGuid().ToString();
- await host.MessageBus().InvokeAsync(new StorePartitionedDirectly(id));
+ await host.MessageBus().InvokeAsync(new StorePartitionedDirectly(id), TestContext.Current.CancellationToken);
var saga = await loadAsync(id, new PartitionKey(id));
saga!.Count.ShouldBe(StorePartitionedDirectlyHandler.StoredCount);
diff --git a/src/Persistence/CosmosDbTests/using_storage_return_types_and_entity_attributes.cs b/src/Persistence/CosmosDbTests/using_storage_return_types_and_entity_attributes.cs
index 67dffb4b2..87fc7dc07 100644
--- a/src/Persistence/CosmosDbTests/using_storage_return_types_and_entity_attributes.cs
+++ b/src/Persistence/CosmosDbTests/using_storage_return_types_and_entity_attributes.cs
@@ -29,7 +29,7 @@ public async Task can_use_cosmosdb_ops_as_side_effects()
opts.UseCosmosDbPersistence(AppFixture.DatabaseName);
opts.Services.AddSingleton(_fixture.Client);
opts.Discovery.IncludeAssembly(GetType().Assembly);
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var tracked = await host.InvokeMessageAndWaitAsync(new CreateDocument("doc1", "Test Document"));
tracked.Executed.MessagesOf().Any().ShouldBeTrue();
diff --git a/src/Persistence/EfCoreTests.MultiTenancy/Bug_2739_host_build_with_managed_multi_tenancy.cs b/src/Persistence/EfCoreTests.MultiTenancy/Bug_2739_host_build_with_managed_multi_tenancy.cs
index 57d64bc2c..b2f3319ac 100644
--- a/src/Persistence/EfCoreTests.MultiTenancy/Bug_2739_host_build_with_managed_multi_tenancy.cs
+++ b/src/Persistence/EfCoreTests.MultiTenancy/Bug_2739_host_build_with_managed_multi_tenancy.cs
@@ -88,7 +88,7 @@ public async Task host_build_does_not_throw_with_AddDbContextWithWolverineManage
});
using var host = builder.Build();
- await host.StartAsync();
+ await host.StartAsync(TestContext.Current.CancellationToken);
// Force WolverineOptions singleton resolution. The bug from #2739
// fires inside the WolverineOptions factory lambda in
diff --git a/src/Persistence/EfCoreTests.MultiTenancy/Bug_3497_model_cache_key_includes_wolverine_schema.cs b/src/Persistence/EfCoreTests.MultiTenancy/Bug_3497_model_cache_key_includes_wolverine_schema.cs
index 26f7b0eee..e6e6d92a6 100644
--- a/src/Persistence/EfCoreTests.MultiTenancy/Bug_3497_model_cache_key_includes_wolverine_schema.cs
+++ b/src/Persistence/EfCoreTests.MultiTenancy/Bug_3497_model_cache_key_includes_wolverine_schema.cs
@@ -31,7 +31,7 @@ public async Task two_hosts_with_different_wolverine_schemas_get_distinct_envelo
opts.PersistMessagesWithPostgresql(Servers.PostgresConnectionString, "bug3497_a");
opts.Services.AddDbContextWithWolverineIntegration(
x => x.UseNpgsql(Servers.PostgresConnectionString));
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
using var hostB = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
@@ -41,7 +41,7 @@ public async Task two_hosts_with_different_wolverine_schemas_get_distinct_envelo
opts.PersistMessagesWithPostgresql(Servers.PostgresConnectionString, "bug3497_b");
opts.Services.AddDbContextWithWolverineIntegration(
x => x.UseNpgsql(Servers.PostgresConnectionString));
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
using var scopeA = hostA.Services.CreateScope();
using var scopeB = hostB.Services.CreateScope();
diff --git a/src/Persistence/EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedPartitioningCompliance.cs b/src/Persistence/EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedPartitioningCompliance.cs
index 8026d659f..0f502d960 100644
--- a/src/Persistence/EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedPartitioningCompliance.cs
+++ b/src/Persistence/EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedPartitioningCompliance.cs
@@ -196,8 +196,8 @@ public async Task ef_model_keys_stay_single_and_sqlserver_maps_the_ordinal_colum
[Fact]
public async Task add_tenants_then_write_and_read_per_tenant()
{
- await thePartitions.AddTenantAsync("green");
- await thePartitions.AddTenantAsync("blue");
+ await thePartitions.AddTenantAsync("green", TestContext.Current.CancellationToken);
+ await thePartitions.AddTenantAsync("blue", TestContext.Current.CancellationToken);
var greenId = Guid.NewGuid();
var blueId = Guid.NewGuid();
@@ -205,17 +205,17 @@ public async Task add_tenants_then_write_and_read_per_tenant()
await theHost.ExecuteAndWaitAsync(c => c.InvokeForTenantAsync("blue", new CreatePartitionedItem(blueId, "b")));
var green = await theBuilder.BuildAsync("green", CancellationToken.None);
- (await green.Items.ToListAsync()).Single().Id.ShouldBe(greenId);
+ (await green.Items.ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(greenId);
var blue = await theBuilder.BuildAsync("blue", CancellationToken.None);
- (await blue.Items.ToListAsync()).Single().Id.ShouldBe(blueId);
+ (await blue.Items.ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(blueId);
}
[Fact]
public async Task adding_the_same_tenant_twice_is_idempotent()
{
- await thePartitions.AddTenantAsync("green");
- await thePartitions.AddTenantAsync("green");
+ await thePartitions.AddTenantAsync("green", TestContext.Current.CancellationToken);
+ await thePartitions.AddTenantAsync("green", TestContext.Current.CancellationToken);
}
[Fact]
@@ -238,7 +238,7 @@ public async Task add_tenants_reports_the_outcome_for_every_managed_table()
{
["green"] = null,
["blue"] = null
- });
+ }, TestContext.Current.CancellationToken);
result.Succeeded.ShouldBeTrue();
result.Failures.ShouldBeEmpty();
@@ -264,15 +264,15 @@ public async Task add_tenants_reports_the_outcome_for_every_managed_table()
[Fact]
public async Task back_fill_reconciles_every_managed_table_and_is_idempotent()
{
- await thePartitions.AddTenantAsync("green");
- await thePartitions.AddTenantAsync("blue");
+ await thePartitions.AddTenantAsync("green", TestContext.Current.CancellationToken);
+ await thePartitions.AddTenantAsync("blue", TestContext.Current.CancellationToken);
- var first = await thePartitions.MigrateTenantPartitionsAsync();
+ var first = await thePartitions.MigrateTenantPartitionsAsync(TestContext.Current.CancellationToken);
first.Succeeded.ShouldBeTrue();
first.Tables.ShouldContain(x => x.TableName.Contains("partitioned_items"));
// Back-fill is a reconcile, not a one-shot -- re-running it changes nothing
- var second = await thePartitions.MigrateTenantPartitionsAsync();
+ var second = await thePartitions.MigrateTenantPartitionsAsync(TestContext.Current.CancellationToken);
second.Succeeded.ShouldBeTrue();
// and the tenants registered before the back-fill still write and read
@@ -281,7 +281,7 @@ await theHost.ExecuteAndWaitAsync(c =>
c.InvokeForTenantAsync("green", new CreatePartitionedItem(id, "g")));
var green = await theBuilder.BuildAsync("green", CancellationToken.None);
- (await green.Items.ToListAsync()).Single().Id.ShouldBe(id);
+ (await green.Items.ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(id);
}
[Fact]
@@ -292,8 +292,8 @@ public async Task bucketed_tenants_registered_separately_share_one_partition()
// second member was swallowed by CREATE TABLE IF NOT EXISTS so its first write failed with 23514;
// SQL Server's registry had no bucket key, so each call quietly allocated a separate ordinal and
// the tenants never actually shared the partition that bucketing exists to give them.
- await thePartitions.AddTenantAsync("smalla", "shared_bucket");
- await thePartitions.AddTenantAsync("smallb", "shared_bucket");
+ await thePartitions.AddTenantAsync("smalla", "shared_bucket", TestContext.Current.CancellationToken);
+ await thePartitions.AddTenantAsync("smallb", "shared_bucket", TestContext.Current.CancellationToken);
// Both members read and write...
var aId = Guid.NewGuid();
@@ -304,10 +304,10 @@ await theHost.ExecuteAndWaitAsync(c =>
c.InvokeForTenantAsync("smallb", new CreatePartitionedItem(bId, "b")));
var a = await theBuilder.BuildAsync("smalla", CancellationToken.None);
- (await a.Items.ToListAsync()).Single().Id.ShouldBe(aId);
+ (await a.Items.ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(aId);
var b = await theBuilder.BuildAsync("smallb", CancellationToken.None);
- (await b.Items.ToListAsync()).Single().Id.ShouldBe(bId);
+ (await b.Items.ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(bId);
// ...and they genuinely share ONE physical partition, which is the entire point
(await distinctPartitionCountAsync(["smalla", "smallb"])).ShouldBe(1);
@@ -320,7 +320,7 @@ await thePartitions.AddTenantsAsync(new Dictionary
{
["smalla"] = "shared_bucket",
["smallb"] = "shared_bucket"
- });
+ }, TestContext.Current.CancellationToken);
(await distinctPartitionCountAsync(["smalla", "smallb"])).ShouldBe(1);
}
@@ -330,8 +330,8 @@ public async Task dropping_one_bucket_member_leaves_the_others_working()
{
// The co-tenant data-loss defect found alongside GH-3683: on PostgreSQL the by-value drop resolved
// the tenant to its suffix and dropped BY SUFFIX, taking every co-tenant's rows with it.
- await thePartitions.AddTenantAsync("smalla", "shared_bucket");
- await thePartitions.AddTenantAsync("smallb", "shared_bucket");
+ await thePartitions.AddTenantAsync("smalla", "shared_bucket", TestContext.Current.CancellationToken);
+ await thePartitions.AddTenantAsync("smallb", "shared_bucket", TestContext.Current.CancellationToken);
var survivorId = Guid.NewGuid();
await theHost.ExecuteAndWaitAsync(c =>
@@ -339,11 +339,11 @@ await theHost.ExecuteAndWaitAsync(c =>
await theHost.ExecuteAndWaitAsync(c =>
c.InvokeForTenantAsync("smallb", new CreatePartitionedItem(survivorId, "survivor")));
- await thePartitions.DropTenantAsync("smalla", deleteData: true);
+ await thePartitions.DropTenantAsync("smalla", deleteData: true, cancellationToken: TestContext.Current.CancellationToken);
// The survivor keeps its rows...
var b = await theBuilder.BuildAsync("smallb", CancellationToken.None);
- (await b.Items.ToListAsync()).Single().Id.ShouldBe(survivorId);
+ (await b.Items.ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(survivorId);
// ...and can still write
var moreId = Guid.NewGuid();
@@ -351,7 +351,7 @@ await theHost.ExecuteAndWaitAsync(c =>
c.InvokeForTenantAsync("smallb", new CreatePartitionedItem(moreId, "more")));
b = await theBuilder.BuildAsync("smallb", CancellationToken.None);
- (await b.Items.ToListAsync()).Select(x => x.Id).OrderBy(x => x)
+ (await b.Items.ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Select(x => x.Id).OrderBy(x => x)
.ShouldBe(new[] { survivorId, moreId }.OrderBy(x => x));
}
@@ -399,29 +399,29 @@ from pg_class c
[Fact]
public async Task physical_partition_exists_per_tenant()
{
- await thePartitions.AddTenantAsync("green");
+ await thePartitions.AddTenantAsync("green", TestContext.Current.CancellationToken);
if (_engine == DatabaseEngine.PostgreSQL)
{
await using var conn = new NpgsqlConnection(Servers.PostgresConnectionString);
- await conn.OpenAsync();
+ await conn.OpenAsync(TestContext.Current.CancellationToken);
await using var cmd = conn.CreateCommand();
cmd.CommandText = @"
select count(*) from pg_inherits
join pg_class parent on pg_inherits.inhparent = parent.oid
join pg_namespace ns on parent.relnamespace = ns.oid
where ns.nspname = 'conjoined_part' and parent.relname = 'partitioned_items'";
- var partitionCount = (long)(await cmd.ExecuteScalarAsync())!;
+ var partitionCount = (long)(await cmd.ExecuteScalarAsync(TestContext.Current.CancellationToken))!;
partitionCount.ShouldBeGreaterThanOrEqualTo(1);
}
else
{
await using var conn = new SqlConnection(Servers.SqlServerConnectionString);
- await conn.OpenAsync();
+ await conn.OpenAsync(TestContext.Current.CancellationToken);
await using var cmd = conn.CreateCommand();
cmd.CommandText =
"SELECT COUNT(*) FROM conjoined_part_wolverine.wolverine_tenant_partitions WHERE tenant_id = 'green'";
- ((int)(await cmd.ExecuteScalarAsync())!).ShouldBe(1);
+ ((int)(await cmd.ExecuteScalarAsync(TestContext.Current.CancellationToken))!).ShouldBe(1);
}
}
}
@@ -442,14 +442,14 @@ public conjoined_partitioning_with_postgresql() : base(DatabaseEngine.PostgreSQL
[Fact]
public async Task back_fill_recreates_a_partition_missing_for_a_registered_tenant()
{
- await thePartitions.AddTenantAsync("green");
+ await thePartitions.AddTenantAsync("green", TestContext.Current.CancellationToken);
await using (var conn = new NpgsqlConnection(Servers.PostgresConnectionString))
{
- await conn.OpenAsync();
+ await conn.OpenAsync(TestContext.Current.CancellationToken);
await using var drop = conn.CreateCommand();
drop.CommandText = "DROP TABLE conjoined_part.partitioned_items_green;";
- await drop.ExecuteNonQueryAsync();
+ await drop.ExecuteNonQueryAsync(TestContext.Current.CancellationToken);
}
// Without its partition, the tenant's writes have nowhere to land
@@ -460,7 +460,7 @@ await theHost.TrackActivity().DoNotAssertOnExceptionsDetected()
c.InvokeForTenantAsync("green", new CreatePartitionedItem(Guid.NewGuid(), "before")));
});
- var result = await thePartitions.MigrateTenantPartitionsAsync();
+ var result = await thePartitions.MigrateTenantPartitionsAsync(TestContext.Current.CancellationToken);
result.Succeeded.ShouldBeTrue();
var id = Guid.NewGuid();
@@ -468,7 +468,7 @@ await theHost.ExecuteAndWaitAsync(c =>
c.InvokeForTenantAsync("green", new CreatePartitionedItem(id, "after")));
var green = await theBuilder.BuildAsync("green", CancellationToken.None);
- (await green.Items.ToListAsync()).Single().Id.ShouldBe(id);
+ (await green.Items.ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(id);
}
}
diff --git a/src/Persistence/EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedTenancyCompliance.cs b/src/Persistence/EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedTenancyCompliance.cs
index 099bede7b..cea1cdc91 100644
--- a/src/Persistence/EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedTenancyCompliance.cs
+++ b/src/Persistence/EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedTenancyCompliance.cs
@@ -110,7 +110,7 @@ public async Task handler_insert_stamps_the_ambient_tenant_id()
await theHost.ExecuteAndWaitAsync(c => c.InvokeForTenantAsync("green", new CreateConjoinedItem(id, "one")));
var context = await theBuilder.BuildAsync("green", CancellationToken.None);
- var item = await context.Items.FindAsync(id);
+ var item = await context.Items.FindAsync(new object?[] { id }, TestContext.Current.CancellationToken);
item.ShouldNotBeNull();
item.TenantId.ShouldBe("green");
@@ -123,7 +123,7 @@ public async Task insert_without_a_tenant_gets_the_default_tenant_sentinel()
await theHost.InvokeMessageAndWaitAsync(new CreateConjoinedItem(id, "plain"));
var context = await theBuilder.BuildAsync(CancellationToken.None);
- var item = await context.Items.FindAsync(id);
+ var item = await context.Items.FindAsync(new object?[] { id }, TestContext.Current.CancellationToken);
item.ShouldNotBeNull();
item.TenantId.ShouldBe(StorageConstants.DefaultTenantId);
@@ -143,9 +143,9 @@ public async Task queries_are_bound_to_the_tenant_of_each_context_instance()
var blue = await theBuilder.BuildAsync("blue", CancellationToken.None);
var greenAgain = await theBuilder.BuildAsync("green", CancellationToken.None);
- (await green.Items.Where(x => x.Name == "same").ToListAsync()).Single().Id.ShouldBe(greenId);
- (await blue.Items.Where(x => x.Name == "same").ToListAsync()).Single().Id.ShouldBe(blueId);
- (await greenAgain.Items.Where(x => x.Name == "same").ToListAsync()).Single().Id.ShouldBe(greenId);
+ (await green.Items.Where(x => x.Name == "same").ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(greenId);
+ (await blue.Items.Where(x => x.Name == "same").ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(blueId);
+ (await greenAgain.Items.Where(x => x.Name == "same").ToListAsync(cancellationToken: TestContext.Current.CancellationToken)).Single().Id.ShouldBe(greenId);
}
[Fact]
@@ -157,10 +157,10 @@ public async Task find_async_respects_the_tenant_filter()
await theHost.ExecuteAndWaitAsync(c => c.InvokeForTenantAsync("green", new CreateConjoinedItem(greenId, "mine")));
var blue = await theBuilder.BuildAsync("blue", CancellationToken.None);
- (await blue.Items.FindAsync(greenId)).ShouldBeNull();
+ (await blue.Items.FindAsync(new object?[] { greenId }, TestContext.Current.CancellationToken)).ShouldBeNull();
var green = await theBuilder.BuildAsync("green", CancellationToken.None);
- (await green.Items.FindAsync(greenId)).ShouldNotBeNull();
+ (await green.Items.FindAsync(new object?[] { greenId }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
}
[Fact]
@@ -170,7 +170,7 @@ public async Task cross_tenant_update_is_rejected()
await theHost.ExecuteAndWaitAsync(c => c.InvokeForTenantAsync("green", new CreateConjoinedItem(id, "guarded")));
var blue = await theBuilder.BuildAsync("blue", CancellationToken.None);
- var smuggled = await blue.Items.IgnoreQueryFilters().SingleAsync(x => x.Id == id);
+ var smuggled = await blue.Items.IgnoreQueryFilters().SingleAsync(x => x.Id == id, cancellationToken: TestContext.Current.CancellationToken);
smuggled.Name = "hijacked";
var ex = await Should.ThrowAsync(() => blue.SaveChangesAsync());
@@ -185,7 +185,7 @@ public async Task cross_tenant_delete_is_rejected()
await theHost.ExecuteAndWaitAsync(c => c.InvokeForTenantAsync("green", new CreateConjoinedItem(id, "keeper")));
var blue = await theBuilder.BuildAsync("blue", CancellationToken.None);
- var smuggled = await blue.Items.IgnoreQueryFilters().SingleAsync(x => x.Id == id);
+ var smuggled = await blue.Items.IgnoreQueryFilters().SingleAsync(x => x.Id == id, cancellationToken: TestContext.Current.CancellationToken);
blue.Items.Remove(smuggled);
await Should.ThrowAsync(() => blue.SaveChangesAsync());
@@ -213,12 +213,12 @@ await Should.ThrowAsync(() => theHost.TrackActivity()
.ExecuteAndWaitAsync(c => c.InvokeForTenantAsync("blue", new IncrementCounter(id))));
var green = await theBuilder.BuildAsync("green", CancellationToken.None);
- var saga = await green.Counters.SingleAsync(x => x.Id == id);
+ var saga = await green.Counters.SingleAsync(x => x.Id == id, cancellationToken: TestContext.Current.CancellationToken);
saga.Count.ShouldBe(1);
saga.TenantId.ShouldBe("green");
var blue = await theBuilder.BuildAsync("blue", CancellationToken.None);
- (await blue.Counters.FindAsync(id)).ShouldBeNull();
+ (await blue.Counters.FindAsync(new object?[] { id }, TestContext.Current.CancellationToken)).ShouldBeNull();
}
}
diff --git a/src/Persistence/EfCoreTests.MultiTenancy/EfCoreTests.MultiTenancy.csproj b/src/Persistence/EfCoreTests.MultiTenancy/EfCoreTests.MultiTenancy.csproj
index b09ce498b..2620632c9 100644
--- a/src/Persistence/EfCoreTests.MultiTenancy/EfCoreTests.MultiTenancy.csproj
+++ b/src/Persistence/EfCoreTests.MultiTenancy/EfCoreTests.MultiTenancy.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
false
true
diff --git a/src/Persistence/EfCoreTests.MultiTenancy/MultiTenancyCompliance.cs b/src/Persistence/EfCoreTests.MultiTenancy/MultiTenancyCompliance.cs
index edf632ab9..29167c687 100644
--- a/src/Persistence/EfCoreTests.MultiTenancy/MultiTenancyCompliance.cs
+++ b/src/Persistence/EfCoreTests.MultiTenancy/MultiTenancyCompliance.cs
@@ -162,17 +162,17 @@ public async Task end_to_end_with_commands()
var greenDbContext = await theBuilder.BuildAsync("green", CancellationToken.None);
var redDbContext = await theBuilder.BuildAsync("red", CancellationToken.None);
- (await blueDbContext.Items.FindAsync(blueId))!.Name.ShouldBe("Blue!");
- (await greenDbContext.Items.FindAsync(blueId)).ShouldBeNull();
- (await redDbContext.Items.FindAsync(blueId)).ShouldBeNull();
+ (await blueDbContext.Items.FindAsync(new object?[] { blueId }, TestContext.Current.CancellationToken))!.Name.ShouldBe("Blue!");
+ (await greenDbContext.Items.FindAsync(new object?[] { blueId }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await redDbContext.Items.FindAsync(new object?[] { blueId }, TestContext.Current.CancellationToken)).ShouldBeNull();
- (await blueDbContext.Items.FindAsync(redId)).ShouldBeNull();
- (await greenDbContext.Items.FindAsync(redId)).ShouldBeNull();
- (await redDbContext.Items.FindAsync(redId))!.Name.ShouldBe("Red!");
+ (await blueDbContext.Items.FindAsync(new object?[] { redId }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await greenDbContext.Items.FindAsync(new object?[] { redId }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await redDbContext.Items.FindAsync(new object?[] { redId }, TestContext.Current.CancellationToken))!.Name.ShouldBe("Red!");
- (await blueDbContext.Items.FindAsync(greenId)).ShouldBeNull();
- (await greenDbContext.Items.FindAsync(greenId))!.Name.ShouldBe("Green!");
- (await redDbContext.Items.FindAsync(greenId)).ShouldBeNull();
+ (await blueDbContext.Items.FindAsync(new object?[] { greenId }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await greenDbContext.Items.FindAsync(new object?[] { greenId }, TestContext.Current.CancellationToken))!.Name.ShouldBe("Green!");
+ (await redDbContext.Items.FindAsync(new object?[] { greenId }, TestContext.Current.CancellationToken)).ShouldBeNull();
}
[Fact]
@@ -189,7 +189,7 @@ public async Task end_to_end_with_default_database()
var greenDbContext = await theBuilder.BuildAsync("green", CancellationToken.None);
var redDbContext = await theBuilder.BuildAsync("red", CancellationToken.None);
- (await defaultDbContext.FindAsync- (defaultId))!.Name.ShouldBe("The Default!");
+ (await defaultDbContext.FindAsync
- (new object?[] { defaultId }, TestContext.Current.CancellationToken))!.Name.ShouldBe("The Default!");
}
catch (DefaultTenantUsageDisabledException)
{
@@ -212,23 +212,23 @@ public async Task end_to_end_with_cascading_messages()
var greenDbContext = await theBuilder.BuildAsync("green", CancellationToken.None);
var redDbContext = await theBuilder.BuildAsync("red", CancellationToken.None);
- var blue = (await blueDbContext.Items.FindAsync(blueId))!;
+ var blue = (await blueDbContext.Items.FindAsync(new object?[] { blueId }, TestContext.Current.CancellationToken))!;
blue.Name.ShouldBe("Blue!");
blue.Approved.ShouldBeTrue();
- (await greenDbContext.Items.FindAsync(blueId)).ShouldBeNull();
- (await redDbContext.Items.FindAsync(blueId)).ShouldBeNull();
+ (await greenDbContext.Items.FindAsync(new object?[] { blueId }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await redDbContext.Items.FindAsync(new object?[] { blueId }, TestContext.Current.CancellationToken)).ShouldBeNull();
- (await blueDbContext.Items.FindAsync(redId)).ShouldBeNull();
- (await greenDbContext.Items.FindAsync(redId)).ShouldBeNull();
- var red = (await redDbContext.Items.FindAsync(redId))!;
+ (await blueDbContext.Items.FindAsync(new object?[] { redId }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await greenDbContext.Items.FindAsync(new object?[] { redId }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ var red = (await redDbContext.Items.FindAsync(new object?[] { redId }, TestContext.Current.CancellationToken))!;
red.Name.ShouldBe("Red!");
red.Approved.ShouldBeTrue();
- (await blueDbContext.Items.FindAsync(greenId)).ShouldBeNull();
- var green = (await greenDbContext.Items.FindAsync(greenId))!;
+ (await blueDbContext.Items.FindAsync(new object?[] { greenId }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ var green = (await greenDbContext.Items.FindAsync(new object?[] { greenId }, TestContext.Current.CancellationToken))!;
green.Name.ShouldBe("Green!");
green.Approved.ShouldBeTrue();
- (await redDbContext.Items.FindAsync(greenId)).ShouldBeNull();
+ (await redDbContext.Items.FindAsync(new object?[] { greenId }, TestContext.Current.CancellationToken)).ShouldBeNull();
}
[Fact]
@@ -248,11 +248,11 @@ await theHost.Scenario(x =>
var redDbContext = await theBuilder.BuildAsync("red", CancellationToken.None);
- (await defaultDbContext.FindAsync
- (command.Id)).ShouldBeNull();
- (await redDbContext.FindAsync
- (command.Id)).ShouldBeNull();
- (await greenDbContext.FindAsync
- (command.Id)).ShouldBeNull();
+ (await defaultDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await redDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await greenDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken)).ShouldBeNull();
- (await blueDbContext.FindAsync
- (command.Id))!.Name.ShouldBe(command.Name);
+ (await blueDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Name.ShouldBe(command.Name);
}
[Fact]
@@ -271,11 +271,11 @@ await theHost.Scenario(x =>
var greenDbContext = await theBuilder.BuildAsync("green", CancellationToken.None);
var redDbContext = await theBuilder.BuildAsync("red", CancellationToken.None);
- (await blueDbContext.FindAsync
- (command.Id)).ShouldBeNull();
- (await redDbContext.FindAsync
- (command.Id)).ShouldBeNull();
- (await greenDbContext.FindAsync
- (command.Id)).ShouldBeNull();
+ (await blueDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await redDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken)).ShouldBeNull();
+ (await greenDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken)).ShouldBeNull();
- (await defaultDbContext.FindAsync
- (command.Id))!.Name.ShouldBe(command.Name);
+ (await defaultDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Name.ShouldBe(command.Name);
}
[Fact]
@@ -373,11 +373,11 @@ await theHost.Scenario(x =>
var greenDbContext = await theBuilder.BuildAsync("green", CancellationToken.None);
var redDbContext = await theBuilder.BuildAsync("red", CancellationToken.None);
- (await blueDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeFalse();
- (await redDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeFalse();
+ (await blueDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeFalse();
+ (await redDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeFalse();
// Only approved this one
- (await greenDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeTrue();
+ (await greenDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeTrue();
}
[Fact]
@@ -403,11 +403,11 @@ await theHost.Scenario(x =>
var greenDbContext = await theBuilder.BuildAsync("green", CancellationToken.None);
var redDbContext = await theBuilder.BuildAsync("red", CancellationToken.None);
- (await blueDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeFalse();
- (await redDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeFalse();
+ (await blueDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeFalse();
+ (await redDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeFalse();
// Only approved this one
- (await greenDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeTrue();
+ (await greenDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeTrue();
}
[Fact]
@@ -433,11 +433,11 @@ await theHost.Scenario(x =>
var greenDbContext = await theBuilder.BuildAsync("green", CancellationToken.None);
var redDbContext = await theBuilder.BuildAsync("red", CancellationToken.None);
- (await blueDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeFalse();
- (await redDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeFalse();
+ (await blueDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeFalse();
+ (await redDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeFalse();
// Only approved this one
- (await greenDbContext.FindAsync
- (command.Id))!.Approved.ShouldBeTrue();
+ (await greenDbContext.FindAsync
- (new object?[] { command.Id }, TestContext.Current.CancellationToken))!.Approved.ShouldBeTrue();
}
[Fact]
@@ -494,7 +494,7 @@ await theHost.ExecuteAndWaitAsync(async _ =>
var builder = theHost.Services.GetRequiredService>();
var dbContext = await builder.BuildAsync("blue", CancellationToken.None);
- var item2 = await dbContext.Items.FindAsync(id);
+ var item2 = await dbContext.Items.FindAsync(new object?[] { id }, TestContext.Current.CancellationToken);
item2!.Approved.ShouldBeTrue();
}
diff --git a/src/Persistence/EfCoreTests/Bug_252_codegen_issue.cs b/src/Persistence/EfCoreTests/Bug_252_codegen_issue.cs
index 45dcb954e..e08c883a0 100644
--- a/src/Persistence/EfCoreTests/Bug_252_codegen_issue.cs
+++ b/src/Persistence/EfCoreTests/Bug_252_codegen_issue.cs
@@ -33,8 +33,8 @@ public Bug_252_codegen_issue(ITestOutputHelper output)
public async Task use_the_saga_type_to_determine_the_correct_DbContext_type()
{
await using var conn = new SqlConnection(Servers.SqlServerConnectionString);
- await conn.OpenAsync();
- await conn.DropSchemaAsync("mt_items");
+ await conn.OpenAsync(TestContext.Current.CancellationToken);
+ await conn.DropSchemaAsync("mt_items", ct: TestContext.Current.CancellationToken);
await conn.CloseAsync();
using var host = await Host.CreateDefaultBuilder()
@@ -58,7 +58,7 @@ public async Task use_the_saga_type_to_determine_the_correct_DbContext_type()
opt.Services.AddResourceSetupOnStartup(StartupAction.ResetState);
opt.Policies.UseDurableLocalQueues();
opt.Policies.AutoApplyTransactions();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
await host.InvokeMessageAndWaitAsync(new OrderCreated(Guid.NewGuid()));
}
@@ -67,8 +67,8 @@ public async Task use_the_saga_type_to_determine_the_correct_DbContext_type()
public async Task bug_256_message_bus_should_be_in_outbox_transaction()
{
await using var conn = new SqlConnection(Servers.SqlServerConnectionString);
- await conn.OpenAsync();
- await conn.DropSchemaAsync("mt_items");
+ await conn.OpenAsync(TestContext.Current.CancellationToken);
+ await conn.DropSchemaAsync("mt_items", ct: TestContext.Current.CancellationToken);
await conn.CloseAsync();
using var host = await Host.CreateDefaultBuilder()
@@ -92,7 +92,7 @@ public async Task bug_256_message_bus_should_be_in_outbox_transaction()
opt.Services.AddResourceSetupOnStartup(StartupAction.ResetState);
opt.Policies.UseDurableLocalQueues();
opt.Policies.AutoApplyTransactions();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var chain = host.Services.GetRequiredService().HandlerFor()!.As()!.Chain!;
diff --git a/src/Persistence/EfCoreTests/Bug_661_postgresql_with_ef_core.cs b/src/Persistence/EfCoreTests/Bug_661_postgresql_with_ef_core.cs
index 1cfd5b3f5..c99e13b7a 100644
--- a/src/Persistence/EfCoreTests/Bug_661_postgresql_with_ef_core.cs
+++ b/src/Persistence/EfCoreTests/Bug_661_postgresql_with_ef_core.cs
@@ -26,6 +26,6 @@ public async Task can_set_up_with_default_schema_name()
opts.PersistMessagesWithPostgresql(Servers.PostgresConnectionString);
opts.Services.AddResourceSetupOnStartup();
opts.Services.AddDbContext(opt => opt.UseNpgsql(Servers.PostgresConnectionString));
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Persistence/EfCoreTests/Bugs/Bug_1846_duplicate_execution_of_scheduled_jobs.cs b/src/Persistence/EfCoreTests/Bugs/Bug_1846_duplicate_execution_of_scheduled_jobs.cs
index 845565061..02aed7ae3 100644
--- a/src/Persistence/EfCoreTests/Bugs/Bug_1846_duplicate_execution_of_scheduled_jobs.cs
+++ b/src/Persistence/EfCoreTests/Bugs/Bug_1846_duplicate_execution_of_scheduled_jobs.cs
@@ -43,7 +43,7 @@ public async Task should_not_double_execute()
opts.Services.AddDbContextWithWolverineIntegration(x =>
x.UseSqlServer(Servers.SqlServerConnectionString));
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var session = await host.TrackActivity()
.WaitForMessageToBeReceivedAt(host)
diff --git a/src/Persistence/EfCoreTests/Bugs/Bug_2075_separated_behavior_and_scheduled_messages.cs b/src/Persistence/EfCoreTests/Bugs/Bug_2075_separated_behavior_and_scheduled_messages.cs
index 58bd38994..9768ef6b1 100644
--- a/src/Persistence/EfCoreTests/Bugs/Bug_2075_separated_behavior_and_scheduled_messages.cs
+++ b/src/Persistence/EfCoreTests/Bugs/Bug_2075_separated_behavior_and_scheduled_messages.cs
@@ -39,7 +39,7 @@ public async Task MyBug()
opts.MultipleHandlerBehavior = MultipleHandlerBehavior.Separated;
GlobalErrorHandlingPolicy.Invoke(opts);
})
- .StartAsync();
+ .StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var session = await host.TrackActivity().DoNotAssertOnExceptionsDetected().WaitForMessageToBeReceivedAt(host).Timeout(30.Seconds())
.SendMessageAndWaitAsync(new SayStuffy0());
diff --git a/src/Persistence/EfCoreTests/Bugs/Bug_3342_saga_entity_and_storage_action.cs b/src/Persistence/EfCoreTests/Bugs/Bug_3342_saga_entity_and_storage_action.cs
index 3b6c87fe9..1313b10ba 100644
--- a/src/Persistence/EfCoreTests/Bugs/Bug_3342_saga_entity_and_storage_action.cs
+++ b/src/Persistence/EfCoreTests/Bugs/Bug_3342_saga_entity_and_storage_action.cs
@@ -81,7 +81,7 @@ public async Task cascaded_handler_sees_the_persisted_entity()
// And the record persisted by the Update in the ProcessOrder handler must be up to date.
using var scope = _host.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService();
- var record = await db.OrderProcessRecords.FirstOrDefaultAsync(x => x.Id == TheOrderId);
+ var record = await db.OrderProcessRecords.FirstOrDefaultAsync(x => x.Id == TheOrderId, cancellationToken: TestContext.Current.CancellationToken);
record.ShouldNotBeNull("Start's Storage.Insert must be persisted");
record.StockChecked.ShouldBeTrue("the ProcessOrder handler's Storage.Update must be persisted");
}
diff --git a/src/Persistence/EfCoreTests/Bugs/Bug_DurableLocalQueue_ancillary_store_routing.cs b/src/Persistence/EfCoreTests/Bugs/Bug_DurableLocalQueue_ancillary_store_routing.cs
index 3250ba81e..9e1718ac4 100644
--- a/src/Persistence/EfCoreTests/Bugs/Bug_DurableLocalQueue_ancillary_store_routing.cs
+++ b/src/Persistence/EfCoreTests/Bugs/Bug_DurableLocalQueue_ancillary_store_routing.cs
@@ -214,7 +214,7 @@ await _host
.SendMessageAndWaitAsync(message);
// Give a moment for post-processing
- await Task.Delay(500);
+ await Task.Delay(500, TestContext.Current.CancellationToken);
var runtime = _host.Services.GetRequiredService();
@@ -240,7 +240,7 @@ await _host
.TrackActivity()
.SendMessageAndWaitAsync(message);
- await Task.Delay(500);
+ await Task.Delay(500, TestContext.Current.CancellationToken);
var runtime = _host.Services.GetRequiredService();
@@ -264,7 +264,7 @@ await _host
// Verify the entity was actually saved in the ancillary DbContext
using var scope = _host.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService();
- var doc = await db.Docs.FindAsync(message.Id);
+ var doc = await db.Docs.FindAsync(new object?[] { message.Id }, TestContext.Current.CancellationToken);
doc.ShouldNotBeNull();
doc.Name.ShouldBe("test-entity");
}
diff --git a/src/Persistence/EfCoreTests/DomainEvents/DomainEventScraperStateFilterTests.cs b/src/Persistence/EfCoreTests/DomainEvents/DomainEventScraperStateFilterTests.cs
index 6657db24d..2e2487820 100644
--- a/src/Persistence/EfCoreTests/DomainEvents/DomainEventScraperStateFilterTests.cs
+++ b/src/Persistence/EfCoreTests/DomainEvents/DomainEventScraperStateFilterTests.cs
@@ -58,7 +58,7 @@ public async Task domain_event_scraper_collects_events_from_added_and_modified_b
{
seed.Items.Add(new Item { Id = Guid.Parse("00000000-0000-0000-0000-000000000001"), Name = "WillBeUnchanged" });
seed.Items.Add(new Item { Id = Guid.Parse("00000000-0000-0000-0000-000000000002"), Name = "WillBeDeleted" });
- await seed.SaveChangesAsync();
+ await seed.SaveChangesAsync(TestContext.Current.CancellationToken);
}
using var ctx = new ScraperTestDbContext(options);
@@ -69,12 +69,12 @@ public async Task domain_event_scraper_collects_events_from_added_and_modified_b
addedItem.Approve(); // raises ItemApproved event
// Modified – load, change, and let EF detect it
- var modifiedItem = await ctx.Items.FindAsync(Guid.Parse("00000000-0000-0000-0000-000000000001"));
+ var modifiedItem = await ctx.Items.FindAsync(new object?[] { Guid.Parse("00000000-0000-0000-0000-000000000001") }, TestContext.Current.CancellationToken);
modifiedItem!.Approve(); // raises event AND sets Approved=true → Modified state
// Unchanged – load but do not touch
// (we manually add an event to the unchanged item to prove the scraper skips it)
- var unchangedItem = await ctx.Items.FindAsync(Guid.Parse("00000000-0000-0000-0000-000000000002"));
+ var unchangedItem = await ctx.Items.FindAsync(new object?[] { Guid.Parse("00000000-0000-0000-0000-000000000002") }, TestContext.Current.CancellationToken);
unchangedItem!.Publish(new ItemApproved(unchangedItem.Id)); // event added, but state stays Unchanged
// Verify states are as expected
diff --git a/src/Persistence/EfCoreTests/DomainEvents/configuration_of_domain_events_scrapers.cs b/src/Persistence/EfCoreTests/DomainEvents/configuration_of_domain_events_scrapers.cs
index ef8271d1d..446b66de0 100644
--- a/src/Persistence/EfCoreTests/DomainEvents/configuration_of_domain_events_scrapers.cs
+++ b/src/Persistence/EfCoreTests/DomainEvents/configuration_of_domain_events_scrapers.cs
@@ -187,7 +187,7 @@ public async Task publish_through_db_context_scraping1()
var item = new Item { Id = itemId, Name = "Latte"};
dbContext.Items.Add(item);
- await dbContext.SaveChangesAsync();
+ await dbContext.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var tracked = await theHost.InvokeMessageAndWaitAsync(new ApproveItem(itemId));
@@ -208,7 +208,7 @@ public async Task publish_through_db_context_scraping2()
var item = new Item { Id = itemId, Name = "Smoothie"};
dbContext.Items.Add(item);
- await dbContext.SaveChangesAsync();
+ await dbContext.SaveChangesAsync(TestContext.Current.CancellationToken);
}
var tracked = await theHost.InvokeMessageAndWaitAsync(new ApproveItem(itemId));
diff --git a/src/Persistence/EfCoreTests/EfCoreCompilationScenarios.cs b/src/Persistence/EfCoreTests/EfCoreCompilationScenarios.cs
index 90c07ba26..d7cf2e583 100644
--- a/src/Persistence/EfCoreTests/EfCoreCompilationScenarios.cs
+++ b/src/Persistence/EfCoreTests/EfCoreCompilationScenarios.cs
@@ -24,7 +24,7 @@ public async Task ef_context_is_scoped_and_options_are_scoped()
opts.UseEntityFrameworkCoreTransactions();
});
- await host.MessageBus().InvokeAsync(new CreateItem { Name = "foo" });
+ await host.MessageBus().InvokeAsync(new CreateItem { Name = "foo" }, TestContext.Current.CancellationToken);
}
[Fact]
@@ -39,8 +39,8 @@ public async Task ef_context_is_scoped_and_options_are_singleton()
opts.UseEntityFrameworkCoreTransactions();
});
- await host.MessageBus().InvokeAsync(new CreateItem { Name = "foo" });
- await host.StopAsync();
+ await host.MessageBus().InvokeAsync(new CreateItem { Name = "foo" }, TestContext.Current.CancellationToken);
+ await host.StopAsync(TestContext.Current.CancellationToken);
host.Dispose();
}
@@ -57,7 +57,7 @@ public async Task ef_context_is_singleton_and_options_are_singleton()
opts.UseEntityFrameworkCoreTransactions();
});
- await host.MessageBus().InvokeAsync(new CreateItem { Name = "foo" });
+ await host.MessageBus().InvokeAsync(new CreateItem { Name = "foo" }, TestContext.Current.CancellationToken);
}
}
diff --git a/src/Persistence/EfCoreTests/EfCoreTests.csproj b/src/Persistence/EfCoreTests/EfCoreTests.csproj
index 8d4b5feb6..1e51faf3c 100644
--- a/src/Persistence/EfCoreTests/EfCoreTests.csproj
+++ b/src/Persistence/EfCoreTests/EfCoreTests.csproj
@@ -1,6 +1,8 @@
+
+ true
Exe
false
true
diff --git a/src/Persistence/EfCoreTests/Migrations/with_one_postgresql_context.cs b/src/Persistence/EfCoreTests/Migrations/with_one_postgresql_context.cs
index a5548d3bd..acdf13a1a 100644
--- a/src/Persistence/EfCoreTests/Migrations/with_one_postgresql_context.cs
+++ b/src/Persistence/EfCoreTests/Migrations/with_one_postgresql_context.cs
@@ -74,8 +74,8 @@ await context.Blogs.AddAsync(new Blog()
{
BlogId = 1,
Url = "http://codebetter.com"
- });
- await context.SaveChangesAsync();
+ }, TestContext.Current.CancellationToken);
+ await context.SaveChangesAsync(TestContext.Current.CancellationToken);
}
[Fact]
diff --git a/src/Persistence/EfCoreTests/Migrations/with_one_sqlserver_context.cs b/src/Persistence/EfCoreTests/Migrations/with_one_sqlserver_context.cs
index bc4f07bdf..a9b6301ce 100644
--- a/src/Persistence/EfCoreTests/Migrations/with_one_sqlserver_context.cs
+++ b/src/Persistence/EfCoreTests/Migrations/with_one_sqlserver_context.cs
@@ -73,8 +73,8 @@ await context.Blogs.AddAsync(new Blog()
{
BlogId = 1,
Url = "http://codebetter.com"
- });
- await context.SaveChangesAsync();
+ }, TestContext.Current.CancellationToken);
+ await context.SaveChangesAsync(TestContext.Current.CancellationToken);
}
[Fact]
diff --git a/src/Persistence/EfCoreTests/Optimistic_concurrency_with_ef_core.cs b/src/Persistence/EfCoreTests/Optimistic_concurrency_with_ef_core.cs
index f068d6ac2..348ffe109 100644
--- a/src/Persistence/EfCoreTests/Optimistic_concurrency_with_ef_core.cs
+++ b/src/Persistence/EfCoreTests/Optimistic_concurrency_with_ef_core.cs
@@ -49,7 +49,7 @@ public async Task detect_concurrency_exception_as_SagaConcurrencyException()
opt.Services.AddResourceSetupOnStartup(StartupAction.ResetState);
opt.Policies.UseDurableLocalQueues();
opt.Policies.AutoApplyTransactions();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
using var scope = host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService();
@@ -70,8 +70,8 @@ await dbContext.ConcurrencyTestSagas.AddAsync(new()
Id = sagaId,
Value = "initial value",
Version = 0,
- });
- await dbContext.SaveChangesAsync();
+ }, TestContext.Current.CancellationToken);
+ await dbContext.SaveChangesAsync(TestContext.Current.CancellationToken);
await Should.ThrowAsync(() =>
host.InvokeMessageAndWaitAsync(new UpdateConcurrencyTestSaga(sagaId, "updated value")));
diff --git a/src/Persistence/EfCoreTests/QueryPlans/QueryPlan_end_to_end.cs b/src/Persistence/EfCoreTests/QueryPlans/QueryPlan_end_to_end.cs
index 8d4335103..1b9860d24 100644
--- a/src/Persistence/EfCoreTests/QueryPlans/QueryPlan_end_to_end.cs
+++ b/src/Persistence/EfCoreTests/QueryPlans/QueryPlan_end_to_end.cs
@@ -58,7 +58,7 @@ public async Task handler_uses_query_plan_to_approve_matching_items()
db.Items.Add(new Item { Id = Guid.NewGuid(), Name = $"{prefix}_a", Approved = false });
db.Items.Add(new Item { Id = Guid.NewGuid(), Name = $"{prefix}_b", Approved = false });
db.Items.Add(new Item { Id = Guid.NewGuid(), Name = "untouched", Approved = false });
- await db.SaveChangesAsync();
+ await db.SaveChangesAsync(TestContext.Current.CancellationToken);
}
await _host.InvokeMessageAndWaitAsync(new ApproveItemsByPrefix(prefix));
@@ -68,10 +68,10 @@ public async Task handler_uses_query_plan_to_approve_matching_items()
var approved = await verifyDb.Items
.Where(x => x.Name.StartsWith(prefix) && x.Approved)
- .CountAsync();
+ .CountAsync(cancellationToken: TestContext.Current.CancellationToken);
approved.ShouldBe(2);
- var untouched = await verifyDb.Items.SingleAsync(x => x.Name == "untouched");
+ var untouched = await verifyDb.Items.SingleAsync(x => x.Name == "untouched", cancellationToken: TestContext.Current.CancellationToken);
untouched.Approved.ShouldBeFalse();
}
}
diff --git a/src/Persistence/EfCoreTests/QueryPlans/QueryPlan_specs.cs b/src/Persistence/EfCoreTests/QueryPlans/QueryPlan_specs.cs
index 3367fb246..4846dbd88 100644
--- a/src/Persistence/EfCoreTests/QueryPlans/QueryPlan_specs.cs
+++ b/src/Persistence/EfCoreTests/QueryPlans/QueryPlan_specs.cs
@@ -73,7 +73,7 @@ public async Task query_plan_returns_null_when_no_match()
{
// Delete everything, then run the plan
_db.Items.RemoveRange(_db.Items);
- await _db.SaveChangesAsync();
+ await _db.SaveChangesAsync(TestContext.Current.CancellationToken);
var plan = new FirstApprovedItem();
var result = await plan.FetchAsync(_db, CancellationToken.None);
@@ -84,7 +84,7 @@ public async Task query_plan_returns_null_when_no_match()
[Fact]
public async Task QueryByPlanAsync_extension_routes_to_the_plan()
{
- var result = await _db.QueryByPlanAsync(new FirstApprovedItem());
+ var result = await _db.QueryByPlanAsync(new FirstApprovedItem(), cancellation: TestContext.Current.CancellationToken);
result.ShouldNotBeNull();
result.Approved.ShouldBeTrue();
@@ -93,7 +93,7 @@ public async Task QueryByPlanAsync_extension_routes_to_the_plan()
[Fact]
public async Task QueryByPlanAsync_extension_works_with_list_plan()
{
- var results = await _db.QueryByPlanAsync(new ItemsByNamePrefix("Red"));
+ var results = await _db.QueryByPlanAsync(new ItemsByNamePrefix("Red"), cancellation: TestContext.Current.CancellationToken);
results.Count.ShouldBe(2);
}
@@ -123,8 +123,8 @@ public async Task plan_parameters_via_constructor_flow_through_to_query()
{
// Verify that distinct parameter values yield distinct results — the
// core claim of the specification pattern
- var red = await _db.QueryByPlanAsync(new ItemsByNamePrefix("Red"));
- var blue = await _db.QueryByPlanAsync(new ItemsByNamePrefix("Blue"));
+ var red = await _db.QueryByPlanAsync(new ItemsByNamePrefix("Red"), cancellation: TestContext.Current.CancellationToken);
+ var blue = await _db.QueryByPlanAsync(new ItemsByNamePrefix("Blue"), cancellation: TestContext.Current.CancellationToken);
red.Count.ShouldBe(2);
blue.Count.ShouldBe(1);
diff --git a/src/Persistence/EfCoreTests/auto_database_cleaner_tests.cs b/src/Persistence/EfCoreTests/auto_database_cleaner_tests.cs
index 3d6bf2a4d..267ba0503 100644
--- a/src/Persistence/EfCoreTests/auto_database_cleaner_tests.cs
+++ b/src/Persistence/EfCoreTests/auto_database_cleaner_tests.cs
@@ -99,15 +99,15 @@ public async Task host_ResetAllDataAsync_deletes_then_reseeds()
{
var db = scope.ServiceProvider.GetRequiredService();
db.Items.Add(new Item { Id = Guid.NewGuid(), Name = "Noise" });
- await db.SaveChangesAsync();
+ await db.SaveChangesAsync(TestContext.Current.CancellationToken);
}
// Act: the new one-liner for test teardown.
- await _ctx.Host.ResetAllDataAsync();
+ await _ctx.Host.ResetAllDataAsync(ct: TestContext.Current.CancellationToken);
using var check = _ctx.Host.Services.CreateScope();
var checkDb = check.ServiceProvider.GetRequiredService();
- var items = await checkDb.Items.OrderBy(x => x.Name).ToListAsync();
+ var items = await checkDb.Items.OrderBy(x => x.Name).ToListAsync(cancellationToken: TestContext.Current.CancellationToken);
items.Select(x => x.Name).ShouldBe(
SeedItemsForTests.Items.Select(x => x.Name).OrderBy(n => n));
diff --git a/src/Persistence/EfCoreTests/batch_query_tests.cs b/src/Persistence/EfCoreTests/batch_query_tests.cs
index a87c2a477..8db2c9f3d 100644
--- a/src/Persistence/EfCoreTests/batch_query_tests.cs
+++ b/src/Persistence/EfCoreTests/batch_query_tests.cs
@@ -54,7 +54,7 @@ public async Task load_two_entities_in_single_round_trip()
var batch = db.CreateBatchQuery();
var item1Task = batch.QuerySingle(db.Items.Where(x => x.Id == id1));
var item2Task = batch.QuerySingle(db.Items.Where(x => x.Id == id2));
- await batch.ExecuteAsync();
+ await batch.ExecuteAsync(TestContext.Current.CancellationToken);
var item1 = await item1Task;
var item2 = await item2Task;
@@ -80,7 +80,7 @@ public async Task load_list_of_entities_via_batch()
new Item { Id = Guid.NewGuid(), Name = $"{prefix}_list_2" });
#pragma warning restore VSTHRD103 // Call async methods when in an async method
- await db.SaveChangesAsync();
+ await db.SaveChangesAsync(TestContext.Current.CancellationToken);
}
using (var scope = _host.Services.CreateScope())
@@ -88,7 +88,7 @@ public async Task load_list_of_entities_via_batch()
var db = scope.ServiceProvider.GetRequiredService();
var batch = db.CreateBatchQuery();
var listTask = batch.Query(db.Items.Where(x => x.Name.StartsWith(prefix)));
- await batch.ExecuteAsync();
+ await batch.ExecuteAsync(TestContext.Current.CancellationToken);
var items = await listTask;
items.Count.ShouldBe(3);
@@ -112,7 +112,7 @@ public async Task mix_single_and_list_queries_in_same_batch()
new Item { Id = Guid.NewGuid(), Name = $"{prefix}_b" });
#pragma warning restore VSTHRD103 // Call async methods when in an async method
- await db.SaveChangesAsync();
+ await db.SaveChangesAsync(TestContext.Current.CancellationToken);
}
using (var scope = _host.Services.CreateScope())
@@ -122,7 +122,7 @@ public async Task mix_single_and_list_queries_in_same_batch()
var batch = db.CreateBatchQuery();
var singleTask = batch.QuerySingle(db.Items.Where(x => x.Id == id1));
var listTask = batch.Query(db.Items.Where(x => x.Name.StartsWith(prefix)));
- await batch.ExecuteAsync();
+ await batch.ExecuteAsync(TestContext.Current.CancellationToken);
var single = await singleTask;
var list = await listTask;
diff --git a/src/Persistence/EfCoreTests/database_cleaner_tests.cs b/src/Persistence/EfCoreTests/database_cleaner_tests.cs
index c3df8f23a..1671b45a5 100644
--- a/src/Persistence/EfCoreTests/database_cleaner_tests.cs
+++ b/src/Persistence/EfCoreTests/database_cleaner_tests.cs
@@ -110,11 +110,11 @@ public async Task delete_all_data_removes_every_row()
{
var db = scope.ServiceProvider.GetRequiredService();
db.Items.Add(new Item { Id = Guid.NewGuid(), Name = "Temp Item" });
- await db.SaveChangesAsync();
+ await db.SaveChangesAsync(TestContext.Current.CancellationToken);
}
// Act: FK-safe bulk delete (no seeding)
- await Cleaner.DeleteAllDataAsync();
+ await Cleaner.DeleteAllDataAsync(TestContext.Current.CancellationToken);
// Assert
(await CountItemsAsync()).ShouldBe(0);
@@ -128,16 +128,16 @@ public async Task reset_all_data_clears_then_applies_seed_data()
{
var db = scope.ServiceProvider.GetRequiredService();
db.Items.Add(new Item { Id = Guid.NewGuid(), Name = "Noise Item" });
- await db.SaveChangesAsync();
+ await db.SaveChangesAsync(TestContext.Current.CancellationToken);
}
// Act: delete all + run IInitialData seeders
- await Cleaner.ResetAllDataAsync();
+ await Cleaner.ResetAllDataAsync(TestContext.Current.CancellationToken);
// Assert: exactly the seed rows remain
using var checkScope = _ctx.Host.Services.CreateScope();
var checkDb = checkScope.ServiceProvider.GetRequiredService();
- var items = await checkDb.Items.OrderBy(x => x.Name).ToListAsync();
+ var items = await checkDb.Items.OrderBy(x => x.Name).ToListAsync(cancellationToken: TestContext.Current.CancellationToken);
items.Count.ShouldBe(SeedItemsForTests.Items.Length);
items.Select(x => x.Name).ShouldBe(
diff --git a/src/Persistence/EfCoreTests/dbContext_abstraction_scenarios.cs b/src/Persistence/EfCoreTests/dbContext_abstraction_scenarios.cs
index 0d3fcc136..1ff4652e9 100644
--- a/src/Persistence/EfCoreTests/dbContext_abstraction_scenarios.cs
+++ b/src/Persistence/EfCoreTests/dbContext_abstraction_scenarios.cs
@@ -89,7 +89,7 @@ CREATE TABLE customers_abs_schema.customers (
.IncludeType();
opts.Services.AddResourceSetupOnStartup(StartupAction.ResetState);
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var orderId = Guid.NewGuid();
var customerId = Guid.NewGuid();
@@ -99,10 +99,10 @@ CREATE TABLE customers_abs_schema.customers (
await using var scope = host.Services.CreateAsyncScope();
(await scope.ServiceProvider.GetRequiredService()
- .Orders.AnyAsync(o => o.Id == orderId))
+ .Orders.AnyAsync(o => o.Id == orderId, cancellationToken: TestContext.Current.CancellationToken))
.ShouldBeTrue("abstracted handler must commit through the IOrderRepository transaction");
(await scope.ServiceProvider.GetRequiredService()
- .Customers.AnyAsync(c => c.Id == customerId))
+ .Customers.AnyAsync(c => c.Id == customerId, cancellationToken: TestContext.Current.CancellationToken))
.ShouldBeTrue("direct handler must commit through the CustomersDbContext transaction");
}
@@ -155,7 +155,7 @@ CREATE TABLE store_abs_schema.orders (
.IncludeType();
opts.Services.AddResourceSetupOnStartup(StartupAction.ResetState);
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var itemId = Guid.NewGuid();
var orderId = Guid.NewGuid();
@@ -165,8 +165,8 @@ CREATE TABLE store_abs_schema.orders (
await using var scope = host.Services.CreateAsyncScope();
var db = scope.ServiceProvider.GetRequiredService();
- (await db.Items.AnyAsync(i => i.Id == itemId)).ShouldBeTrue();
- (await db.StoreOrders.AnyAsync(o => o.Id == orderId)).ShouldBeTrue();
+ (await db.Items.AnyAsync(i => i.Id == itemId, cancellationToken: TestContext.Current.CancellationToken)).ShouldBeTrue();
+ (await db.StoreOrders.AnyAsync(o => o.Id == orderId, cancellationToken: TestContext.Current.CancellationToken)).ShouldBeTrue();
}
// --- Scenario 3: same handler uses both abstractions; assert SAME DbContext instance -------
@@ -212,7 +212,7 @@ CREATE TABLE store_abs_schema.orders (
.IncludeType();
opts.Services.AddResourceSetupOnStartup(StartupAction.ResetState);
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var itemId = Guid.NewGuid();
var orderId = Guid.NewGuid();
@@ -230,8 +230,8 @@ CREATE TABLE store_abs_schema.orders (
// And both writes must have landed via that single context's single SaveChanges.
await using var scope = host.Services.CreateAsyncScope();
var db = scope.ServiceProvider.GetRequiredService();
- (await db.Items.AnyAsync(i => i.Id == itemId)).ShouldBeTrue();
- (await db.StoreOrders.AnyAsync(o => o.Id == orderId)).ShouldBeTrue();
+ (await db.Items.AnyAsync(i => i.Id == itemId, cancellationToken: TestContext.Current.CancellationToken)).ShouldBeTrue();
+ (await db.StoreOrders.AnyAsync(o => o.Id == orderId, cancellationToken: TestContext.Current.CancellationToken)).ShouldBeTrue();
}
// EF Core's EnsureCreatedAsync is a no-op when the database already exists — and the shared
diff --git a/src/Persistence/EfCoreTests/dbContext_transactions_with_abstractions_tests.cs b/src/Persistence/EfCoreTests/dbContext_transactions_with_abstractions_tests.cs
index e09645918..5ece22b69 100644
--- a/src/Persistence/EfCoreTests/dbContext_transactions_with_abstractions_tests.cs
+++ b/src/Persistence/EfCoreTests/dbContext_transactions_with_abstractions_tests.cs
@@ -63,7 +63,7 @@ public async Task can_apply_transactional_middleware_to_abstraction()
opts.Policies.AutoApplyTransactions();
opts.Discovery.DisableConventionalDiscovery().IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var runtime = host.GetRuntime();
var chain = runtime.Handlers.ChainFor();
@@ -95,7 +95,7 @@ public async Task codegen_works_with_abstraction()
opts.Policies.AutoApplyTransactions();
opts.Discovery.DisableConventionalDiscovery().IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
// If it compiles and runs without error, the cast worked
Should.NotThrow(async () => await host.InvokeMessageAndWaitAsync(new DbContextAbstractionTestFixture.AbstractionCommand()));
@@ -120,7 +120,7 @@ public async Task should_add_save_changes_async_call_to_postprocessors()
opts.Policies.AutoApplyTransactions();
opts.Discovery.DisableConventionalDiscovery().IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var runtime = host.GetRuntime();
var chain = runtime.Handlers.ChainFor();
diff --git a/src/Persistence/EfCoreTests/eager_idempotency_with_non_wolverine_mapped_db_context.cs b/src/Persistence/EfCoreTests/eager_idempotency_with_non_wolverine_mapped_db_context.cs
index 3a9883537..c021efa2c 100644
--- a/src/Persistence/EfCoreTests/eager_idempotency_with_non_wolverine_mapped_db_context.cs
+++ b/src/Persistence/EfCoreTests/eager_idempotency_with_non_wolverine_mapped_db_context.cs
@@ -46,7 +46,7 @@ public async Task happy_path_eager_idempotency()
var ok = await transaction.TryMakeEagerIdempotencyCheckAsync(envelope, new DurabilitySettings(), CancellationToken.None);
ok.ShouldBeTrue();
- await dbContext.Database.CurrentTransaction!.CommitAsync();
+ await dbContext.Database.CurrentTransaction!.CommitAsync(TestContext.Current.CancellationToken);
var persisted = (await runtime.Storage.Admin.AllIncomingAsync()).Single(x => x.Id == envelope.Id);
persisted.Data!.Length.ShouldBe(0);
@@ -56,12 +56,12 @@ public async Task happy_path_eager_idempotency()
persisted.KeepUntil.HasValue.ShouldBeTrue();
using var conn = new SqlConnection(Servers.SqlServerConnectionString);
- await conn.OpenAsync();
+ await conn.OpenAsync(TestContext.Current.CancellationToken);
var raw = await conn
.CreateCommand($"select keep_until from dbo.{DatabaseConstants.IncomingTable} where id = @id")
.With("id", persisted.Id)
- .ExecuteScalarAsync();
+ .ExecuteScalarAsync(TestContext.Current.CancellationToken);
raw.ShouldNotBeNull();
raw.ShouldBeOfType().ShouldBeGreaterThan(DateTimeOffset.UtcNow);
@@ -107,7 +107,7 @@ public async Task persist_batch_outgoing_envelopes_uses_outgoing_table()
var transaction = new EfCoreEnvelopeTransaction(dbContext, context);
await transaction.PersistOutgoingAsync([envelope1, envelope2]);
- await dbContext.Database.CurrentTransaction!.CommitAsync();
+ await dbContext.Database.CurrentTransaction!.CommitAsync(TestContext.Current.CancellationToken);
var outgoing = await runtime.Storage.Admin.AllOutgoingAsync();
outgoing.ShouldContain(x => x.Id == envelope1.Id);
@@ -135,7 +135,7 @@ public async Task sad_path_eager_idempotency()
var durabilitySettings = new DurabilitySettings();
var ok = await transaction.TryMakeEagerIdempotencyCheckAsync(envelope, durabilitySettings, CancellationToken.None);
ok.ShouldBeTrue();
- await dbContext.Database.CurrentTransaction!.CommitAsync();
+ await dbContext.Database.CurrentTransaction!.CommitAsync(TestContext.Current.CancellationToken);
// Kind of resetting it here
envelope.WasPersistedInInbox = false;
diff --git a/src/Persistence/EfCoreTests/end_to_end_efcore_persistence.cs b/src/Persistence/EfCoreTests/end_to_end_efcore_persistence.cs
index 88a07fbc2..9f55837ec 100644
--- a/src/Persistence/EfCoreTests/end_to_end_efcore_persistence.cs
+++ b/src/Persistence/EfCoreTests/end_to_end_efcore_persistence.cs
@@ -196,7 +196,7 @@ public void outbox_for_db_context_mapped()
[Fact]
public async Task persisting_against_mapped_dbcontext_does_not_start_an_explicit_transaction()
{
- await Host.ResetResourceState();
+ await Host.ResetResourceState(cancellation: TestContext.Current.CancellationToken);
var envelope = new Envelope
{
@@ -227,7 +227,7 @@ public async Task persisting_against_mapped_dbcontext_does_not_start_an_explicit
[Fact]
public async Task persist_an_outgoing_envelope_raw()
{
- await Host.ResetResourceState();
+ await Host.ResetResourceState(cancellation: TestContext.Current.CancellationToken);
var envelope = new Envelope
{
@@ -247,7 +247,7 @@ public async Task persist_an_outgoing_envelope_raw()
await messaging.Transaction!.PersistOutgoingAsync(envelope);
messaging.DbContext.Items.Add(new Item { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString() });
- await messaging.SaveChangesAndFlushMessagesAsync();
+ await messaging.SaveChangesAndFlushMessagesAsync(TestContext.Current.CancellationToken);
}
var persisted = await Host.Services.GetRequiredService()
@@ -268,7 +268,7 @@ public async Task persist_an_outgoing_envelope_raw()
[Fact]
public async Task persist_an_outgoing_envelope_mapped()
{
- await Host.ResetResourceState();
+ await Host.ResetResourceState(cancellation: TestContext.Current.CancellationToken);
var envelope = new Envelope
{
@@ -290,7 +290,7 @@ public async Task persist_an_outgoing_envelope_mapped()
await messaging.Transaction!.PersistOutgoingAsync(envelope);
messaging.DbContext.Items.Add(new Item { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString() });
- await messaging.SaveChangesAndFlushMessagesAsync();
+ await messaging.SaveChangesAndFlushMessagesAsync(TestContext.Current.CancellationToken);
}
var persisted = await Host.Services.GetRequiredService()
@@ -327,7 +327,7 @@ public async Task use_non_generic_outbox_raw()
context.Items.Add(new Item { Id = id, Name = "Bill" });
await messaging.SendAsync(new OutboxedMessage { Id = id });
- await messaging.SaveChangesAndFlushMessagesAsync();
+ await messaging.SaveChangesAndFlushMessagesAsync(TestContext.Current.CancellationToken);
}
var message = await waiter;
@@ -336,7 +336,7 @@ public async Task use_non_generic_outbox_raw()
using (var nested = Host.Services.CreateScope())
{
var context = nested.ServiceProvider.GetRequiredService();
- (await context.Items.FindAsync(id)).ShouldNotBeNull();
+ (await context.Items.FindAsync(new object?[] { id }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
}
}
@@ -359,7 +359,7 @@ public async Task use_non_generic_outbox_mapped()
context.Items.Add(new Item { Id = id, Name = "Bill" });
await messaging.SendAsync(new OutboxedMessage { Id = id });
- await messaging.SaveChangesAndFlushMessagesAsync();
+ await messaging.SaveChangesAndFlushMessagesAsync(TestContext.Current.CancellationToken);
}
var message = await waiter;
@@ -368,7 +368,7 @@ public async Task use_non_generic_outbox_mapped()
using (var nested = Host.Services.CreateScope())
{
var context = nested.ServiceProvider.GetRequiredService();
- (await context.Items.FindAsync(id)).ShouldNotBeNull();
+ (await context.Items.FindAsync(new object?[] { id }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
}
}
@@ -388,7 +388,7 @@ public async Task use_generic_outbox_raw()
outbox.DbContext.Items.Add(new Item { Id = id, Name = "Bill" });
await outbox.SendAsync(new OutboxedMessage { Id = id });
- await outbox.SaveChangesAndFlushMessagesAsync();
+ await outbox.SaveChangesAndFlushMessagesAsync(TestContext.Current.CancellationToken);
}
var message = await waiter;
@@ -397,7 +397,7 @@ public async Task use_generic_outbox_raw()
using (var nested = Host.Services.CreateScope())
{
var context = nested.ServiceProvider.GetRequiredService();
- (await context.Items.FindAsync(id)).ShouldNotBeNull();
+ (await context.Items.FindAsync(new object?[] { id }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
}
}
@@ -418,7 +418,7 @@ public async Task DbContextOutbox_generic_can_opt_into_multiple_save_changes_and
outbox.DbContext.Items.Add(new Item { Id = id1, Name = "First" });
await outbox.SendAsync(new OutboxedMessage { Id = id1 });
- await outbox.SaveChangesAndFlushMessagesAsync(MultiFlushMode.AllowMultiples);
+ await outbox.SaveChangesAndFlushMessagesAsync(MultiFlushMode.AllowMultiples, TestContext.Current.CancellationToken);
context.MultiFlushMode.ShouldBe(MultiFlushMode.OnlyOnce);
var message1 = await waiter1;
@@ -428,7 +428,7 @@ public async Task DbContextOutbox_generic_can_opt_into_multiple_save_changes_and
outbox.DbContext.Items.Add(new Item { Id = id2, Name = "Second" });
await outbox.SendAsync(new OutboxedMessage { Id = id2 });
- await outbox.SaveChangesAndFlushMessagesAsync(MultiFlushMode.AllowMultiples);
+ await outbox.SaveChangesAndFlushMessagesAsync(MultiFlushMode.AllowMultiples, TestContext.Current.CancellationToken);
context.MultiFlushMode.ShouldBe(MultiFlushMode.OnlyOnce);
var message2 = await waiter2;
@@ -438,8 +438,8 @@ public async Task DbContextOutbox_generic_can_opt_into_multiple_save_changes_and
using (var nested = Host.Services.CreateScope())
{
var context = nested.ServiceProvider.GetRequiredService();
- (await context.Items.FindAsync(id1)).ShouldNotBeNull();
- (await context.Items.FindAsync(id2)).ShouldNotBeNull();
+ (await context.Items.FindAsync(new object?[] { id1 }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
+ (await context.Items.FindAsync(new object?[] { id2 }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
}
}
@@ -462,7 +462,7 @@ public async Task DbContextOutbox_non_generic_can_opt_into_multiple_save_changes
context.Items.Add(new Item { Id = id1, Name = "First" });
await outbox.SendAsync(new OutboxedMessage { Id = id1 });
- await outbox.SaveChangesAndFlushMessagesAsync(MultiFlushMode.AllowMultiples);
+ await outbox.SaveChangesAndFlushMessagesAsync(MultiFlushMode.AllowMultiples, TestContext.Current.CancellationToken);
messageContext.MultiFlushMode.ShouldBe(MultiFlushMode.OnlyOnce);
var message1 = await waiter1;
@@ -472,7 +472,7 @@ public async Task DbContextOutbox_non_generic_can_opt_into_multiple_save_changes
context.Items.Add(new Item { Id = id2, Name = "Second" });
await outbox.SendAsync(new OutboxedMessage { Id = id2 });
- await outbox.SaveChangesAndFlushMessagesAsync(MultiFlushMode.AllowMultiples);
+ await outbox.SaveChangesAndFlushMessagesAsync(MultiFlushMode.AllowMultiples, TestContext.Current.CancellationToken);
messageContext.MultiFlushMode.ShouldBe(MultiFlushMode.OnlyOnce);
var message2 = await waiter2;
@@ -482,8 +482,8 @@ public async Task DbContextOutbox_non_generic_can_opt_into_multiple_save_changes
using (var nested = Host.Services.CreateScope())
{
var context = nested.ServiceProvider.GetRequiredService();
- (await context.Items.FindAsync(id1)).ShouldNotBeNull();
- (await context.Items.FindAsync(id2)).ShouldNotBeNull();
+ (await context.Items.FindAsync(new object?[] { id1 }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
+ (await context.Items.FindAsync(new object?[] { id2 }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
}
}
@@ -503,7 +503,7 @@ public async Task use_generic_outbox_mapped()
outbox.DbContext.Items.Add(new Item { Id = id, Name = "Bill" });
await outbox.SendAsync(new OutboxedMessage { Id = id });
- await outbox.SaveChangesAndFlushMessagesAsync();
+ await outbox.SaveChangesAndFlushMessagesAsync(TestContext.Current.CancellationToken);
}
var message = await waiter;
@@ -512,14 +512,14 @@ public async Task use_generic_outbox_mapped()
using (var nested = Host.Services.CreateScope())
{
var context = nested.ServiceProvider.GetRequiredService();
- (await context.Items.FindAsync(id)).ShouldNotBeNull();
+ (await context.Items.FindAsync(new object?[] { id }, TestContext.Current.CancellationToken)).ShouldNotBeNull();
}
}
[Fact]
public async Task persist_an_incoming_envelope_raw()
{
- await Host.ResetResourceState();
+ await Host.ResetResourceState(cancellation: TestContext.Current.CancellationToken);
var envelope = new Envelope
{
@@ -544,7 +544,7 @@ public async Task persist_an_incoming_envelope_raw()
messaging.Enroll(context);
await messaging.As().Transaction!.PersistIncomingAsync(envelope);
- await messaging.SaveChangesAndFlushMessagesAsync();
+ await messaging.SaveChangesAndFlushMessagesAsync(TestContext.Current.CancellationToken);
}
var persisted = await Host.Services.GetRequiredService()
@@ -564,7 +564,7 @@ public async Task persist_an_incoming_envelope_raw()
[Fact]
public async Task persist_an_incoming_envelope_mapped()
{
- await Host.ResetResourceState();
+ await Host.ResetResourceState(cancellation: TestContext.Current.CancellationToken);
var envelope = new Envelope
{
@@ -589,7 +589,7 @@ public async Task persist_an_incoming_envelope_mapped()
messaging.Enroll(context);
await messaging.As().Transaction!.PersistIncomingAsync(envelope);
- await messaging.SaveChangesAndFlushMessagesAsync();
+ await messaging.SaveChangesAndFlushMessagesAsync(TestContext.Current.CancellationToken);
}
var persisted = await Host.Services.GetRequiredService()
diff --git a/src/Persistence/EfCoreTests/idempotency_with_inline_or_buffered_endpoints_end_to_end.cs b/src/Persistence/EfCoreTests/idempotency_with_inline_or_buffered_endpoints_end_to_end.cs
index e2eb7a99b..9c837850b 100644
--- a/src/Persistence/EfCoreTests/idempotency_with_inline_or_buffered_endpoints_end_to_end.cs
+++ b/src/Persistence/EfCoreTests/idempotency_with_inline_or_buffered_endpoints_end_to_end.cs
@@ -59,7 +59,7 @@ public async Task happy_and_sad_path(IdempotencyStyle idempotency, bool isWolver
opts.PersistMessagesWithSqlServer(Servers.SqlServerConnectionString, "idempotency");
opts.UseEntityFrameworkCoreTransactions();
opts.UseEntityFrameworkCoreWolverineManagedMigrations();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var messageId = Guid.NewGuid();
var tracked1 = await host.SendMessageAndWaitAsync(new MaybeIdempotent(messageId));
@@ -110,7 +110,7 @@ public async Task happy_and_sad_path_with_message_and_destination_tracking(Idemp
opts.PersistMessagesWithSqlServer(Servers.SqlServerConnectionString, "idempotency");
opts.UseEntityFrameworkCoreTransactions();
opts.UseEntityFrameworkCoreWolverineManagedMigrations();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var messageId = Guid.NewGuid();
var tracked1 = await host.SendMessageAndWaitAsync(new MaybeIdempotent(messageId));
@@ -155,7 +155,7 @@ public async Task apply_idempotency_to_non_transactional_handler()
// THIS RIGHT HERE
opts.Policies.AutoApplyIdempotencyOnNonTransactionalHandlers();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
#endregion
diff --git a/src/Persistence/EfCoreTests/persisting_envelopes_with_sqlserver.cs b/src/Persistence/EfCoreTests/persisting_envelopes_with_sqlserver.cs
index a22fa1f5e..dc0577381 100644
--- a/src/Persistence/EfCoreTests/persisting_envelopes_with_sqlserver.cs
+++ b/src/Persistence/EfCoreTests/persisting_envelopes_with_sqlserver.cs
@@ -155,11 +155,11 @@ public async Task persist_outgoing_batch_uses_add_range()
var transaction = new EfCoreEnvelopeTransaction(dbContext, context);
await transaction.PersistOutgoingAsync(envelopes);
- await dbContext.SaveChangesAsync();
+ await dbContext.SaveChangesAsync(TestContext.Current.CancellationToken);
if (dbContext.Database.CurrentTransaction != null)
{
- await dbContext.Database.CurrentTransaction.CommitAsync();
+ await dbContext.Database.CurrentTransaction.CommitAsync(TestContext.Current.CancellationToken);
}
var storage = _host.Services.GetRequiredService();
diff --git a/src/Persistence/EfCoreTests/storage_dbcontext_selection_tests.cs b/src/Persistence/EfCoreTests/storage_dbcontext_selection_tests.cs
index fb6e971e9..e0eb236f7 100644
--- a/src/Persistence/EfCoreTests/storage_dbcontext_selection_tests.cs
+++ b/src/Persistence/EfCoreTests/storage_dbcontext_selection_tests.cs
@@ -28,8 +28,8 @@ public async Task storage_attribute_disambiguates_and_only_enrolls_that_context(
{
await using (var conn = new NpgsqlConnection(Servers.PostgresConnectionString))
{
- await conn.OpenAsync();
- await conn.DropSchemaAsync("invoice_storage_schema");
+ await conn.OpenAsync(TestContext.Current.CancellationToken);
+ await conn.DropSchemaAsync("invoice_storage_schema", ct: TestContext.Current.CancellationToken);
await conn.CreateCommand(
"""
CREATE SCHEMA "invoice_storage_schema";
@@ -38,7 +38,7 @@ CREATE TABLE invoice_storage_schema.invoices (
"Memo" text NOT NULL
);
""")
- .ExecuteNonQueryAsync();
+ .ExecuteNonQueryAsync(TestContext.Current.CancellationToken);
}
using var host = await Host.CreateDefaultBuilder()
@@ -60,7 +60,7 @@ CREATE TABLE invoice_storage_schema.invoices (
opts.Discovery.DisableConventionalDiscovery()
.IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
host.GetRuntime().Handlers.HandlerFor();
var chain = host.GetRuntime().Handlers.ChainFor();
@@ -79,7 +79,7 @@ CREATE TABLE invoice_storage_schema.invoices (
await using var scope = host.Services.CreateAsyncScope();
var db = scope.ServiceProvider.GetRequiredService();
- (await db.Invoices.AnyAsync(i => i.Id == invoiceId)).ShouldBeTrue();
+ (await db.Invoices.AnyAsync(i => i.Id == invoiceId, cancellationToken: TestContext.Current.CancellationToken)).ShouldBeTrue();
}
[Fact]
diff --git a/src/Persistence/EfCoreTests/transaction_middleware_mode_tests.cs b/src/Persistence/EfCoreTests/transaction_middleware_mode_tests.cs
index 218ab28cf..8ee9213d0 100644
--- a/src/Persistence/EfCoreTests/transaction_middleware_mode_tests.cs
+++ b/src/Persistence/EfCoreTests/transaction_middleware_mode_tests.cs
@@ -38,7 +38,7 @@ public async Task eager_mode_should_add_transaction_frame()
opts.Discovery.DisableConventionalDiscovery()
.IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var chain = host.GetRuntime().Handlers.ChainFor()!;
@@ -71,7 +71,7 @@ public async Task lightweight_mode_should_not_add_transaction_frame()
opts.Discovery.DisableConventionalDiscovery()
.IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
#endregion
@@ -103,7 +103,7 @@ public async Task transactional_attribute_lightweight_overrides_eager_default()
opts.Discovery.DisableConventionalDiscovery()
.IncludeType()
.IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
// Verify the auto-applied handler uses the Eager default
var eagerChain = host.GetRuntime().Handlers.ChainFor()!;
@@ -141,7 +141,7 @@ public async Task transactional_attribute_eager_overrides_lightweight_default()
opts.Discovery.DisableConventionalDiscovery()
.IncludeType()
.IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
// Verify the auto-applied handler uses the Lightweight default
var lightChain = host.GetRuntime().Handlers.ChainFor()!;
@@ -177,7 +177,7 @@ public async Task lightweight_attribute_with_storage_side_effects_should_not_add
opts.Discovery.DisableConventionalDiscovery()
.IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
// Force compilation
host.GetRuntime().Handlers.HandlerFor();
@@ -209,7 +209,7 @@ public async Task eager_attribute_with_storage_side_effects_should_add_transacti
opts.Discovery.DisableConventionalDiscovery()
.IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
// Force compilation
host.GetRuntime().Handlers.HandlerFor();
@@ -240,7 +240,7 @@ public async Task default_mode_is_eager()
opts.Discovery.DisableConventionalDiscovery()
.IncludeType();
- }).StartAsync();
+ }).StartAsync(cancellationToken: TestContext.Current.CancellationToken);
var chain = host.GetRuntime().Handlers.ChainFor()!;
@@ -271,7 +271,7 @@ public async Task handler_policy_eager_mode_is_honored_for_storage_action_saga_c
opts.Policies.Add>();
opts.Discovery.DisableConventionalDiscovery().IncludeType