diff --git a/src/Particular.LicensingComponent.UnitTests/.editorconfig b/src/Particular.LicensingComponent.UnitTests/.editorconfig index 474aec5159..0a6ae3dffe 100644 --- a/src/Particular.LicensingComponent.UnitTests/.editorconfig +++ b/src/Particular.LicensingComponent.UnitTests/.editorconfig @@ -6,7 +6,4 @@ dotnet_diagnostic.CA2007.severity = none # Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. # They are scheduled work, not accepted exceptions: remove a line once this project has no # violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0003.severity = none -dotnet_diagnostic.PS0006.severity = none -dotnet_diagnostic.PS0017.severity = none dotnet_diagnostic.PS0018.severity = none diff --git a/src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs b/src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs index b9318ecc88..0c35b77398 100644 --- a/src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs @@ -34,7 +34,7 @@ public async Task Should_return_known_endpoints_if_any() var auditQuery = new AuditQuery(NullLogger.Instance, new EndpointsApi_ReturningTwoEndpoints(), new FakeAuditCountApi(), new FakeConfigurationApi()); //Act - var endpoints = (await auditQuery.GetKnownEndpoints(default)).ToList(); + var endpoints = (await auditQuery.GetKnownEndpoints()).ToList(); //Assert Assert.That(endpoints, Is.Not.Null, "Endpoints should be found"); @@ -53,7 +53,7 @@ public async Task Should_return_audit_remotes() var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new FakeAuditCountApi(), new ConfigurationApi_ReturningOneValidAuditConfig()); //Act - var remotes = await auditQuery.GetAuditRemotes(default); + var remotes = await auditQuery.GetAuditRemotes(); //Assert Assert.That(remotes, Is.Not.Null, "Remotes should be found"); @@ -81,7 +81,7 @@ public async Task Should_return_successful_audit_connection_if_instances_exist_a var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new FakeAuditCountApi(), new ConfigurationApi_ReturningOneValidAuditConfig()); //Act - var connectionSettingsResult = await auditQuery.TestAuditConnection(default); + var connectionSettingsResult = await auditQuery.TestAuditConnection(); //Assert Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned"); @@ -103,7 +103,7 @@ public async Task Should_return_diagnostics_and_no_errors_when_no_remotes_define var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new FakeAuditCountApi(), confiApi); //Act - var connectionSettingsResult = await auditQuery.TestAuditConnection(default); + var connectionSettingsResult = await auditQuery.TestAuditConnection(); //Assert Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned"); @@ -128,7 +128,7 @@ public async Task Should_always_return_diagnostics_and_relevant_errors_when_inva var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new FakeAuditCountApi(), confiApi); //Act - var connectionSettingsResult = await auditQuery.TestAuditConnection(default); + var connectionSettingsResult = await auditQuery.TestAuditConnection(); //Assert Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned"); @@ -148,7 +148,7 @@ public async Task Should_return_correct_audit_count() var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new AuditCountApi_ReturningThreeAuditCounts(), new FakeConfigurationApi()); //Act - var auditCount = await auditQuery.GetAuditCountForEndpoint("Endpoint1", default); + var auditCount = await auditQuery.GetAuditCountForEndpoint("Endpoint1"); Assert.That(auditCount, Is.Not.Null, "AuditCount should be returned"); Assert.That(auditCount.Count, Is.EqualTo(3), "Invalid number of audit counts"); @@ -156,7 +156,7 @@ public async Task Should_return_correct_audit_count() class ConfigurationApi_ReturningOneValidAuditConfig : IConfigurationApi { - public Task GetConfig(CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task GetConfig(CancellationToken cancellationToken = default) => throw new NotImplementedException(); public Task GetRemoteConfigs(CancellationToken cancellationToken = default) { @@ -165,12 +165,12 @@ public Task GetRemoteConfigs(CancellationToken cancellati return Task.FromResult([remote]); } - public Task GetUrls(string baseUrl, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task GetUrls(string baseUrl, CancellationToken cancellationToken = default) => throw new NotImplementedException(); } class ConfigurationApi_Configurable : IConfigurationApi { - public Task GetConfig(CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task GetConfig(CancellationToken cancellationToken = default) => throw new NotImplementedException(); public Task GetRemoteConfigs(CancellationToken cancellationToken = default) { @@ -184,7 +184,7 @@ public Task GetRemoteConfigs(CancellationToken cancellati return Task.FromResult([remote]); } - public Task GetUrls(string baseUrl, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task GetUrls(string baseUrl, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public bool ReturnAuditConfig { get; set; } public string RemoteStatus { get; set; } @@ -194,7 +194,7 @@ public Task GetRemoteConfigs(CancellationToken cancellati class EndpointsApi_ReturningTwoEndpoints : IEndpointsApi { - public Task> GetEndpoints(CancellationToken cancellationToken) + public Task> GetEndpoints(CancellationToken cancellationToken = default) { return Task.FromResult>([ new Endpoint { Id = Guid.NewGuid(), Name = "Endpoint1" }, @@ -206,7 +206,7 @@ public Task> GetEndpoints(CancellationToken cancellationToken) class AuditCountApi_ReturningThreeAuditCounts : IAuditCountApi { - public async Task> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken) + public async Task> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken = default) { var auditCounts = new List { diff --git a/src/Particular.LicensingComponent.UnitTests/AuditThroughputCollectorHostedService_Tests.cs b/src/Particular.LicensingComponent.UnitTests/AuditThroughputCollectorHostedService_Tests.cs index 88a22d2cfd..3c2fdb5474 100644 --- a/src/Particular.LicensingComponent.UnitTests/AuditThroughputCollectorHostedService_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/AuditThroughputCollectorHostedService_Tests.cs @@ -133,7 +133,7 @@ await Task.Run(async () => } while (!token.IsCancellationRequested); }); - Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Audit, default); + Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Audit); //Assert Assert.That(foundEndpoint, Is.Not.Null, $"Expected endpoint {endpointName} not found."); @@ -181,9 +181,9 @@ await Task.Run(async () => }); await auditThroughputCollectorHostedService.StopAsync(token2); - Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Audit, default); + Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Audit); IDictionary> foundEndpointThroughput = - await DataStore.GetEndpointThroughputByQueueName([endpointName], default); + await DataStore.GetEndpointThroughputByQueueName([endpointName]); ThroughputData[] throughputData = foundEndpointThroughput[endpointName].ToArray(); // Assert @@ -210,19 +210,19 @@ class AuditQuery_NoAuditRemotes : IAuditQuery public Func ValidRemoteInstances => r => true; public Task> GetAuditCountForEndpoint(string endpointUrlName, - CancellationToken cancellationToken) => Task.FromResult>([]); + CancellationToken cancellationToken = default) => Task.FromResult>([]); - public Task> GetAuditRemotes(CancellationToken cancellationToken) => + public Task> GetAuditRemotes(CancellationToken cancellationToken = default) => Task.FromResult>([]); - public Task> GetKnownEndpoints(CancellationToken cancellationToken) + public Task> GetKnownEndpoints(CancellationToken cancellationToken = default) { InstanceParameter = true; return Task.FromResult>([]); } - public Task TestAuditConnection(CancellationToken cancellationToken) => + public Task TestAuditConnection(CancellationToken cancellationToken = default) => Task.FromResult( new ConnectionSettingsTestResult { ConnectionSuccessful = true, ConnectionErrorMessages = [] }); @@ -243,23 +243,23 @@ public AuditQuery_WithOneEndpoint(string endpointName, long throughputCount, Dat public Func ValidRemoteInstances => r => true; public Task> GetAuditCountForEndpoint(string endpointUrlName, - CancellationToken cancellationToken) + CancellationToken cancellationToken = default) { var auditCount = new AuditCount { UtcDate = ThroughputDate, Count = ThroughputCount }; return Task.FromResult(new List { auditCount }.AsEnumerable()); } - public Task> GetAuditRemotes(CancellationToken cancellationToken) => + public Task> GetAuditRemotes(CancellationToken cancellationToken = default) => Task.FromResult>([]); - public Task> GetKnownEndpoints(CancellationToken cancellationToken) + public Task> GetKnownEndpoints(CancellationToken cancellationToken = default) { var scEndpoint = new ServiceControlEndpoint { Name = EndpointName, HeartbeatsEnabled = true }; return Task.FromResult>([scEndpoint]); } - public Task TestAuditConnection(CancellationToken cancellationToken) => + public Task TestAuditConnection(CancellationToken cancellationToken = default) => Task.FromResult( new ConnectionSettingsTestResult { ConnectionSuccessful = true, ConnectionErrorMessages = [] }); @@ -275,19 +275,19 @@ class AuditQuery_ThrowingAnExceptionOnKnownEndpointsCall : IAuditQuery public Func ValidRemoteInstances => r => true; public Task> GetAuditCountForEndpoint(string endpointUrlName, - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public Task> GetAuditRemotes(CancellationToken cancellationToken) => + public Task> GetAuditRemotes(CancellationToken cancellationToken = default) => Task.FromResult>([]); - public Task> GetKnownEndpoints(CancellationToken cancellationToken) + public Task> GetKnownEndpoints(CancellationToken cancellationToken = default) { InstanceParameter = true; throw new Exception("Oops"); } - public Task TestAuditConnection(CancellationToken cancellationToken) => + public Task TestAuditConnection(CancellationToken cancellationToken = default) => throw new NotImplementedException(); public bool InstanceParameter { get; set; } @@ -303,17 +303,17 @@ class BrokerThroughputQuery_WithSanitization : IBrokerThroughputQuery public KeyDescriptionPair[] Settings => throw new NotImplementedException(); - public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) => + public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) => throw new NotImplementedException(); public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate, - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException(); public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException(); public Task<(bool Success, List Errors, string Diagnostics)> TestConnection( - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public string SanitizeEndpointName(string endpointName) { diff --git a/src/Particular.LicensingComponent.UnitTests/BrokerThroughputCollectorHostedServiceTests.cs b/src/Particular.LicensingComponent.UnitTests/BrokerThroughputCollectorHostedServiceTests.cs index 2b5506a498..69ed2e4d8c 100644 --- a/src/Particular.LicensingComponent.UnitTests/BrokerThroughputCollectorHostedServiceTests.cs +++ b/src/Particular.LicensingComponent.UnitTests/BrokerThroughputCollectorHostedServiceTests.cs @@ -138,7 +138,7 @@ public void Initialize(ReadOnlyDictionary settings) } public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate, - [EnumeratorCancellation] CancellationToken cancellationToken) + [EnumeratorCancellation] CancellationToken cancellationToken = default) { GetGetThroughputPerDay++; @@ -148,7 +148,7 @@ public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue } public async IAsyncEnumerable GetQueueNames( - [EnumeratorCancellation] CancellationToken cancellationToken) + [EnumeratorCancellation] CancellationToken cancellationToken = default) { if (GetQueueNamesCalls++ % 2 == 0) { @@ -168,7 +168,7 @@ public async IAsyncEnumerable GetQueueNames( public KeyDescriptionPair[] Settings { get; } = []; public Task<(bool Success, List Errors, string Diagnostics)> TestConnection( - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public string SanitizeEndpointName(string endpointName) => endpointName; public string SanitizedEndpointNameCleanser(string endpointName) => endpointName; @@ -187,7 +187,7 @@ public void Initialize(ReadOnlyDictionary settings) } public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate, - [EnumeratorCancellation] CancellationToken cancellationToken) + [EnumeratorCancellation] CancellationToken cancellationToken = default) { await Task.CompletedTask; @@ -195,7 +195,7 @@ public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue } public async IAsyncEnumerable GetQueueNames( - [EnumeratorCancellation] CancellationToken cancellationToken) + [EnumeratorCancellation] CancellationToken cancellationToken = default) { yield return new DefaultBrokerQueue("sales@one") { SanitizedName = "sales" }; yield return new DefaultBrokerQueue("sales@two") { SanitizedName = "sales" }; @@ -211,7 +211,7 @@ public async IAsyncEnumerable GetQueueNames( public KeyDescriptionPair[] Settings { get; } = []; public Task<(bool Success, List Errors, string Diagnostics)> TestConnection( - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public string SanitizeEndpointName(string endpointName) => endpointName; public string SanitizedEndpointNameCleanser(string endpointName) => endpointName; @@ -232,7 +232,7 @@ public void Initialize(ReadOnlyDictionary settings) } public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate, - [EnumeratorCancellation] CancellationToken cancellationToken) + [EnumeratorCancellation] CancellationToken cancellationToken = default) { await Task.CompletedTask; @@ -242,7 +242,7 @@ public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue } public async IAsyncEnumerable GetQueueNames( - [EnumeratorCancellation] CancellationToken cancellationToken) + [EnumeratorCancellation] CancellationToken cancellationToken = default) { yield return new DefaultBrokerQueue("marketing"); yield return new DefaultBrokerQueue("customer"); @@ -256,7 +256,7 @@ public async IAsyncEnumerable GetQueueNames( public KeyDescriptionPair[] Settings { get; } = []; public Task<(bool Success, List Errors, string Diagnostics)> TestConnection( - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public string SanitizeEndpointName(string endpointName) => endpointName; public string SanitizedEndpointNameCleanser(string endpointName) => endpointName; diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/DataStoreBuilder.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/DataStoreBuilder.cs index d2b1b1c93c..e579cf8f9c 100644 --- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/DataStoreBuilder.cs +++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/DataStoreBuilder.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Contracts; using Persistence; @@ -122,7 +123,7 @@ public async Task Build() { foreach (Endpoint endpoint in endpoints) { - await store.SaveEndpoint(endpoint, default); + await store.SaveEndpoint(endpoint); } ; @@ -132,7 +133,7 @@ public async Task Build() foreach (ThroughputData throughput in throughputList) { await store.RecordEndpointThroughput(endpointId.Name, throughput.ThroughputSource, - throughput.Select(entry => new EndpointDailyThroughput(entry.Key, entry.Value)).ToList(), default); + throughput.Select(entry => new EndpointDailyThroughput(entry.Key, entry.Value)).ToList()); } } } diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeAuditCountApi.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeAuditCountApi.cs index a130d66264..e9c715e857 100644 --- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeAuditCountApi.cs +++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeAuditCountApi.cs @@ -8,6 +8,6 @@ class FakeAuditCountApi : IAuditCountApi { - public Task> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken = default) => throw new NotImplementedException(); } } diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeBrokerThroughputQuery.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeBrokerThroughputQuery.cs index 86e97d3c5b..6beb384f0a 100644 --- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeBrokerThroughputQuery.cs +++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeBrokerThroughputQuery.cs @@ -17,17 +17,17 @@ class FakeBrokerThroughputQuery : IBrokerThroughputQuery public KeyDescriptionPair[] Settings => throw new NotImplementedException(); - public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) => + public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) => throw new NotImplementedException(); public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate, - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException(); public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException(); public Task<(bool Success, List Errors, string Diagnostics)> TestConnection( - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public string SanitizeEndpointName(string endpointName) => endpointName; public string SanitizedEndpointNameCleanser(string endpointName) => endpointName; diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeConfigurationApi.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeConfigurationApi.cs index 9f3a7fc3a0..d7d0893be2 100644 --- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeConfigurationApi.cs +++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeConfigurationApi.cs @@ -8,8 +8,8 @@ class FakeConfigurationApi : IConfigurationApi { - public Task GetConfig(CancellationToken cancellationToken) => throw new NotImplementedException(); - public Task GetRemoteConfigs(CancellationToken cancellationToken) => throw new NotImplementedException(); - public Task GetUrls(string baseUrl, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task GetConfig(CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public Task GetRemoteConfigs(CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public Task GetUrls(string baseUrl, CancellationToken cancellationToken = default) => throw new NotImplementedException(); } } diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeEndpointApi.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeEndpointApi.cs index 3f2a66a6c0..802db6d5f2 100644 --- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeEndpointApi.cs +++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeEndpointApi.cs @@ -9,6 +9,6 @@ class FakeEndpointApi : IEndpointsApi { - public Task> GetEndpoints(CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task> GetEndpoints(CancellationToken cancellationToken = default) => throw new NotImplementedException(); } } diff --git a/src/Particular.LicensingComponent.UnitTests/MonitoringService_Tests.cs b/src/Particular.LicensingComponent.UnitTests/MonitoringService_Tests.cs index c59a7b63c9..aa13b9852f 100644 --- a/src/Particular.LicensingComponent.UnitTests/MonitoringService_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/MonitoringService_Tests.cs @@ -37,12 +37,12 @@ public async Task Should_record_new_endpoint_and_throughput() }; byte[] messageBytes = JsonSerializer.SerializeToUtf8Bytes(message); - await configuration.MonitoringService.RecordMonitoringThroughput(messageBytes, default); + await configuration.MonitoringService.RecordMonitoringThroughput(messageBytes); // Act - Endpoint foundEndpoint = await DataStore.GetEndpoint("Endpoint1", ThroughputSource.Monitoring, default); + Endpoint foundEndpoint = await DataStore.GetEndpoint("Endpoint1", ThroughputSource.Monitoring); IDictionary> foundEndpointThroughput = - await DataStore.GetEndpointThroughputByQueueName(["Endpoint1"], default); + await DataStore.GetEndpointThroughputByQueueName(["Endpoint1"]); ThroughputData[] throughputData = foundEndpointThroughput["Endpoint1"].ToArray(); // Assert @@ -84,11 +84,11 @@ public async Task Should_sanitize_endpoint_name() var monitoringService = new MonitoringService(DataStore, new BrokerThroughputQuery_WithSanitization()); byte[] messageBytes = JsonSerializer.SerializeToUtf8Bytes(message); - await monitoringService.RecordMonitoringThroughput(messageBytes, default); + await monitoringService.RecordMonitoringThroughput(messageBytes); string endpointNameSanitized = "e-ndpoint-1"; // Act - Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Monitoring, default); + Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Monitoring); // Assert Assert.That(foundEndpoint, Is.Not.Null, $"Expected endpoint {endpointName} not found."); @@ -109,7 +109,7 @@ public async Task Should_return_successful_monitoring_connection_and_diagnostics // Act ConnectionSettingsTestResult connectionSettingsResult = - await configuration.MonitoringService.TestMonitoringConnection(default); + await configuration.MonitoringService.TestMonitoringConnection(); // Assert Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned"); @@ -139,7 +139,7 @@ public async Task Should_return_error_monitoring_connection_and_diagnostics_if_n // Act ConnectionSettingsTestResult connectionSettingsResult = - await configuration.MonitoringService.TestMonitoringConnection(default); + await configuration.MonitoringService.TestMonitoringConnection(); // Assert Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned"); @@ -169,17 +169,17 @@ class BrokerThroughputQuery_WithSanitization : IBrokerThroughputQuery public KeyDescriptionPair[] Settings => throw new NotImplementedException(); - public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) => + public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) => throw new NotImplementedException(); public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate, - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException(); public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException(); public Task<(bool Success, List Errors, string Diagnostics)> TestConnection( - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public string SanitizeEndpointName(string endpointName) { diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_AdditionalEnvironmentDataProvider_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_AdditionalEnvironmentDataProvider_Tests.cs index 8d42beea1d..732a6f8122 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_AdditionalEnvironmentDataProvider_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_AdditionalEnvironmentDataProvider_Tests.cs @@ -1,6 +1,7 @@ namespace Particular.LicensingComponent.UnitTests; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; @@ -22,7 +23,7 @@ public async Task Should_include_additional_environment_data_in_throughput_repor { // Arrange // Act - var report = await ThroughputCollector.GenerateThroughputReport(null, null, default); + var report = await ThroughputCollector.GenerateThroughputReport(null, null); // Assert Assert.That(report, Is.Not.Null); Assert.That(report.ReportData, Is.Not.Null); diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_GenerationStatus_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_GenerationStatus_Tests.cs index 96173bddb8..dc753860ac 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_GenerationStatus_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_GenerationStatus_Tests.cs @@ -1,6 +1,7 @@ namespace Particular.LicensingComponent.UnitTests; using System; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Particular.LicensingComponent.Contracts; @@ -25,7 +26,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default); + var reportGenerationState = await ThroughputCollector.GetReportGenerationState(); // Assert using (Assert.EnterMultipleScope()) @@ -45,7 +46,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default); + var reportGenerationState = await ThroughputCollector.GetReportGenerationState(); // Assert using (Assert.EnterMultipleScope()) @@ -66,7 +67,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default); + var reportGenerationState = await ThroughputCollector.GetReportGenerationState(); // Assert using (Assert.EnterMultipleScope()) @@ -87,7 +88,7 @@ await DataStore.CreateBuilder().AddEndpoint() .Build(); // Act - var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default); + var reportGenerationState = await ThroughputCollector.GetReportGenerationState(); // Assert using (Assert.EnterMultipleScope()) diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Dates_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Dates_Tests.cs index 096fed9bfe..6978ffa15b 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Dates_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Dates_Tests.cs @@ -2,6 +2,7 @@ using System; using System.Linq; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Particular.LicensingComponent.Contracts; @@ -41,7 +42,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert var minDateInReport = new DateTimeOffset(minDate.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc)); diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs index c79c987081..200ac65fa8 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs @@ -1,6 +1,7 @@ namespace Particular.LicensingComponent.UnitTests; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Contracts; @@ -27,7 +28,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -58,7 +59,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -82,7 +83,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -113,7 +114,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -145,7 +146,7 @@ await DataStore.CreateBuilder() // Act var spVersion = "5.1"; - var report = await ThroughputCollector.GenerateThroughputReport(spVersion, null, default); + var report = await ThroughputCollector.GenerateThroughputReport(spVersion, null); // Assert Assert.That(report, Is.Not.Null); @@ -170,14 +171,14 @@ await DataStore.CreateBuilder() var expectedBrokerVersion = "1.2"; var expectedScopeType = "testingScope"; - await DataStore.SaveBrokerMetadata(new BrokerMetadata(expectedScopeType, new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = expectedBrokerVersion }), default); + await DataStore.SaveBrokerMetadata(new BrokerMetadata(expectedScopeType, new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = expectedBrokerVersion })); var expectedAuditVersionSummary = new Dictionary { ["4.3.6"] = 2 }; var expectedAuditTransportSummary = new Dictionary { ["AzureServiceBus"] = 2 }; - await DataStore.SaveAuditServiceMetadata(new AuditServiceMetadata(expectedAuditVersionSummary, expectedAuditTransportSummary), default); + await DataStore.SaveAuditServiceMetadata(new AuditServiceMetadata(expectedAuditVersionSummary, expectedAuditTransportSummary)); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Indicator_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Indicator_Tests.cs index 68cab4dac4..9082429111 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Indicator_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Indicator_Tests.cs @@ -1,6 +1,7 @@ namespace Particular.LicensingComponent.UnitTests; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Contracts; using Infrastructure; @@ -31,7 +32,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -53,7 +54,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Masking_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Masking_Tests.cs index e3bdb7db7a..d589dcaab3 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Masking_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Masking_Tests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Particular.LicensingComponent.Contracts; @@ -28,10 +29,10 @@ await DataStore.CreateBuilder() .AddEndpoint("Endpoint3", sources: [ThroughputSource.Broker]).WithThroughput(days: 2) .Build(); var expectedReportMasks = new List { "Endpoint1" }; - await DataStore.SaveReportMasks(expectedReportMasks, default); + await DataStore.SaveReportMasks(expectedReportMasks); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -56,7 +57,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Throughput_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Throughput_Tests.cs index 6603abcad0..ac4503a4ca 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Throughput_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Throughput_Tests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Contracts; using Infrastructure; @@ -37,7 +38,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -67,7 +68,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -94,7 +95,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -112,7 +113,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -132,7 +133,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -170,7 +171,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -197,7 +198,7 @@ public async Task Should_return_correct_throughput_in_report_when_endpoint_has_n await DataStore.CreateBuilder().AddEndpoint().Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -224,7 +225,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -258,7 +259,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var report = await ThroughputCollector.GenerateThroughputReport("", null, default); + var report = await ThroughputCollector.GenerateThroughputReport("", null); // Assert Assert.That(report, Is.Not.Null); @@ -298,18 +299,18 @@ await DataStore.CreateBuilder() .Build(); var expectedReportMasks = new List { "Endpoint1" }; - await DataStore.SaveReportMasks(expectedReportMasks, default); + await DataStore.SaveReportMasks(expectedReportMasks); var expectedBrokerVersion = "1.2"; var expectedScopeType = "testingScope"; - await DataStore.SaveBrokerMetadata(new BrokerMetadata(expectedScopeType, new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = expectedBrokerVersion }), default); + await DataStore.SaveBrokerMetadata(new BrokerMetadata(expectedScopeType, new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = expectedBrokerVersion })); var expectedAuditVersionSummary = new Dictionary { ["4.3.6"] = 2 }; var expectedAuditTransportSummary = new Dictionary { ["AzureServiceBus"] = 2 }; - await DataStore.SaveAuditServiceMetadata(new AuditServiceMetadata(expectedAuditVersionSummary, expectedAuditTransportSummary), default); + await DataStore.SaveAuditServiceMetadata(new AuditServiceMetadata(expectedAuditVersionSummary, expectedAuditTransportSummary)); // Act - var report = await ThroughputCollector.GenerateThroughputReport("2.3.1", new DateTime(2024, 4, 25), default); + var report = await ThroughputCollector.GenerateThroughputReport("2.3.1", new DateTime(2024, 4, 25)); var reportString = System.Text.Json.JsonSerializer.Serialize(report, SerializationOptions.IndentedWithNoEscaping); // Assert diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_SanitizedNameGrouping_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_SanitizedNameGrouping_Tests.cs index 703e842cea..24cc1783b0 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_SanitizedNameGrouping_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_SanitizedNameGrouping_Tests.cs @@ -38,7 +38,7 @@ await DataStore.CreateBuilder() var throughputCollector = new ThroughputCollector(DataStore, configuration.ThroughputSettings, configuration.AuditQuery, configuration.MonitoringService, [], new BrokerThroughputQuery_WithLowerCaseSanitizedNameCleanse()); // Act - var summary = await throughputCollector.GetThroughputSummary(default); + var summary = await throughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -64,7 +64,7 @@ await DataStore.CreateBuilder() var throughputCollector = new ThroughputCollector(DataStore, configuration.ThroughputSettings, configuration.AuditQuery, configuration.MonitoringService, [], new BrokerThroughputQuery_WithLowerCaseSanitizedNameCleanse()); // Act - var report = await throughputCollector.GenerateThroughputReport(null, null, default); + var report = await throughputCollector.GenerateThroughputReport(null, null); // Assert Assert.That(report, Is.Not.Null); @@ -91,7 +91,7 @@ await DataStore.CreateBuilder() var throughputCollector = new ThroughputCollector(DataStore, configuration.ThroughputSettings, configuration.AuditQuery, configuration.MonitoringService, [], new BrokerThroughputQuery_WithNoSanitizedNameCleanse()); // Act - var summary = await throughputCollector.GetThroughputSummary(default); + var summary = await throughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -117,7 +117,7 @@ await DataStore.CreateBuilder() var throughputCollector = new ThroughputCollector(DataStore, configuration.ThroughputSettings, configuration.AuditQuery, configuration.MonitoringService, [], new BrokerThroughputQuery_WithNoSanitizedNameCleanse()); // Act - var report = await throughputCollector.GenerateThroughputReport(null, null, default); + var report = await throughputCollector.GenerateThroughputReport(null, null); // Assert Assert.That(report, Is.Not.Null); @@ -136,17 +136,17 @@ class BrokerThroughputQuery_WithLowerCaseSanitizedNameCleanse : IBrokerThroughpu public KeyDescriptionPair[] Settings => throw new NotImplementedException(); - public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) => + public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) => throw new NotImplementedException(); public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate, - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException(); public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException(); public Task<(bool Success, List Errors, string Diagnostics)> TestConnection( - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public string SanitizeEndpointName(string endpointName) => endpointName; @@ -163,17 +163,17 @@ class BrokerThroughputQuery_WithNoSanitizedNameCleanse : IBrokerThroughputQuery public KeyDescriptionPair[] Settings => throw new NotImplementedException(); - public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) => + public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) => throw new NotImplementedException(); public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate, - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException(); public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException(); public Task<(bool Success, List Errors, string Diagnostics)> TestConnection( - CancellationToken cancellationToken) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) => throw new NotImplementedException(); public string SanitizeEndpointName(string endpointName) => endpointName; diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSumary_Indicator_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSumary_Indicator_Tests.cs index ec54124799..a6922f683c 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSumary_Indicator_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSumary_Indicator_Tests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Particular.LicensingComponent.Contracts; @@ -36,7 +37,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -54,14 +55,14 @@ await DataStore.CreateBuilder() .AddEndpoint("Endpoint1", sources: [ThroughputSource.Broker]).WithThroughput(days: 2) .AddEndpoint("Endpoint1", sources: [ThroughputSource.Monitoring]).WithThroughput(days: 2) .Build(); - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Act List endpointsWithUpdates = [new UpdateUserIndicator() { Name = "Endpoint1", UserIndicator = userIndicator }]; - await ThroughputCollector.UpdateUserIndicatorsOnEndpoints(endpointsWithUpdates, default); + await ThroughputCollector.UpdateUserIndicatorsOnEndpoints(endpointsWithUpdates); // Assert - var updatedEndpoints = await DataStore.GetAllEndpoints(true, default); + var updatedEndpoints = await DataStore.GetAllEndpoints(true); Assert.That(updatedEndpoints, Is.Not.Null); Assert.That(updatedEndpoints.Count, Is.EqualTo(2)); diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSummary_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSummary_Tests.cs index b3007fe41f..e012779408 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSummary_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSummary_Tests.cs @@ -35,7 +35,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -55,7 +55,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -73,7 +73,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -93,7 +93,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -125,7 +125,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -183,7 +183,7 @@ public async Task Should_return_correct_max_daily_throughput_in_summary_when_end await DataStore.CreateBuilder().AddEndpoint().Build(); // Act - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); @@ -204,7 +204,7 @@ await DataStore.CreateBuilder() .Build(); // Act - var summary = await ThroughputCollector.GetThroughputSummary(default); + var summary = await ThroughputCollector.GetThroughputSummary(); // Assert Assert.That(summary, Is.Not.Null); diff --git a/src/ServiceControl.AcceptanceTests.RavenDB/.editorconfig b/src/ServiceControl.AcceptanceTests.RavenDB/.editorconfig index bbcb303765..5f68a610b3 100644 --- a/src/ServiceControl.AcceptanceTests.RavenDB/.editorconfig +++ b/src/ServiceControl.AcceptanceTests.RavenDB/.editorconfig @@ -2,9 +2,3 @@ # Justification: Test project dotnet_diagnostic.CA2007.severity = none - -# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. -# They are scheduled work, not accepted exceptions: remove a line once this project has no -# violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0003.severity = none -dotnet_diagnostic.PS0018.severity = none diff --git a/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/FailedErrorsController.cs b/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/FailedErrorsController.cs index c22a6f6e7e..2a6ce095f0 100644 --- a/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/FailedErrorsController.cs +++ b/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/FailedErrorsController.cs @@ -20,7 +20,7 @@ public class FailedErrorsController(IRavenSessionProvider sessionProvider, Impor { [Route("failederrors/count")] [HttpGet] - public async Task GetFailedErrorsCount(CancellationToken cancellationToken) + public async Task GetFailedErrorsCount(CancellationToken cancellationToken = default) { using var session = await sessionProvider.OpenSession(cancellationToken: cancellationToken); var query = diff --git a/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/FailedMessageRetriesController.cs b/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/FailedMessageRetriesController.cs index b511a9db28..705806daba 100644 --- a/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/FailedMessageRetriesController.cs +++ b/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/FailedMessageRetriesController.cs @@ -19,7 +19,7 @@ public class FailedMessageRetriesController(IRavenSessionProvider sessionProvide { [Route("failedmessageretries/count")] [HttpGet] - public async Task GetFailedMessageRetriesCount(CancellationToken cancellationToken) + public async Task GetFailedMessageRetriesCount(CancellationToken cancellationToken = default) { using var session = await sessionProvider.OpenSession(cancellationToken: cancellationToken); await session.Query().Statistics(out var stats).ToListAsync(cancellationToken); diff --git a/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/When_a_message_fails_to_import.cs b/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/When_a_message_fails_to_import.cs index 5780d4e716..e1749990c0 100644 --- a/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/When_a_message_fails_to_import.cs +++ b/src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/When_a_message_fails_to_import.cs @@ -77,7 +77,7 @@ public async Task It_can_be_reimported() class MessageFailedHandler(MyContext scenarioContext) : IDomainHandler { - public Task Handle(MessageFailed domainEvent, CancellationToken cancellationToken) + public Task Handle(MessageFailed domainEvent, CancellationToken cancellationToken = default) { scenarioContext.MessageFailedEventPublished = true; return Task.CompletedTask; diff --git a/src/ServiceControl.AcceptanceTests/.editorconfig b/src/ServiceControl.AcceptanceTests/.editorconfig index 4fcb63e0be..a32084aea3 100644 --- a/src/ServiceControl.AcceptanceTests/.editorconfig +++ b/src/ServiceControl.AcceptanceTests/.editorconfig @@ -3,14 +3,14 @@ # Justification: Test project dotnet_diagnostic.CA2007.severity = none -# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. -# They are scheduled work, not accepted exceptions: remove a line once this project has no -# violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0003.severity = none -dotnet_diagnostic.PS0013.severity = none -dotnet_diagnostic.PS0017.severity = none -dotnet_diagnostic.PS0018.severity = none - # Timezone debt: these DateTime values are Kind=Unspecified or Local, so the implicit cast to # DateTimeOffset uses the build agent's offset. Each needs individual review before removing. dotnet_diagnostic.PS0022.severity = none + +# Justification: these are the test helpers the NServiceBus.AcceptanceTesting scenario API drives. +# It calls Done/When callbacks and IComponentBehavior/ComponentRunner without a CancellationToken, +# so a token added here could only ever be CancellationToken.None at every call site, which tests +# nothing. Tests that genuinely exercise cancellation use [Test, CancelAfter(...)] with the token +# NUnit injects, and forward that. Helpers reachable with a real token do take one. +dotnet_diagnostic.PS0013.severity = none +dotnet_diagnostic.PS0018.severity = none diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/KnownEndpointPersistenceQueryController.cs b/src/ServiceControl.AcceptanceTests/Monitoring/KnownEndpointPersistenceQueryController.cs index 1790818a34..f8b25b5206 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/KnownEndpointPersistenceQueryController.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/KnownEndpointPersistenceQueryController.cs @@ -1,6 +1,7 @@ namespace ServiceControl.AcceptanceTests.Monitoring { using System.Collections.Generic; + using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using ServiceControl.Persistence; @@ -11,6 +12,6 @@ public class KnownEndpointPersistenceQueryController(IMonitoringDataStore dataSt { [Route("test/knownendpoints/query")] [HttpGet] - public async Task> GetKnownEndpoints() => await dataStore.GetAllKnownEndpoints(); + public async Task> GetKnownEndpoints(CancellationToken cancellationToken = default) => await dataStore.GetAllKnownEndpoints(cancellationToken); } } \ No newline at end of file diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/FailedMessageExtensions.cs b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/FailedMessageExtensions.cs index 262991a3b3..45ec710995 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/FailedMessageExtensions.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/FailedMessageExtensions.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using ServiceControl.AcceptanceTesting; using ServiceControl.AcceptanceTests; @@ -7,10 +8,10 @@ public static class FailedMessageExtensions { - internal static async Task GetOnlyFailedUnresolvedMessageId(this AcceptanceTest test) + internal static async Task GetOnlyFailedUnresolvedMessageId(this AcceptanceTest test, CancellationToken cancellationToken = default) { var allFailedMessages = - await test.TryGet>($"/api/errors/?status=unresolved"); + await test.TryGet>($"/api/errors/?status=unresolved", cancellationToken: cancellationToken); if (!allFailedMessages.HasResult) { return null; diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_group_is_archived.cs b/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_group_is_archived.cs index 2e3455cc29..b1db1044bc 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_group_is_archived.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_group_is_archived.cs @@ -165,7 +165,7 @@ await Define() [Test] [CancelAfter(120_000)] - public async Task Only_unresolved_issues_should_be_archived(CancellationToken cancellationToken) + public async Task Only_unresolved_issues_should_be_archived(CancellationToken cancellationToken = default) { await Define() .WithEndpoint(b => b.When(async bus => diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_group_is_retried.cs b/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_group_is_retried.cs index 3e32fba255..df2ba2a532 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_group_is_retried.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_group_is_retried.cs @@ -17,7 +17,7 @@ class When_a_group_is_retried : AcceptanceTest { [Test] [CancelAfter(120_000)] - public async Task Only_unresolved_issues_should_be_retried(CancellationToken cancellationToken) + public async Task Only_unresolved_issues_should_be_retried(CancellationToken cancellationToken = default) { FailedMessage messageToBeRetriedAsPartOfGroupRetry = null; FailedMessage messageToBeArchived = null; diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_message_fails_twice_with_different_exceptions.cs b/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_message_fails_twice_with_different_exceptions.cs index 3668a8b7f4..ca914f59b2 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_message_fails_twice_with_different_exceptions.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/Groups/When_a_message_fails_twice_with_different_exceptions.cs @@ -19,7 +19,7 @@ class When_a_message_fails_twice_with_different_exceptions : AcceptanceTest { [Test] [CancelAfter(180_000)] - public async Task Only_the_second_groups_should_apply(CancellationToken cancellationToken) + public async Task Only_the_second_groups_should_apply(CancellationToken cancellationToken = default) { FailedMessage originalMessage = null; FailedMessage retriedMessage = null; diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/ErrorImportPerformanceTests.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/ErrorImportPerformanceTests.cs index 72fe25eff0..a0a56c6336 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/ErrorImportPerformanceTests.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/ErrorImportPerformanceTests.cs @@ -16,7 +16,7 @@ class ErrorImportPerformanceTests : AcceptanceTest { [Test] [CancelAfter(180_000)] - public async Task Should_import_all_messages(CancellationToken cancellationToken) + public async Task Should_import_all_messages(CancellationToken cancellationToken = default) { await Define() .WithEndpoint(b => b.When(bus => Task.WhenAll(Enumerable.Repeat(0, 100).Select(i => bus.SendLocal(new MyMessage())))).DoNotFailOnErrorMessages()) diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_invalid_id_is_sent_to_retry.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_invalid_id_is_sent_to_retry.cs index 068f7b0dda..630e7b938c 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_invalid_id_is_sent_to_retry.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_invalid_id_is_sent_to_retry.cs @@ -15,7 +15,7 @@ class When_a_invalid_id_is_sent_to_retry : AcceptanceTest { [Test] [CancelAfter(180_000)] - public async Task SubsequentBatchesShouldBeProcessed(CancellationToken cancellationToken) + public async Task SubsequentBatchesShouldBeProcessed(CancellationToken cancellationToken = default) { var context = await Define() .WithEndpoint(cfg => cfg diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs index a26f067f09..1c6bd75b5b 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs @@ -146,7 +146,7 @@ public async Task Should_be_listed_in_the_error_list() [Test] [CancelAfter(120_000)] - public async Task Should_be_listed_in_the_messages_list(CancellationToken cancellationToken) + public async Task Should_be_listed_in_the_messages_list(CancellationToken cancellationToken = default) { var failure = new MessagesView(); diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_fails_to_be_sent.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_fails_to_be_sent.cs index bbeea18019..ec575fb481 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_fails_to_be_sent.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_fails_to_be_sent.cs @@ -25,7 +25,7 @@ class When_a_retry_fails_to_be_sent : AcceptanceTest { [Test] [CancelAfter(180_000)] - public async Task SubsequentBatchesShouldBeProcessed(CancellationToken cancellationToken) + public async Task SubsequentBatchesShouldBeProcessed(CancellationToken cancellationToken = default) { FailedMessage decomissionedFailure = null, successfullyRetried = null; diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_empty_body_message_is_successful.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_empty_body_message_is_successful.cs index 73ee896515..1cc7e3494b 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_empty_body_message_is_successful.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_empty_body_message_is_successful.cs @@ -22,7 +22,7 @@ class When_a_retry_for_a_empty_body_message_is_successful : AcceptanceTest { [Test] [CancelAfter(120_000)] - public async Task Should_show_up_as_resolved_when_doing_a_single_retry(CancellationToken cancellationToken) + public async Task Should_show_up_as_resolved_when_doing_a_single_retry(CancellationToken cancellationToken = default) { FailedMessage failure = null; diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_failed_message_fails.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_failed_message_fails.cs index 716f707c4f..fc3bfbcdb7 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_failed_message_fails.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_failed_message_fails.cs @@ -17,7 +17,7 @@ class When_a_retry_for_a_failed_message_fails : AcceptanceTest { [Test] [CancelAfter(120_000)] - public async Task It_should_be_marked_as_unresolved(CancellationToken cancellationToken) + public async Task It_should_be_marked_as_unresolved(CancellationToken cancellationToken = default) { var result = await Define(ctx => { ctx.Succeed = false; }) .WithEndpoint(b => @@ -49,7 +49,7 @@ public async Task It_should_be_marked_as_unresolved(CancellationToken cancellati [Test] [CancelAfter(120_000)] - public async Task It_should_be_able_to_be_retried_successfully(CancellationToken cancellationToken) + public async Task It_should_be_able_to_be_retried_successfully(CancellationToken cancellationToken = default) { var result = await Define(ctx => { ctx.Succeed = false; }) .WithEndpoint(b => diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_failed_message_is_successful.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_failed_message_is_successful.cs index 44a06395af..dd232ed5a0 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_failed_message_is_successful.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_retry_for_a_failed_message_is_successful.cs @@ -20,7 +20,7 @@ class When_a_retry_for_a_failed_message_is_successful : AcceptanceTest { [Test] [CancelAfter(120_000)] - public async Task Should_show_up_as_resolved_in_the_eventlog(CancellationToken cancellationToken) + public async Task Should_show_up_as_resolved_in_the_eventlog(CancellationToken cancellationToken = default) { FailedMessage failure = null; List eventLogItems = null; @@ -58,7 +58,7 @@ await Define() [Test] [CancelAfter(120_000)] - public async Task Should_show_up_as_resolved_when_doing_a_multi_retry(CancellationToken cancellationToken) + public async Task Should_show_up_as_resolved_when_doing_a_multi_retry(CancellationToken cancellationToken = default) { FailedMessage failure = null; @@ -89,7 +89,7 @@ await Define() [Test] [CancelAfter(120_000)] - public async Task Should_show_up_as_resolved_when_doing_a_retry_all(CancellationToken cancellationToken) + public async Task Should_show_up_as_resolved_when_doing_a_retry_all(CancellationToken cancellationToken = default) { FailedMessage failure = null; @@ -120,7 +120,7 @@ await Define() [Test] [CancelAfter(120_000)] - public async Task Acknowledging_the_retry_should_be_successful(CancellationToken cancellationToken) + public async Task Acknowledging_the_retry_should_be_successful(CancellationToken cancellationToken = default) { FailedMessage failure; @@ -149,7 +149,7 @@ await Define() [Test] [CancelAfter(120_000)] - public async Task Should_show_up_as_resolved_when_doing_a_retry_all_for_the_given_endpoint(CancellationToken cancellationToken) + public async Task Should_show_up_as_resolved_when_doing_a_retry_all_for_the_given_endpoint(CancellationToken cancellationToken = default) { FailedMessage failure = null; diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_all_messages_are_retried.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_all_messages_are_retried.cs index d77fa5da40..c30c63f3ff 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_all_messages_are_retried.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_all_messages_are_retried.cs @@ -17,7 +17,7 @@ class When_all_messages_are_retried : AcceptanceTest { [Test] [CancelAfter(180_000)] - public async Task Only_unresolved_issues_should_be_retried(CancellationToken cancellationToken) + public async Task Only_unresolved_issues_should_be_retried(CancellationToken cancellationToken = default) { FailedMessage messageToBeRetriedAsPartOfRetryAll = null; FailedMessage messageToBeArchived = null; diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageRedirects/When_a_message_is_retried.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageRedirects/When_a_message_is_retried.cs index d373dcee4d..5235d39c36 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageRedirects/When_a_message_is_retried.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageRedirects/When_a_message_is_retried.cs @@ -18,7 +18,7 @@ class When_a_message_is_retried_with_a_redirect : AcceptanceTest { [Test] [CancelAfter(120_000)] - public async Task It_should_be_sent_to_the_correct_endpoint(CancellationToken cancellationToken) + public async Task It_should_be_sent_to_the_correct_endpoint(CancellationToken cancellationToken = default) { var context = await Define() .WithEndpoint(b => b.When(bus => bus.SendLocal(new MessageToRetry())) diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/When_a_message_is_retried_and_succeeds_with_a_reply.cs b/src/ServiceControl.AcceptanceTests/Recoverability/When_a_message_is_retried_and_succeeds_with_a_reply.cs index 5b87a5aaf9..81711ab5b8 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/When_a_message_is_retried_and_succeeds_with_a_reply.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/When_a_message_is_retried_and_succeeds_with_a_reply.cs @@ -17,7 +17,7 @@ class When_a_message_is_retried_and_succeeds_with_a_reply : AcceptanceTest { [Test] [CancelAfter(60_000)] - public async Task The_reply_should_go_to_the_correct_endpoint(CancellationToken cancellation) + public async Task The_reply_should_go_to_the_correct_endpoint(CancellationToken cancellationToken = default) { var context = await Define() .WithEndpoint(c => c.When(bus => bus.Send(new OriginalMessage()))) @@ -43,7 +43,7 @@ public async Task The_reply_should_go_to_the_correct_endpoint(CancellationToken return !string.IsNullOrWhiteSpace(c.ReplyHandledBy); }) - .Run(cancellation); + .Run(cancellationToken); Assert.That(context.ReplyHandledBy, Is.EqualTo("Originating Endpoint"), "Reply handled by incorrect endpoint"); } diff --git a/src/ServiceControl.Audit.AcceptanceTests.RavenDB/.editorconfig b/src/ServiceControl.Audit.AcceptanceTests.RavenDB/.editorconfig index bbcb303765..0a6ae3dffe 100644 --- a/src/ServiceControl.Audit.AcceptanceTests.RavenDB/.editorconfig +++ b/src/ServiceControl.Audit.AcceptanceTests.RavenDB/.editorconfig @@ -6,5 +6,4 @@ dotnet_diagnostic.CA2007.severity = none # Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. # They are scheduled work, not accepted exceptions: remove a line once this project has no # violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0003.severity = none dotnet_diagnostic.PS0018.severity = none diff --git a/src/ServiceControl.Audit.AcceptanceTests.RavenDB/Auditing/When_critical_storage_threshold_reached.cs b/src/ServiceControl.Audit.AcceptanceTests.RavenDB/Auditing/When_critical_storage_threshold_reached.cs index 852e23c1e5..d87622ec54 100644 --- a/src/ServiceControl.Audit.AcceptanceTests.RavenDB/Auditing/When_critical_storage_threshold_reached.cs +++ b/src/ServiceControl.Audit.AcceptanceTests.RavenDB/Auditing/When_critical_storage_threshold_reached.cs @@ -50,7 +50,7 @@ await Define() [Test] [CancelAfter(120_000)] - public async Task Should_stop_ingestion_and_resume_when_more_space_is_available(CancellationToken cancellationToken) + public async Task Should_stop_ingestion_and_resume_when_more_space_is_available(CancellationToken cancellationToken = default) { SetStorageConfiguration = static d => d.Add(RavenPersistenceConfiguration.MinimumStorageLeftRequiredForIngestionKey, "0"); diff --git a/src/ServiceControl.Audit.UnitTests/.editorconfig b/src/ServiceControl.Audit.UnitTests/.editorconfig index bbcb303765..0a6ae3dffe 100644 --- a/src/ServiceControl.Audit.UnitTests/.editorconfig +++ b/src/ServiceControl.Audit.UnitTests/.editorconfig @@ -6,5 +6,4 @@ dotnet_diagnostic.CA2007.severity = none # Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. # They are scheduled work, not accepted exceptions: remove a line once this project has no # violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0003.severity = none dotnet_diagnostic.PS0018.severity = none diff --git a/src/ServiceControl.Audit.UnitTests/BodyStorage/BodyStorageEnricherTests.cs b/src/ServiceControl.Audit.UnitTests/BodyStorage/BodyStorageEnricherTests.cs index d0e7f00a2b..d559fdcf4e 100644 --- a/src/ServiceControl.Audit.UnitTests/BodyStorage/BodyStorageEnricherTests.cs +++ b/src/ServiceControl.Audit.UnitTests/BodyStorage/BodyStorageEnricherTests.cs @@ -262,13 +262,13 @@ class FakeBodyStorage : IBodyStorage { public int StoredBodySize { get; set; } - public Task Store(string bodyId, string contentType, int bodySize, Stream bodyStream, CancellationToken cancellationToken) + public Task Store(string bodyId, string contentType, int bodySize, Stream bodyStream, CancellationToken cancellationToken = default) { StoredBodySize = bodySize; return Task.CompletedTask; } - public Task TryFetch(string bodyId, CancellationToken cancellationToken) + public Task TryFetch(string bodyId, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } diff --git a/src/ServiceControl.Infrastructure.Tests/.editorconfig b/src/ServiceControl.Infrastructure.Tests/.editorconfig index b09da988d4..07eabf2b62 100644 --- a/src/ServiceControl.Infrastructure.Tests/.editorconfig +++ b/src/ServiceControl.Infrastructure.Tests/.editorconfig @@ -3,7 +3,3 @@ # Justification: Test project dotnet_diagnostic.CA2007.severity = none -# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. -# They are scheduled work, not accepted exceptions: remove a line once this project has no -# violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0019.severity = none diff --git a/src/ServiceControl.Infrastructure.Tests/WatchdogTests.cs b/src/ServiceControl.Infrastructure.Tests/WatchdogTests.cs index ea786ed314..c3d5c5fc8a 100644 --- a/src/ServiceControl.Infrastructure.Tests/WatchdogTests.cs +++ b/src/ServiceControl.Infrastructure.Tests/WatchdogTests.cs @@ -63,6 +63,10 @@ public async Task When_stop_fails_stop_should_throw_identifying_ungraceful_stop( await dog.Stop(TestContext.CurrentContext.CancellationToken); Assert.Fail("Should have thrown an exception"); } + catch (OperationCanceledException) when (TestContext.CurrentContext.CancellationToken.IsCancellationRequested) + { + throw; + } catch (Exception ex) { Assert.That(ex.Message, Is.EqualTo("Simulated")); diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/.editorconfig b/src/ServiceControl.MultiInstance.AcceptanceTests/.editorconfig index b0c4497648..3eca2918ad 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/.editorconfig +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/.editorconfig @@ -3,9 +3,10 @@ # Justification: Test project dotnet_diagnostic.CA2007.severity = none -# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. -# They are scheduled work, not accepted exceptions: remove a line once this project has no -# violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0003.severity = none +# Justification: these are the test helpers the NServiceBus.AcceptanceTesting scenario API drives. +# It calls Done/When callbacks and IComponentBehavior/ComponentRunner without a CancellationToken, +# so a token added here could only ever be CancellationToken.None at every call site, which tests +# nothing. Tests that genuinely exercise cancellation use [Test, CancelAfter(...)] with the token +# NUnit injects, and forward that. Helpers reachable with a real token do take one. dotnet_diagnostic.PS0013.severity = none dotnet_diagnostic.PS0018.severity = none diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/Auditing/When_requesting_a_message_body.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/Auditing/When_requesting_a_message_body.cs index 7188e391a5..9766f79249 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/Auditing/When_requesting_a_message_body.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/Auditing/When_requesting_a_message_body.cs @@ -22,7 +22,7 @@ class When_requesting_a_message_body : AcceptanceTest { [Test] [CancelAfter(120_000)] - public async Task Should_be_forwarded_to_audit_instance(CancellationToken cancellationToken) + public async Task Should_be_forwarded_to_audit_instance(CancellationToken cancellationToken = default) { string addressOfAuditInstance = null; diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/Infrastructure/When_remote_instance_is_not_reachable.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/Infrastructure/When_remote_instance_is_not_reachable.cs index 704dcb3220..e1fefebbc0 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/Infrastructure/When_remote_instance_is_not_reachable.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/Infrastructure/When_remote_instance_is_not_reachable.cs @@ -49,7 +49,7 @@ await Define() class RemoteNotAvailableHandler : HttpMessageHandler { - protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default) => throw new HttpRequestException(HttpRequestError.ConnectionError); } diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetrying.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetrying.cs index cdb7f575db..775f64cb6a 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetrying.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetrying.cs @@ -1,5 +1,7 @@ namespace ServiceControl.MultiInstance.AcceptanceTests.Recoverability; +using System.Threading; + using System.Threading.Tasks; using AcceptanceTesting; using MessageFailures; @@ -8,15 +10,15 @@ namespace ServiceControl.MultiInstance.AcceptanceTests.Recoverability; abstract class WhenRetrying : AcceptanceTest { - protected Task> GetFailedMessage(string uniqueMessageId, string instance, FailedMessageStatus expectedStatus) + protected Task> GetFailedMessage(string uniqueMessageId, string instance, FailedMessageStatus expectedStatus, CancellationToken cancellationToken = default) { if (uniqueMessageId == null) { return Task.FromResult(SingleResult.Empty); } - return this.TryGet($"/api/errors/{uniqueMessageId}", f => f.Status == expectedStatus, instance); + return this.TryGet($"/api/errors/{uniqueMessageId}", f => f.Status == expectedStatus, instance, cancellationToken); } - protected Task> GetAllFailedMessage(string instance, FailedMessageStatus expectedStatus) => this.TryGetMany("/api/errors", f => f.Status == expectedStatus, instance); + protected Task> GetAllFailedMessage(string instance, FailedMessageStatus expectedStatus, CancellationToken cancellationToken = default) => this.TryGetMany("/api/errors", f => f.Status == expectedStatus, instance, cancellationToken); } \ No newline at end of file diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetryingSameMessageMultipleTimes.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetryingSameMessageMultipleTimes.cs index 68b100316b..86e9d243fb 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetryingSameMessageMultipleTimes.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetryingSameMessageMultipleTimes.cs @@ -27,7 +27,7 @@ public enum RetryType //[TestCase(new[] { RetryType.NoEdit, RetryType.Edit, RetryType.NoEdit, RetryType.Edit })] [TestCase(new[] { RetryType.Edit, RetryType.Edit, RetryType.NoEdit })] [CancelAfter(30_000)] - public async Task WithMixOfRetryTypes(RetryType[] retryTypes, CancellationToken cancellationToken) + public async Task WithMixOfRetryTypes(RetryType[] retryTypes, CancellationToken cancellationToken = default) { CustomServiceControlPrimarySettings = s => { s.AllowMessageEditing = true; }; diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetryingWithEdit.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetryingWithEdit.cs index c98ab98cf3..74abb83b2e 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetryingWithEdit.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/WhenRetryingWithEdit.cs @@ -17,7 +17,7 @@ class WhenRetryingWithEdit : WhenRetrying { [Test] [CancelAfter(30_000)] - public async Task ShouldCreateNewMessageAndResolveEditedMessage(CancellationToken cancellationToken) + public async Task ShouldCreateNewMessageAndResolveEditedMessage(CancellationToken cancellationToken = default) { CustomServiceControlPrimarySettings = s => { s.AllowMessageEditing = true; }; diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/When_a_message_retry_audit_is_sent_to_audit_instance.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/When_a_message_retry_audit_is_sent_to_audit_instance.cs index d912716f26..67cd947d2e 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/When_a_message_retry_audit_is_sent_to_audit_instance.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/When_a_message_retry_audit_is_sent_to_audit_instance.cs @@ -18,7 +18,7 @@ class When_a_message_retry_audit_is_sent_to_audit_instance : AcceptanceTest { [Test] [CancelAfter(120_000)] - public async Task Should_mark_as_resolved(CancellationToken cancellationToken) + public async Task Should_mark_as_resolved(CancellationToken cancellationToken = default) { FailedMessage failure; diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/When_issuing_retry_by_specifying_instance_id.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/When_issuing_retry_by_specifying_instance_id.cs index 7159ca5348..658810bb4c 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/When_issuing_retry_by_specifying_instance_id.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/Recoverability/When_issuing_retry_by_specifying_instance_id.cs @@ -19,7 +19,7 @@ class When_issuing_retry_by_specifying_instance_id : AcceptanceTest { [Test] [CancelAfter(120_000)] - public async Task Should_be_work(CancellationToken cancellationToken) + public async Task Should_be_work(CancellationToken cancellationToken = default) { string addressOfItself = null; diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/HttpExtensionsMultiinstance.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/HttpExtensionsMultiinstance.cs index d09497c90a..4f0512ed03 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/HttpExtensionsMultiinstance.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/HttpExtensionsMultiinstance.cs @@ -4,6 +4,7 @@ namespace ServiceControl.MultiInstance.AcceptanceTests.TestSupport using System.Net; using System.Net.Http; using System.Text.Json; + using System.Threading; using System.Threading.Tasks; using AcceptanceTesting; using ServiceBus.Management.Infrastructure.Settings; @@ -17,39 +18,39 @@ static IAcceptanceTestInfrastructureProvider ToHttpExtension(this IAcceptanceTes SerializerOptions = providerMultiInstance.SerializerOptions[instanceName], }; - public static Task Put(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, Func requestHasFailed = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class + public static Task Put(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, Func requestHasFailed = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME, CancellationToken cancellationToken = default) where T : class { - return providerMultiInstance.ToHttpExtension(instanceName).Put(url, payload, requestHasFailed); + return providerMultiInstance.ToHttpExtension(instanceName).Put(url, payload, requestHasFailed, cancellationToken); } - public static Task GetRaw(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, string instanceName = Settings.DEFAULT_INSTANCE_NAME) + public static Task GetRaw(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, string instanceName = Settings.DEFAULT_INSTANCE_NAME, CancellationToken cancellationToken = default) { - return providerMultiInstance.ToHttpExtension(instanceName).GetRaw(url); + return providerMultiInstance.ToHttpExtension(instanceName).GetRaw(url, cancellationToken); } - public static Task> TryGetMany(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class + public static Task> TryGetMany(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME, CancellationToken cancellationToken = default) where T : class { - return providerMultiInstance.ToHttpExtension(instanceName).TryGetMany(url, condition); + return providerMultiInstance.ToHttpExtension(instanceName).TryGetMany(url, condition, cancellationToken); } - public static Task Patch(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class + public static Task Patch(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME, CancellationToken cancellationToken = default) where T : class { - return providerMultiInstance.ToHttpExtension(instanceName).Patch(url, payload); + return providerMultiInstance.ToHttpExtension(instanceName).Patch(url, payload, cancellationToken); } - public static Task> TryGet(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class + public static Task> TryGet(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME, CancellationToken cancellationToken = default) where T : class { - return providerMultiInstance.ToHttpExtension(instanceName).TryGet(url, condition); + return providerMultiInstance.ToHttpExtension(instanceName).TryGet(url, condition, cancellationToken); } - public static Task> TryGetSingle(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class + public static Task> TryGetSingle(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME, CancellationToken cancellationToken = default) where T : class { - return providerMultiInstance.ToHttpExtension(instanceName).TryGetSingle(url, condition); + return providerMultiInstance.ToHttpExtension(instanceName).TryGetSingle(url, condition, cancellationToken); } - public static Task Post(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, Func requestHasFailed = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class + public static Task Post(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, Func requestHasFailed = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME, CancellationToken cancellationToken = default) where T : class { - return providerMultiInstance.ToHttpExtension(instanceName).Post(url, payload, requestHasFailed); + return providerMultiInstance.ToHttpExtension(instanceName).Post(url, payload, requestHasFailed, cancellationToken); } } diff --git a/src/ServiceControl.Persistence.Tests.InMemory/.editorconfig b/src/ServiceControl.Persistence.Tests.InMemory/.editorconfig index 0a6ae3dffe..9bc5edd414 100644 --- a/src/ServiceControl.Persistence.Tests.InMemory/.editorconfig +++ b/src/ServiceControl.Persistence.Tests.InMemory/.editorconfig @@ -3,7 +3,7 @@ # Justification: Test project dotnet_diagnostic.CA2007.severity = none -# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. -# They are scheduled work, not accepted exceptions: remove a line once this project has no +# Cancellation analyzer debt. PS0018 here is the test helper chain, not [Test] methods +# (Particular.Analyzers already exempts those). Remove a line once this project has no # violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0018.severity = none +dotnet_diagnostic.PS0018.severity = none \ No newline at end of file diff --git a/src/ServiceControl.Persistence.Tests.PostgreSql/.editorconfig b/src/ServiceControl.Persistence.Tests.PostgreSql/.editorconfig index e88159f88e..82926b9419 100644 --- a/src/ServiceControl.Persistence.Tests.PostgreSql/.editorconfig +++ b/src/ServiceControl.Persistence.Tests.PostgreSql/.editorconfig @@ -3,11 +3,8 @@ # Justification: ServiceControl app has no synchronization context dotnet_diagnostic.CA2007.severity = none -# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. -# They are scheduled work, not accepted exceptions: remove a line once this project has no +# Cancellation analyzer debt. PS0018 here is the test helper chain, not [Test] methods +# (Particular.Analyzers already exempts those). Remove a line once this project has no # violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0008.severity = none -dotnet_diagnostic.PS0017.severity = none dotnet_diagnostic.PS0018.severity = none -dotnet_diagnostic.PS0019.severity = none diff --git a/src/ServiceControl.Persistence.Tests.PostgreSql/PostgreSqlSharedContainer.cs b/src/ServiceControl.Persistence.Tests.PostgreSql/PostgreSqlSharedContainer.cs index 8b4a659a1c..441c05a9e5 100644 --- a/src/ServiceControl.Persistence.Tests.PostgreSql/PostgreSqlSharedContainer.cs +++ b/src/ServiceControl.Persistence.Tests.PostgreSql/PostgreSqlSharedContainer.cs @@ -9,7 +9,7 @@ static class PostgreSqlSharedContainer { const string docsPath = "docs/testing-persistence.md#postgresql"; - public static async Task GetConnectionStringAsync(CancellationToken ct = default) + public static async Task GetConnectionStringAsync(CancellationToken cancellationToken = default) { var envConnStr = Environment.GetEnvironmentVariable("ServiceControl_Persistence_PostgreSql_ConnectionString"); if (!string.IsNullOrEmpty(envConnStr)) @@ -22,10 +22,10 @@ public static async Task GetConnectionStringAsync(CancellationToken ct = return container.GetConnectionString(); } - await semaphore.WaitAsync(ct); + await semaphore.WaitAsync(cancellationToken); try { - container ??= await StartContainerAsync(ct); + container ??= await StartContainerAsync(cancellationToken); return container.GetConnectionString(); } finally @@ -34,15 +34,19 @@ public static async Task GetConnectionStringAsync(CancellationToken ct = } } - public static async Task Stop() => await (container?.DisposeAsync() ?? ValueTask.CompletedTask); + public static async Task Stop(CancellationToken cancellationToken = default) => await (container?.DisposeAsync() ?? ValueTask.CompletedTask); - static async Task StartContainerAsync(CancellationToken ct) + static async Task StartContainerAsync(CancellationToken cancellationToken) { var c = new PostgreSqlBuilder("postgres:16-alpine") .Build(); try { - await c.StartAsync(ct); + await c.StartAsync(cancellationToken); + } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + throw; } catch (Exception ex) { diff --git a/src/ServiceControl.Persistence.Tests.RavenDB/.editorconfig b/src/ServiceControl.Persistence.Tests.RavenDB/.editorconfig index 0a6ae3dffe..9bc5edd414 100644 --- a/src/ServiceControl.Persistence.Tests.RavenDB/.editorconfig +++ b/src/ServiceControl.Persistence.Tests.RavenDB/.editorconfig @@ -3,7 +3,7 @@ # Justification: Test project dotnet_diagnostic.CA2007.severity = none -# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. -# They are scheduled work, not accepted exceptions: remove a line once this project has no +# Cancellation analyzer debt. PS0018 here is the test helper chain, not [Test] methods +# (Particular.Analyzers already exempts those). Remove a line once this project has no # violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0018.severity = none +dotnet_diagnostic.PS0018.severity = none \ No newline at end of file diff --git a/src/ServiceControl.Persistence.Tests.SqlServer/.editorconfig b/src/ServiceControl.Persistence.Tests.SqlServer/.editorconfig index e88159f88e..82926b9419 100644 --- a/src/ServiceControl.Persistence.Tests.SqlServer/.editorconfig +++ b/src/ServiceControl.Persistence.Tests.SqlServer/.editorconfig @@ -3,11 +3,8 @@ # Justification: ServiceControl app has no synchronization context dotnet_diagnostic.CA2007.severity = none -# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. -# They are scheduled work, not accepted exceptions: remove a line once this project has no +# Cancellation analyzer debt. PS0018 here is the test helper chain, not [Test] methods +# (Particular.Analyzers already exempts those). Remove a line once this project has no # violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0008.severity = none -dotnet_diagnostic.PS0017.severity = none dotnet_diagnostic.PS0018.severity = none -dotnet_diagnostic.PS0019.severity = none diff --git a/src/ServiceControl.Persistence.Tests.SqlServer/SqlServerSharedContainer.cs b/src/ServiceControl.Persistence.Tests.SqlServer/SqlServerSharedContainer.cs index 9494914c8f..aefc4ff667 100644 --- a/src/ServiceControl.Persistence.Tests.SqlServer/SqlServerSharedContainer.cs +++ b/src/ServiceControl.Persistence.Tests.SqlServer/SqlServerSharedContainer.cs @@ -10,7 +10,7 @@ static class SqlServerSharedContainer { const string docsPath = "docs/testing-persistence.md#sql-server"; - public static async Task GetConnectionStringAsync(CancellationToken ct = default) + public static async Task GetConnectionStringAsync(CancellationToken cancellationToken = default) { var envConnStr = Environment.GetEnvironmentVariable("ServiceControl_Persistence_SqlServer_ConnectionString"); if (!string.IsNullOrEmpty(envConnStr)) @@ -23,10 +23,10 @@ public static async Task GetConnectionStringAsync(CancellationToken ct = return container.GetConnectionString(); } - await semaphore.WaitAsync(ct); + await semaphore.WaitAsync(cancellationToken); try { - container ??= await StartContainerAsync(ct); + container ??= await StartContainerAsync(cancellationToken); return container.GetConnectionString(); } finally @@ -35,14 +35,18 @@ public static async Task GetConnectionStringAsync(CancellationToken ct = } } - public static async Task Stop() => await (container?.DisposeAsync() ?? ValueTask.CompletedTask); + public static async Task Stop(CancellationToken cancellationToken = default) => await (container?.DisposeAsync() ?? ValueTask.CompletedTask); - static async Task StartContainerAsync(CancellationToken ct) + static async Task StartContainerAsync(CancellationToken cancellationToken) { var c = new MsSqlBuilder("particular/servicecontrol-testing-sqlserver:latest").Build(); try { - await c.StartAsync(ct); + await c.StartAsync(cancellationToken); + } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + throw; } catch (Exception ex) { diff --git a/src/ServiceControl.Persistence.Tests/.editorconfig b/src/ServiceControl.Persistence.Tests/.editorconfig index b26fbddcce..fdb6174a57 100644 --- a/src/ServiceControl.Persistence.Tests/.editorconfig +++ b/src/ServiceControl.Persistence.Tests/.editorconfig @@ -3,12 +3,10 @@ # Justification: Test project dotnet_diagnostic.CA2007.severity = none -# Justification: Test project. Demanding a CancellationToken on every [Test] method, and on the -# helpers they call, buys nothing: a test that hangs fails the run either way, and [CancelAfter] -# only bites once the code under test honours the token. Persistence integration tests that need a -# real timeout use [Test, CancelAfter(...)] with an injected token instead, which is the pattern to -# follow for new tests. These are accepted exceptions, not scheduled work. -dotnet_diagnostic.PS0003.severity = none # A parameter of type CancellationToken on a non-private delegate or method should be optional -dotnet_diagnostic.PS0006.severity = none # Pass CancellationToken.None instead of the default literal -dotnet_diagnostic.PS0013.severity = none # A Func used as a method parameter with a Task return type argument should have a CancellationToken type argument -dotnet_diagnostic.PS0018.severity = none # A task-returning method should have a CancellationToken parameter +# Cancellation analyzer debt, still scheduled work rather than accepted exceptions. Measured +# Aug 2026: PS0018 here is NOT about [Test] methods (Particular.Analyzers already exempts those), +# it is the protected/private test helpers those tests call. Converting them means threading a +# token through the helper chain and the Func<...> callback shapes, which is why it is not done +# yet. Remove a line once this project has no violations of that rule left. +dotnet_diagnostic.PS0013.severity = none +dotnet_diagnostic.PS0018.severity = none diff --git a/src/ServiceControl.Persistence.Tests/EFCore/EFCoreExtensionMethodTests.cs b/src/ServiceControl.Persistence.Tests/EFCore/EFCoreExtensionMethodTests.cs index 034ee9e51d..a6ea928931 100644 --- a/src/ServiceControl.Persistence.Tests/EFCore/EFCoreExtensionMethodTests.cs +++ b/src/ServiceControl.Persistence.Tests/EFCore/EFCoreExtensionMethodTests.cs @@ -13,7 +13,7 @@ namespace ServiceControl.Persistence.Tests; public class EFCoreExtensionMethodTests : PersistenceTestBase { [Test, CancelAfter(60_000)] - public async Task Insert_until_conflict_should_not_throw_errors(CancellationToken cancellationToken) + public async Task Insert_until_conflict_should_not_throw_errors(CancellationToken cancellationToken = default) { var i = 0; while (!cancellationToken.IsCancellationRequested) diff --git a/src/ServiceControl.Persistence.Tests/EFCore/LicensingDataStoreEFTests.cs b/src/ServiceControl.Persistence.Tests/EFCore/LicensingDataStoreEFTests.cs index fb266503a1..df7d63bc5c 100644 --- a/src/ServiceControl.Persistence.Tests/EFCore/LicensingDataStoreEFTests.cs +++ b/src/ServiceControl.Persistence.Tests/EFCore/LicensingDataStoreEFTests.cs @@ -2,6 +2,7 @@ namespace ServiceControl.Persistence.Tests; using System; using System.Linq; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Particular.LicensingComponent.Contracts; @@ -15,8 +16,8 @@ public async Task Recording_the_same_day_twice_adds_to_that_day() { await SaveEndpoint("Endpoint", ThroughputSource.Monitoring); - await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Monitoring, Today, 30, default); - await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Monitoring, Today, 12, default); + await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Monitoring, Today, 30); + await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Monitoring, Today, 12); var throughput = await GetThroughput("Endpoint"); @@ -32,7 +33,7 @@ public async Task Concurrent_recordings_of_the_same_day_all_count() await SaveEndpoint("Endpoint", ThroughputSource.Monitoring); var recordings = Enumerable.Range(0, writers) - .Select(_ => LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Monitoring, Today, 5, default)); + .Select(_ => LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Monitoring, Today, 5)); await Task.WhenAll(recordings); @@ -46,9 +47,9 @@ public async Task Endpoints_are_matched_regardless_of_name_casing() { await SaveEndpoint("SalesEndpoint", ThroughputSource.Broker); - await LicensingDataStore.RecordEndpointThroughput("salesendpoint", ThroughputSource.Broker, Today, 7, default); + await LicensingDataStore.RecordEndpointThroughput("salesendpoint", ThroughputSource.Broker, Today, 7); - var endpoint = await LicensingDataStore.GetEndpoint("SALESENDPOINT", ThroughputSource.Broker, default); + var endpoint = await LicensingDataStore.GetEndpoint("SALESENDPOINT", ThroughputSource.Broker); Assert.That(endpoint, Is.Not.Null); using (Assert.EnterMultipleScope()) @@ -63,11 +64,11 @@ public async Task Last_collected_date_is_the_newest_recorded_day() { await SaveEndpoint("Endpoint", ThroughputSource.Audit); - await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Audit, Today.AddDays(-5), 10, default); - await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Audit, Today.AddDays(-1), 10, default); - await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Audit, Today.AddDays(-3), 10, default); + await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Audit, Today.AddDays(-5), 10); + await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Audit, Today.AddDays(-1), 10); + await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Audit, Today.AddDays(-3), 10); - var endpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit, default); + var endpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit); Assert.That(endpoint, Is.Not.Null); Assert.That(endpoint.LastCollectedDate, Is.EqualTo(Today.AddDays(-1))); @@ -78,7 +79,7 @@ public async Task Last_collected_date_is_unset_when_nothing_was_recorded() { await SaveEndpoint("Endpoint", ThroughputSource.Audit); - var endpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit, default); + var endpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit); Assert.That(endpoint, Is.Not.Null); Assert.That(endpoint.LastCollectedDate, Is.EqualTo(default(DateOnly))); @@ -98,7 +99,7 @@ public async Task Endpoints_are_returned_for_every_requested_id_including_the_un new EndpointIdentifier("Unknown", ThroughputSource.Audit) }; - var results = (await LicensingDataStore.GetEndpoints(requested, default)).ToList(); + var results = (await LicensingDataStore.GetEndpoints(requested)).ToList(); using (Assert.EnterMultipleScope()) { @@ -118,11 +119,11 @@ await LicensingDataStore.SaveEndpoint( { SanitizedName = "Platform", EndpointIndicators = [EndpointIndicator.PlatformEndpoint.ToString()] - }, default); + }); await SaveEndpoint("Regular", ThroughputSource.Broker); - var withPlatform = await LicensingDataStore.GetAllEndpoints(true, default); - var withoutPlatform = await LicensingDataStore.GetAllEndpoints(false, default); + var withPlatform = await LicensingDataStore.GetAllEndpoints(true); + var withoutPlatform = await LicensingDataStore.GetAllEndpoints(false); using (Assert.EnterMultipleScope()) { @@ -143,9 +144,9 @@ await LicensingDataStore.SaveEndpoint( EndpointIndicators = indicators, Scope = "vhost", UserIndicator = UserIndicator.NServiceBusEndpoint.ToString() - }, default); + }); - var endpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Broker, default); + var endpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Broker); Assert.That(endpoint, Is.Not.Null); using (Assert.EnterMultipleScope()) @@ -163,8 +164,8 @@ public async Task Throughput_older_than_the_reported_window_is_not_returned() { await SaveEndpoint("Endpoint", ThroughputSource.Broker); - await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Broker, Today.AddMonths(-15), 99, default); - await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Broker, Today.AddDays(-1), 5, default); + await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Broker, Today.AddMonths(-15), 99); + await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Broker, Today.AddDays(-1), 5); var throughput = await GetThroughput("Endpoint"); @@ -178,7 +179,7 @@ public async Task Throughput_older_than_the_reported_window_is_not_returned() [Test] public async Task Recording_throughput_for_an_unknown_endpoint_throws() { - Assert.That(async () => await LicensingDataStore.RecordEndpointThroughput("Unknown", ThroughputSource.Broker, Today, 1, default), + Assert.That(async () => await LicensingDataStore.RecordEndpointThroughput("Unknown", ThroughputSource.Broker, Today, 1), Throws.InstanceOf()); } @@ -186,12 +187,12 @@ public async Task Recording_throughput_for_an_unknown_endpoint_throws() public async Task Saving_an_endpoint_again_replaces_it_and_keeps_its_throughput() { await SaveEndpoint("Endpoint", ThroughputSource.Broker); - await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Broker, Today, 11, default); + await LicensingDataStore.RecordEndpointThroughput("Endpoint", ThroughputSource.Broker, Today, 11); await LicensingDataStore.SaveEndpoint( - new Endpoint("Endpoint", ThroughputSource.Broker) { SanitizedName = "Endpoint", Scope = "updated" }, default); + new Endpoint("Endpoint", ThroughputSource.Broker) { SanitizedName = "Endpoint", Scope = "updated" }); - var endpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Broker, default); + var endpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Broker); var throughput = await GetThroughput("Endpoint"); Assert.That(endpoint, Is.Not.Null); @@ -203,11 +204,11 @@ await LicensingDataStore.SaveEndpoint( } Task SaveEndpoint(string name, ThroughputSource source) => - LicensingDataStore.SaveEndpoint(new Endpoint(name, source) { SanitizedName = name }, default); + LicensingDataStore.SaveEndpoint(new Endpoint(name, source) { SanitizedName = name }); async Task GetThroughput(string queueName) { - var throughput = await LicensingDataStore.GetEndpointThroughputByQueueName([queueName], default); + var throughput = await LicensingDataStore.GetEndpointThroughputByQueueName([queueName]); return throughput[queueName].Single(); } diff --git a/src/ServiceControl.Persistence.Tests/EndpointSettingsStoreTests.cs b/src/ServiceControl.Persistence.Tests/EndpointSettingsStoreTests.cs index 8795db2217..2ecaa01c04 100644 --- a/src/ServiceControl.Persistence.Tests/EndpointSettingsStoreTests.cs +++ b/src/ServiceControl.Persistence.Tests/EndpointSettingsStoreTests.cs @@ -10,7 +10,7 @@ namespace ServiceControl.Persistence.Tests; class EndpointSettingsStoreTests : PersistenceTestBase { [Test, CancelAfter(30_000)] - public async Task UpdateEndpointSettings_stores_and_updates_existing_setting(CancellationToken cancellationToken) + public async Task UpdateEndpointSettings_stores_and_updates_existing_setting(CancellationToken cancellationToken = default) { await EndpointSettingsStore.UpdateEndpointSettings(new EndpointSettings { Name = "Sales", TrackInstances = false }, cancellationToken); await EndpointSettingsStore.UpdateEndpointSettings(new EndpointSettings { Name = "Sales", TrackInstances = true }, cancellationToken); @@ -26,7 +26,7 @@ public async Task UpdateEndpointSettings_stores_and_updates_existing_setting(Can } [Test, CancelAfter(30_000)] - public async Task Delete_removes_only_target_setting(CancellationToken cancellationToken) + public async Task Delete_removes_only_target_setting(CancellationToken cancellationToken = default) { await EndpointSettingsStore.UpdateEndpointSettings(new EndpointSettings { Name = "Sales", TrackInstances = false }, cancellationToken); await EndpointSettingsStore.UpdateEndpointSettings(new EndpointSettings { Name = "Shipping", TrackInstances = true }, cancellationToken); diff --git a/src/ServiceControl.Persistence.Tests/FakeDomainEvents.cs b/src/ServiceControl.Persistence.Tests/FakeDomainEvents.cs index 0718354ab6..e69e907b0a 100644 --- a/src/ServiceControl.Persistence.Tests/FakeDomainEvents.cs +++ b/src/ServiceControl.Persistence.Tests/FakeDomainEvents.cs @@ -13,7 +13,7 @@ class FakeDomainEvents : IDomainEvents { public List RaisedEvents { get; } = []; - public Task Raise(T domainEvent, CancellationToken cancellationToken) where T : IDomainEvent + public Task Raise(T domainEvent, CancellationToken cancellationToken = default) where T : IDomainEvent { RaisedEvents.Add(domainEvent); TestContext.Out.WriteLine($"Raised DomainEvent {typeof(T).Name}:"); diff --git a/src/ServiceControl.Persistence.Tests/Recoverability/EditMessageTests.cs b/src/ServiceControl.Persistence.Tests/Recoverability/EditMessageTests.cs index 1e6a979032..afcb089bb4 100644 --- a/src/ServiceControl.Persistence.Tests/Recoverability/EditMessageTests.cs +++ b/src/ServiceControl.Persistence.Tests/Recoverability/EditMessageTests.cs @@ -269,7 +269,7 @@ public sealed class TestableUnicastDispatcher : IMessageDispatcher public Exception ThrowOnDispatch { get; set; } - public Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, CancellationToken cancellationToken) + public Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, CancellationToken cancellationToken = default) { if (ThrowOnDispatch != null) { diff --git a/src/ServiceControl.Persistence.Tests/Recoverability/ReturnToSenderDequeuerTests.cs b/src/ServiceControl.Persistence.Tests/Recoverability/ReturnToSenderDequeuerTests.cs index bc366dfcb4..c73e7bbeba 100644 --- a/src/ServiceControl.Persistence.Tests/Recoverability/ReturnToSenderDequeuerTests.cs +++ b/src/ServiceControl.Persistence.Tests/Recoverability/ReturnToSenderDequeuerTests.cs @@ -184,7 +184,7 @@ public async Task It_restores_body_id_and_target_addres_after_failure() class FaultySender : IMessageDispatcher { - public Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, CancellationToken cancellationToken) + public Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, CancellationToken cancellationToken = default) { throw new Exception("Simulated"); } @@ -196,7 +196,7 @@ class FakeSender : IMessageDispatcher public string Destination { get; private set; } - public Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, CancellationToken cancellationToken) + public Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, CancellationToken cancellationToken = default) { var operation = outgoingMessages.UnicastTransportOperations.Single(); Message = operation.Message; diff --git a/src/ServiceControl.Persistence.Tests/RetryStateTests.cs b/src/ServiceControl.Persistence.Tests/RetryStateTests.cs index 5cdac0108c..56df79608c 100644 --- a/src/ServiceControl.Persistence.Tests/RetryStateTests.cs +++ b/src/ServiceControl.Persistence.Tests/RetryStateTests.cs @@ -515,7 +515,7 @@ public class TestSender : IMessageDispatcher { public Action Callback { get; set; } = m => { }; - public Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, CancellationToken cancellationToken) + public Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, CancellationToken cancellationToken = default) { foreach (var operation in outgoingMessages.UnicastTransportOperations) { diff --git a/src/ServiceControl.Persistence.Tests/Throughput/AuditServiceMetadataTests.cs b/src/ServiceControl.Persistence.Tests/Throughput/AuditServiceMetadataTests.cs index 50a8830326..5707e68d53 100644 --- a/src/ServiceControl.Persistence.Tests/Throughput/AuditServiceMetadataTests.cs +++ b/src/ServiceControl.Persistence.Tests/Throughput/AuditServiceMetadataTests.cs @@ -1,6 +1,7 @@ namespace ServiceControl.Persistence.Tests.Throughput; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Particular.LicensingComponent.Contracts; @@ -15,7 +16,7 @@ public async Task Should_retrieve_saved_audit_service_metadata() var expectedAuditServiceMetadata = new AuditServiceMetadata( new Dictionary { ["Some version"] = 2 }, new Dictionary { ["Some transport"] = 3 }); - await LicensingDataStore.SaveAuditServiceMetadata(expectedAuditServiceMetadata, default); + await LicensingDataStore.SaveAuditServiceMetadata(expectedAuditServiceMetadata); //Act var retrievedAuditServiceMetadata = await LicensingDataStore.GetAuditServiceMetadata(); @@ -36,13 +37,13 @@ public async Task Should_update_existing_audit_service_metadata_if_already_exist var oldAuditServiceMetadata = new AuditServiceMetadata( new Dictionary { ["Some version"] = 2 }, new Dictionary { ["Some transport"] = 3 }); - await LicensingDataStore.SaveAuditServiceMetadata(oldAuditServiceMetadata, default); + await LicensingDataStore.SaveAuditServiceMetadata(oldAuditServiceMetadata); // Act var expectedAuditServiceMetadata = new AuditServiceMetadata( new Dictionary { ["Some version"] = 2, ["New version"] = 1 }, new Dictionary { ["Some transport"] = 4 }); - await LicensingDataStore.SaveAuditServiceMetadata(expectedAuditServiceMetadata, default); + await LicensingDataStore.SaveAuditServiceMetadata(expectedAuditServiceMetadata); var retrievedAuditServiceMetadata = await LicensingDataStore.GetAuditServiceMetadata(); // Assert diff --git a/src/ServiceControl.Persistence.Tests/Throughput/BrokerMetadataTests.cs b/src/ServiceControl.Persistence.Tests/Throughput/BrokerMetadataTests.cs index 90b957a751..e2653207a7 100644 --- a/src/ServiceControl.Persistence.Tests/Throughput/BrokerMetadataTests.cs +++ b/src/ServiceControl.Persistence.Tests/Throughput/BrokerMetadataTests.cs @@ -1,6 +1,7 @@ namespace ServiceControl.Persistence.Tests.Throughput; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Particular.LicensingComponent.Contracts; @@ -13,10 +14,10 @@ public async Task Should_retrieve_saved_broker_metadata() { //Arrange var expectedBrokerMetadata = new BrokerMetadata("Some scope", new Dictionary { ["Some key"] = "Some value" }); - await LicensingDataStore.SaveBrokerMetadata(expectedBrokerMetadata, default); + await LicensingDataStore.SaveBrokerMetadata(expectedBrokerMetadata); //Act - var retrievedBrokerMetadata = await LicensingDataStore.GetBrokerMetadata(default); + var retrievedBrokerMetadata = await LicensingDataStore.GetBrokerMetadata(); //Assert Assert.That(retrievedBrokerMetadata, Is.Not.Null); @@ -32,12 +33,12 @@ public async Task Should_update_existing_broker_metadata_if_already_exists() { // Arrange var oldBrokerMetadata = new BrokerMetadata("Some scope", new Dictionary { ["Some key"] = "Some value" }); - await LicensingDataStore.SaveBrokerMetadata(oldBrokerMetadata, default); + await LicensingDataStore.SaveBrokerMetadata(oldBrokerMetadata); // Act var expectedBrokerMetadata = new BrokerMetadata("New scope", new Dictionary { ["New key"] = "New value" }); - await LicensingDataStore.SaveBrokerMetadata(expectedBrokerMetadata, default); - var retrievedBrokerMetadata = await LicensingDataStore.GetBrokerMetadata(default); + await LicensingDataStore.SaveBrokerMetadata(expectedBrokerMetadata); + var retrievedBrokerMetadata = await LicensingDataStore.GetBrokerMetadata(); // Assert Assert.That(retrievedBrokerMetadata, Is.Not.Null); diff --git a/src/ServiceControl.Persistence.Tests/Throughput/EndpointsTests.cs b/src/ServiceControl.Persistence.Tests/Throughput/EndpointsTests.cs index 897a80a25d..9d258ce21d 100644 --- a/src/ServiceControl.Persistence.Tests/Throughput/EndpointsTests.cs +++ b/src/ServiceControl.Persistence.Tests/Throughput/EndpointsTests.cs @@ -2,6 +2,7 @@ using System; using System.Linq; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using Particular.LicensingComponent.Contracts; @@ -16,10 +17,10 @@ public async Task Should_add_new_endpoint_when_no_endpoints() var endpoint = new Endpoint("Endpoint", ThroughputSource.Audit); // Act - await LicensingDataStore.SaveEndpoint(endpoint, default); + await LicensingDataStore.SaveEndpoint(endpoint); // Assert - var endpoints = await LicensingDataStore.GetAllEndpoints(true, default); + var endpoints = await LicensingDataStore.GetAllEndpoints(true); var foundEndpoint = endpoints.Single(); using (Assert.EnterMultipleScope()) @@ -37,11 +38,11 @@ public async Task Should_add_new_endpoint_when_name_is_the_same_but_source_diffe var endpoint2 = new Endpoint("Endpoint1", ThroughputSource.Broker); // Act - await LicensingDataStore.SaveEndpoint(endpoint1, default); - await LicensingDataStore.SaveEndpoint(endpoint2, default); + await LicensingDataStore.SaveEndpoint(endpoint1); + await LicensingDataStore.SaveEndpoint(endpoint2); // Assert - var endpoints = await LicensingDataStore.GetAllEndpoints(true, default); + var endpoints = await LicensingDataStore.GetAllEndpoints(true); Assert.That(endpoints.Count(), Is.EqualTo(2)); } @@ -51,15 +52,15 @@ public async Task Should_update_endpoint_that_already_has_throughput_with_new_th { // Arrange var endpoint1 = new Endpoint("Endpoint1", ThroughputSource.Audit) { SanitizedName = "Endpoint1" }; - await LicensingDataStore.SaveEndpoint(endpoint1, default); - await LicensingDataStore.RecordEndpointThroughput(endpoint1.Id.Name, ThroughputSource.Audit, DateOnly.FromDateTime(DateTime.UtcNow).AddDays(-1), 50, default); + await LicensingDataStore.SaveEndpoint(endpoint1); + await LicensingDataStore.RecordEndpointThroughput(endpoint1.Id.Name, ThroughputSource.Audit, DateOnly.FromDateTime(DateTime.UtcNow).AddDays(-1), 50); // Act - await LicensingDataStore.RecordEndpointThroughput(endpoint1.Id.Name, ThroughputSource.Audit, DateOnly.FromDateTime(DateTime.UtcNow), 100, default); + await LicensingDataStore.RecordEndpointThroughput(endpoint1.Id.Name, ThroughputSource.Audit, DateOnly.FromDateTime(DateTime.UtcNow), 100); // Assert - var endpoints = await LicensingDataStore.GetAllEndpoints(true, default); - var throughput = await LicensingDataStore.GetEndpointThroughputByQueueName([endpoint1.SanitizedName], default); + var endpoints = await LicensingDataStore.GetAllEndpoints(true); + var throughput = await LicensingDataStore.GetEndpointThroughputByQueueName([endpoint1.SanitizedName]); var foundEndpoint = endpoints.Single(); using (Assert.EnterMultipleScope()) @@ -83,10 +84,10 @@ public async Task Should_retrieve_matching_endpoint_when_same_source() { // Arrange var endpoint = new Endpoint("Endpoint", ThroughputSource.Audit); - await LicensingDataStore.SaveEndpoint(endpoint, default); + await LicensingDataStore.SaveEndpoint(endpoint); // Act - var foundEndpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit, default); + var foundEndpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit); // Assert Assert.That(foundEndpoint, Is.Not.Null); @@ -97,10 +98,10 @@ public async Task Should_not_retrieve_matching_endpoint_when_different_source() { // Arrange var endpoint = new Endpoint("Endpoint", ThroughputSource.Audit); - await LicensingDataStore.SaveEndpoint(endpoint, default); + await LicensingDataStore.SaveEndpoint(endpoint); // Act - var foundEndpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Broker, default); + var foundEndpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Broker); // Assert Assert.That(foundEndpoint, Is.Null); @@ -116,13 +117,13 @@ public async Task Should_update_user_indicators_and_nothing_else() { SanitizedName = "Endpoint" }; - await LicensingDataStore.SaveEndpoint(endpoint, default); + await LicensingDataStore.SaveEndpoint(endpoint); // Act - await LicensingDataStore.UpdateUserIndicatorOnEndpoints([new UpdateUserIndicator { Name = "Endpoint", UserIndicator = userIndicator }], default); + await LicensingDataStore.UpdateUserIndicatorOnEndpoints([new UpdateUserIndicator { Name = "Endpoint", UserIndicator = userIndicator }]); // Assert - var foundEndpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit, default); + var foundEndpoint = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit); Assert.That(foundEndpoint, Is.Not.Null); Assert.That(foundEndpoint.UserIndicator, Is.EqualTo(userIndicator)); @@ -139,10 +140,10 @@ public async Task Should_not_add_endpoint_when_updating_user_indication() }; // Act - await LicensingDataStore.UpdateUserIndicatorOnEndpoints([userIndicatorUpate], default); + await LicensingDataStore.UpdateUserIndicatorOnEndpoints([userIndicatorUpate]); // Assert - var allEndpoints = await LicensingDataStore.GetAllEndpoints(true, default); + var allEndpoints = await LicensingDataStore.GetAllEndpoints(true); Assert.That(allEndpoints.Count, Is.EqualTo(0)); } @@ -156,15 +157,15 @@ public async Task Should_update_indicators_on_all_endpoint_sources_when_updated_ var endpointAudit = new Endpoint("Endpoint", ThroughputSource.Audit) { SanitizedName = "Endpoint" }; var endpointMonitoring = new Endpoint("Endpoint", ThroughputSource.Monitoring) { SanitizedName = "Endpoint" }; - await LicensingDataStore.SaveEndpoint(endpointAudit, default); - await LicensingDataStore.SaveEndpoint(endpointMonitoring, default); + await LicensingDataStore.SaveEndpoint(endpointAudit); + await LicensingDataStore.SaveEndpoint(endpointMonitoring); // Act - await LicensingDataStore.UpdateUserIndicatorOnEndpoints([new UpdateUserIndicator { Name = "Endpoint", UserIndicator = userIndicator }], default); + await LicensingDataStore.UpdateUserIndicatorOnEndpoints([new UpdateUserIndicator { Name = "Endpoint", UserIndicator = userIndicator }]); // Assert - var foundEndpointAudit = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit, default); - var foundEndpointMonitoring = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Monitoring, default); + var foundEndpointAudit = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Audit); + var foundEndpointMonitoring = await LicensingDataStore.GetEndpoint("Endpoint", ThroughputSource.Monitoring); Assert.That(foundEndpointAudit, Is.Not.Null); Assert.That(foundEndpointAudit.UserIndicator, Is.EqualTo(userIndicator)); @@ -182,15 +183,15 @@ public async Task Should_update_indicators_on_all_endpoint_sources_when_updated_ var endpointAudit = new Endpoint("Endpoint1", ThroughputSource.Audit) { SanitizedName = "Endpoint1" }; var endpointMonitoring = new Endpoint("\"public\".\"Endpoint1\"", ThroughputSource.Monitoring) { SanitizedName = "Endpoint1" }; - await LicensingDataStore.SaveEndpoint(endpointAudit, default); - await LicensingDataStore.SaveEndpoint(endpointMonitoring, default); + await LicensingDataStore.SaveEndpoint(endpointAudit); + await LicensingDataStore.SaveEndpoint(endpointMonitoring); // Act - await LicensingDataStore.UpdateUserIndicatorOnEndpoints([new UpdateUserIndicator { Name = "\"public\".\"Endpoint1\"", UserIndicator = userIndicator }], default); + await LicensingDataStore.UpdateUserIndicatorOnEndpoints([new UpdateUserIndicator { Name = "\"public\".\"Endpoint1\"", UserIndicator = userIndicator }]); // Assert - var foundEndpointAudit = await LicensingDataStore.GetEndpoint("Endpoint1", ThroughputSource.Audit, default); - var foundEndpointMonitoring = await LicensingDataStore.GetEndpoint("\"public\".\"Endpoint1\"", ThroughputSource.Monitoring, default); + var foundEndpointAudit = await LicensingDataStore.GetEndpoint("Endpoint1", ThroughputSource.Audit); + var foundEndpointMonitoring = await LicensingDataStore.GetEndpoint("\"public\".\"Endpoint1\"", ThroughputSource.Monitoring); Assert.That(foundEndpointAudit, Is.Not.Null); Assert.That(foundEndpointAudit.UserIndicator, Is.EqualTo(userIndicator)); @@ -213,8 +214,8 @@ public async Task Should_update_user_indicators_on_more_than_30_endpoints_withou for (var i = 0; i < endpointCount; i++) { var sanitizedName = $"Endpoint{i}"; - await LicensingDataStore.SaveEndpoint(new Endpoint(sanitizedName, ThroughputSource.Audit) { SanitizedName = sanitizedName }, default); - await LicensingDataStore.SaveEndpoint(new Endpoint($"schema.{sanitizedName}", ThroughputSource.Monitoring) { SanitizedName = sanitizedName }, default); + await LicensingDataStore.SaveEndpoint(new Endpoint(sanitizedName, ThroughputSource.Audit) { SanitizedName = sanitizedName }); + await LicensingDataStore.SaveEndpoint(new Endpoint($"schema.{sanitizedName}", ThroughputSource.Monitoring) { SanitizedName = sanitizedName }); } var updates = Enumerable.Range(0, endpointCount) @@ -222,10 +223,10 @@ public async Task Should_update_user_indicators_on_more_than_30_endpoints_withou .ToList(); // Act - must not throw InvalidOperationException due to exceeding session request limit - await LicensingDataStore.UpdateUserIndicatorOnEndpoints(updates, default); + await LicensingDataStore.UpdateUserIndicatorOnEndpoints(updates); // Assert - var allEndpoints = (await LicensingDataStore.GetAllEndpoints(true, default)).ToList(); + var allEndpoints = (await LicensingDataStore.GetAllEndpoints(true)).ToList(); Assert.That(allEndpoints, Has.Count.EqualTo(endpointCount * 2)); Assert.That(allEndpoints, Has.All.Matches(e => e.UserIndicator == userIndicator)); @@ -237,16 +238,15 @@ public async Task Should_correctly_report_throughput_existence_for_X_days(int da { // Arrange var endpointAudit = new Endpoint("Endpoint", ThroughputSource.Audit); - await LicensingDataStore.SaveEndpoint(endpointAudit, default); + await LicensingDataStore.SaveEndpoint(endpointAudit); await LicensingDataStore.RecordEndpointThroughput( endpointAudit.Id.Name, ThroughputSource.Audit, DateOnly.FromDateTime(DateTime.UtcNow).AddDays(-daysSinceLastThroughputEntry), - 50, - default); + 50); - Assert.That(await LicensingDataStore.IsThereThroughputForLastXDays(timeFrameToCheck, default), expectedValue ? Is.True : Is.False); + Assert.That(await LicensingDataStore.IsThereThroughputForLastXDays(timeFrameToCheck), expectedValue ? Is.True : Is.False); } [TestCase(10, 5, ThroughputSource.Monitoring, ThroughputSource.Monitoring, false, false)] @@ -258,15 +258,14 @@ public async Task Should_correctly_report_throughput_existence_for_X_days_for_sp { // Arrange var endpointAudit = new Endpoint("Endpoint", throughputSourceToRecord); - await LicensingDataStore.SaveEndpoint(endpointAudit, default); + await LicensingDataStore.SaveEndpoint(endpointAudit); await LicensingDataStore.RecordEndpointThroughput( endpointAudit.Id.Name, throughputSourceToRecord, DateOnly.FromDateTime(DateTime.UtcNow).AddDays(-daysSinceLastThroughputEntry), - 50, - default); + 50); - Assert.That(await LicensingDataStore.IsThereThroughputForLastXDaysForSource(timeFrameToCheck, throughputSourceToCheck, includeToday, default), expectedValue ? Is.True : Is.False); + Assert.That(await LicensingDataStore.IsThereThroughputForLastXDaysForSource(timeFrameToCheck, throughputSourceToCheck, includeToday), expectedValue ? Is.True : Is.False); } } \ No newline at end of file diff --git a/src/ServiceControl.Persistence.Tests/Throughput/ReportMasksTests.cs b/src/ServiceControl.Persistence.Tests/Throughput/ReportMasksTests.cs index 9c0aca7645..209aa699da 100644 --- a/src/ServiceControl.Persistence.Tests/Throughput/ReportMasksTests.cs +++ b/src/ServiceControl.Persistence.Tests/Throughput/ReportMasksTests.cs @@ -1,6 +1,7 @@ namespace ServiceControl.Persistence.Tests.Throughput; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; @@ -12,10 +13,10 @@ public async Task Should_retrieve_saved_report_masks() { //Arrange var expectedReportMasks = new List { "secret", "boo" }; - await LicensingDataStore.SaveReportMasks(expectedReportMasks, default); + await LicensingDataStore.SaveReportMasks(expectedReportMasks); //Act - var retrievedReportMasks = await LicensingDataStore.GetReportMasks(default); + var retrievedReportMasks = await LicensingDataStore.GetReportMasks(); //Assert Assert.That(retrievedReportMasks, Is.Not.Null); @@ -27,12 +28,12 @@ public async Task Should_update_existing_report_masks_if_already_exists() { // Arrange var oldReportMasks = new List { "secret", "boo" }; - await LicensingDataStore.SaveReportMasks(oldReportMasks, default); + await LicensingDataStore.SaveReportMasks(oldReportMasks); // Act var expectedReportMasks = new List { "secret", "hello" }; - await LicensingDataStore.SaveReportMasks(expectedReportMasks, default); - var retrievedReportMasks = await LicensingDataStore.GetReportMasks(default); + await LicensingDataStore.SaveReportMasks(expectedReportMasks); + var retrievedReportMasks = await LicensingDataStore.GetReportMasks(); // Assert Assert.That(retrievedReportMasks, Is.Not.Null); diff --git a/src/ServiceControl.Persistence.Tests/TrialLicenseDataProviderTests.cs b/src/ServiceControl.Persistence.Tests/TrialLicenseDataProviderTests.cs index ca48e29042..88270cb5ef 100644 --- a/src/ServiceControl.Persistence.Tests/TrialLicenseDataProviderTests.cs +++ b/src/ServiceControl.Persistence.Tests/TrialLicenseDataProviderTests.cs @@ -10,7 +10,7 @@ namespace ServiceControl.Persistence.Tests; class TrialLicenseDataProviderTests : PersistenceTestBase { [Test, CancelAfter(30_000)] - public async Task GetTrialEndDate_returns_null_by_default(CancellationToken cancellationToken) + public async Task GetTrialEndDate_returns_null_by_default(CancellationToken cancellationToken = default) { var trialLicenseDataProvider = ServiceProvider.GetRequiredService(); @@ -20,7 +20,7 @@ public async Task GetTrialEndDate_returns_null_by_default(CancellationToken canc } [Test, CancelAfter(30_000)] - public async Task StoreTrialEndDate_persists_value(CancellationToken cancellationToken) + public async Task StoreTrialEndDate_persists_value(CancellationToken cancellationToken = default) { var trialLicenseDataProvider = ServiceProvider.GetRequiredService(); var expectedEndDate = DateOnly.FromDateTime(DateTime.UtcNow.Date.AddDays(13)); diff --git a/src/ServiceControl.UnitTests/.editorconfig b/src/ServiceControl.UnitTests/.editorconfig index d9b7048273..062de7d0db 100644 --- a/src/ServiceControl.UnitTests/.editorconfig +++ b/src/ServiceControl.UnitTests/.editorconfig @@ -6,7 +6,5 @@ dotnet_diagnostic.CA2007.severity = none # Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0. # They are scheduled work, not accepted exceptions: remove a line once this project has no # violations of that rule left, and never add a rule back to this list. -dotnet_diagnostic.PS0003.severity = none dotnet_diagnostic.PS0013.severity = none -dotnet_diagnostic.PS0017.severity = none dotnet_diagnostic.PS0018.severity = none diff --git a/src/ServiceControl.UnitTests/Licensing/ActiveLicenseTests.cs b/src/ServiceControl.UnitTests/Licensing/ActiveLicenseTests.cs index b41dd6c800..00a93ffc04 100644 --- a/src/ServiceControl.UnitTests/Licensing/ActiveLicenseTests.cs +++ b/src/ServiceControl.UnitTests/Licensing/ActiveLicenseTests.cs @@ -70,9 +70,9 @@ public FakeDataProvider() : this(null) public FakeDataProvider(TrialMetadata metadata) => this.metadata = metadata; - public Task GetTrialEndDate(CancellationToken cancellationToken) => Task.FromResult(metadata?.TrialEndDate); + public Task GetTrialEndDate(CancellationToken cancellationToken = default) => Task.FromResult(metadata?.TrialEndDate); - public Task StoreTrialEndDate(DateOnly trialEndDate, CancellationToken cancellationToken) + public Task StoreTrialEndDate(DateOnly trialEndDate, CancellationToken cancellationToken = default) { metadata ??= new TrialMetadata(); metadata.TrialEndDate = trialEndDate; diff --git a/src/ServiceControl.UnitTests/Monitoring/EndpointInstanceMonitoringTests.cs b/src/ServiceControl.UnitTests/Monitoring/EndpointInstanceMonitoringTests.cs index 9ab5eac338..da66c2de3a 100644 --- a/src/ServiceControl.UnitTests/Monitoring/EndpointInstanceMonitoringTests.cs +++ b/src/ServiceControl.UnitTests/Monitoring/EndpointInstanceMonitoringTests.cs @@ -35,7 +35,7 @@ public async Task When_endpoint_removed_should_stay_removed() class FakeDomainEvents : IDomainEvents { - public Task Raise(T domainEvent, CancellationToken cancellationToken) where T : IDomainEvent + public Task Raise(T domainEvent, CancellationToken cancellationToken = default) where T : IDomainEvent { return Task.CompletedTask; } diff --git a/src/ServiceControl.UnitTests/Monitoring/HeartbeatEndpointSettingsSyncHostedServiceTests.cs b/src/ServiceControl.UnitTests/Monitoring/HeartbeatEndpointSettingsSyncHostedServiceTests.cs index 6b8b1ca1c8..2f2252afe2 100644 --- a/src/ServiceControl.UnitTests/Monitoring/HeartbeatEndpointSettingsSyncHostedServiceTests.cs +++ b/src/ServiceControl.UnitTests/Monitoring/HeartbeatEndpointSettingsSyncHostedServiceTests.cs @@ -242,15 +242,15 @@ public void RecordHeartbeat(EndpointInstanceId endpointInstanceId, DateTime time class MockEndpointSettingsStore(EndpointSettings[] settings) : IEndpointSettingsStore { - public IAsyncEnumerable GetAllEndpointSettings(CancellationToken token) => settings.ToAsyncEnumerable(); + public IAsyncEnumerable GetAllEndpointSettings(CancellationToken cancellationToken = default) => settings.ToAsyncEnumerable(); - public Task UpdateEndpointSettings(EndpointSettings settings, CancellationToken token) + public Task UpdateEndpointSettings(EndpointSettings settings, CancellationToken cancellationToken = default) { Updated.Add(settings); return Task.CompletedTask; } - public Task Delete(string name, CancellationToken cancellationToken) + public Task Delete(string name, CancellationToken cancellationToken = default) { Deleted.Add(name); return Task.CompletedTask;