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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Particular.LicensingComponent.UnitTests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 12 additions & 12 deletions src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task Should_return_known_endpoints_if_any()
var auditQuery = new AuditQuery(NullLogger<AuditQuery>.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");
Expand All @@ -53,7 +53,7 @@ public async Task Should_return_audit_remotes()
var auditQuery = new AuditQuery(NullLogger<AuditQuery>.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");
Expand Down Expand Up @@ -81,7 +81,7 @@ public async Task Should_return_successful_audit_connection_if_instances_exist_a
var auditQuery = new AuditQuery(NullLogger<AuditQuery>.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");
Expand All @@ -103,7 +103,7 @@ public async Task Should_return_diagnostics_and_no_errors_when_no_remotes_define
var auditQuery = new AuditQuery(NullLogger<AuditQuery>.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");
Expand All @@ -128,7 +128,7 @@ public async Task Should_always_return_diagnostics_and_relevant_errors_when_inva
var auditQuery = new AuditQuery(NullLogger<AuditQuery>.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");
Expand All @@ -148,15 +148,15 @@ public async Task Should_return_correct_audit_count()
var auditQuery = new AuditQuery(NullLogger<AuditQuery>.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");
}

class ConfigurationApi_ReturningOneValidAuditConfig : IConfigurationApi
{
public Task<object> GetConfig(CancellationToken cancellationToken) => throw new NotImplementedException();
public Task<object> GetConfig(CancellationToken cancellationToken = default) => throw new NotImplementedException();

public Task<RemoteConfiguration[]> GetRemoteConfigs(CancellationToken cancellationToken = default)
{
Expand All @@ -165,12 +165,12 @@ public Task<RemoteConfiguration[]> GetRemoteConfigs(CancellationToken cancellati
return Task.FromResult<RemoteConfiguration[]>([remote]);
}

public Task<RootUrls> GetUrls(string baseUrl, CancellationToken cancellationToken) => throw new NotImplementedException();
public Task<RootUrls> GetUrls(string baseUrl, CancellationToken cancellationToken = default) => throw new NotImplementedException();
}

class ConfigurationApi_Configurable : IConfigurationApi
{
public Task<object> GetConfig(CancellationToken cancellationToken) => throw new NotImplementedException();
public Task<object> GetConfig(CancellationToken cancellationToken = default) => throw new NotImplementedException();

public Task<RemoteConfiguration[]> GetRemoteConfigs(CancellationToken cancellationToken = default)
{
Expand All @@ -184,7 +184,7 @@ public Task<RemoteConfiguration[]> GetRemoteConfigs(CancellationToken cancellati
return Task.FromResult<RemoteConfiguration[]>([remote]);
}

public Task<RootUrls> GetUrls(string baseUrl, CancellationToken cancellationToken) => throw new NotImplementedException();
public Task<RootUrls> GetUrls(string baseUrl, CancellationToken cancellationToken = default) => throw new NotImplementedException();

public bool ReturnAuditConfig { get; set; }
public string RemoteStatus { get; set; }
Expand All @@ -194,7 +194,7 @@ public Task<RemoteConfiguration[]> GetRemoteConfigs(CancellationToken cancellati

class EndpointsApi_ReturningTwoEndpoints : IEndpointsApi
{
public Task<List<Endpoint>> GetEndpoints(CancellationToken cancellationToken)
public Task<List<Endpoint>> GetEndpoints(CancellationToken cancellationToken = default)
{
return Task.FromResult<List<Endpoint>>([
new Endpoint { Id = Guid.NewGuid(), Name = "Endpoint1" },
Expand All @@ -206,7 +206,7 @@ public Task<List<Endpoint>> GetEndpoints(CancellationToken cancellationToken)

class AuditCountApi_ReturningThreeAuditCounts : IAuditCountApi
{
public async Task<IList<AuditCount>> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken)
public async Task<IList<AuditCount>> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken = default)
{
var auditCounts = new List<AuditCount>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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<string, IEnumerable<ThroughputData>> foundEndpointThroughput =
await DataStore.GetEndpointThroughputByQueueName([endpointName], default);
await DataStore.GetEndpointThroughputByQueueName([endpointName]);
ThroughputData[] throughputData = foundEndpointThroughput[endpointName].ToArray();

// Assert
Expand All @@ -210,19 +210,19 @@ class AuditQuery_NoAuditRemotes : IAuditQuery
public Func<RemoteInstanceInformation, bool> ValidRemoteInstances => r => true;

public Task<IEnumerable<AuditCount>> GetAuditCountForEndpoint(string endpointUrlName,
CancellationToken cancellationToken) => Task.FromResult<IEnumerable<AuditCount>>([]);
CancellationToken cancellationToken = default) => Task.FromResult<IEnumerable<AuditCount>>([]);

public Task<List<RemoteInstanceInformation>> GetAuditRemotes(CancellationToken cancellationToken) =>
public Task<List<RemoteInstanceInformation>> GetAuditRemotes(CancellationToken cancellationToken = default) =>
Task.FromResult<List<RemoteInstanceInformation>>([]);

public Task<IEnumerable<ServiceControlEndpoint>> GetKnownEndpoints(CancellationToken cancellationToken)
public Task<IEnumerable<ServiceControlEndpoint>> GetKnownEndpoints(CancellationToken cancellationToken = default)
{
InstanceParameter = true;

return Task.FromResult<IEnumerable<ServiceControlEndpoint>>([]);
}

public Task<ConnectionSettingsTestResult> TestAuditConnection(CancellationToken cancellationToken) =>
public Task<ConnectionSettingsTestResult> TestAuditConnection(CancellationToken cancellationToken = default) =>
Task.FromResult(
new ConnectionSettingsTestResult { ConnectionSuccessful = true, ConnectionErrorMessages = [] });

Expand All @@ -243,23 +243,23 @@ public AuditQuery_WithOneEndpoint(string endpointName, long throughputCount, Dat
public Func<RemoteInstanceInformation, bool> ValidRemoteInstances => r => true;

public Task<IEnumerable<AuditCount>> GetAuditCountForEndpoint(string endpointUrlName,
CancellationToken cancellationToken)
CancellationToken cancellationToken = default)
{
var auditCount = new AuditCount { UtcDate = ThroughputDate, Count = ThroughputCount };

return Task.FromResult(new List<AuditCount> { auditCount }.AsEnumerable());
}

public Task<List<RemoteInstanceInformation>> GetAuditRemotes(CancellationToken cancellationToken) =>
public Task<List<RemoteInstanceInformation>> GetAuditRemotes(CancellationToken cancellationToken = default) =>
Task.FromResult<List<RemoteInstanceInformation>>([]);

public Task<IEnumerable<ServiceControlEndpoint>> GetKnownEndpoints(CancellationToken cancellationToken)
public Task<IEnumerable<ServiceControlEndpoint>> GetKnownEndpoints(CancellationToken cancellationToken = default)
{
var scEndpoint = new ServiceControlEndpoint { Name = EndpointName, HeartbeatsEnabled = true };
return Task.FromResult<IEnumerable<ServiceControlEndpoint>>([scEndpoint]);
}

public Task<ConnectionSettingsTestResult> TestAuditConnection(CancellationToken cancellationToken) =>
public Task<ConnectionSettingsTestResult> TestAuditConnection(CancellationToken cancellationToken = default) =>
Task.FromResult(
new ConnectionSettingsTestResult { ConnectionSuccessful = true, ConnectionErrorMessages = [] });

Expand All @@ -275,19 +275,19 @@ class AuditQuery_ThrowingAnExceptionOnKnownEndpointsCall : IAuditQuery
public Func<RemoteInstanceInformation, bool> ValidRemoteInstances => r => true;

public Task<IEnumerable<AuditCount>> GetAuditCountForEndpoint(string endpointUrlName,
CancellationToken cancellationToken) => throw new NotImplementedException();
CancellationToken cancellationToken = default) => throw new NotImplementedException();

public Task<List<RemoteInstanceInformation>> GetAuditRemotes(CancellationToken cancellationToken) =>
public Task<List<RemoteInstanceInformation>> GetAuditRemotes(CancellationToken cancellationToken = default) =>
Task.FromResult<List<RemoteInstanceInformation>>([]);

public Task<IEnumerable<ServiceControlEndpoint>> GetKnownEndpoints(CancellationToken cancellationToken)
public Task<IEnumerable<ServiceControlEndpoint>> GetKnownEndpoints(CancellationToken cancellationToken = default)
{
InstanceParameter = true;

throw new Exception("Oops");
}

public Task<ConnectionSettingsTestResult> TestAuditConnection(CancellationToken cancellationToken) =>
public Task<ConnectionSettingsTestResult> TestAuditConnection(CancellationToken cancellationToken = default) =>
throw new NotImplementedException();

public bool InstanceParameter { get; set; }
Expand All @@ -303,17 +303,17 @@ class BrokerThroughputQuery_WithSanitization : IBrokerThroughputQuery

public KeyDescriptionPair[] Settings => throw new NotImplementedException();

public IAsyncEnumerable<IBrokerQueue> GetQueueNames(CancellationToken cancellationToken) =>
public IAsyncEnumerable<IBrokerQueue> GetQueueNames(CancellationToken cancellationToken = default) =>
throw new NotImplementedException();

public IAsyncEnumerable<QueueThroughput> 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<string, string> settings) => throw new NotImplementedException();

public Task<(bool Success, List<string> Errors, string Diagnostics)> TestConnection(
CancellationToken cancellationToken) => throw new NotImplementedException();
CancellationToken cancellationToken = default) => throw new NotImplementedException();

public string SanitizeEndpointName(string endpointName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void Initialize(ReadOnlyDictionary<string, string> settings)
}

public async IAsyncEnumerable<QueueThroughput> GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
[EnumeratorCancellation] CancellationToken cancellationToken)
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
GetGetThroughputPerDay++;

Expand All @@ -148,7 +148,7 @@ public async IAsyncEnumerable<QueueThroughput> GetThroughputPerDay(IBrokerQueue
}

public async IAsyncEnumerable<IBrokerQueue> GetQueueNames(
[EnumeratorCancellation] CancellationToken cancellationToken)
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
if (GetQueueNamesCalls++ % 2 == 0)
{
Expand All @@ -168,7 +168,7 @@ public async IAsyncEnumerable<IBrokerQueue> GetQueueNames(
public KeyDescriptionPair[] Settings { get; } = [];

public Task<(bool Success, List<string> 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;
Expand All @@ -187,15 +187,15 @@ public void Initialize(ReadOnlyDictionary<string, string> settings)
}

public async IAsyncEnumerable<QueueThroughput> GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
[EnumeratorCancellation] CancellationToken cancellationToken)
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await Task.CompletedTask;

yield break;
}

public async IAsyncEnumerable<IBrokerQueue> GetQueueNames(
[EnumeratorCancellation] CancellationToken cancellationToken)
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
yield return new DefaultBrokerQueue("sales@one") { SanitizedName = "sales" };
yield return new DefaultBrokerQueue("sales@two") { SanitizedName = "sales" };
Expand All @@ -211,7 +211,7 @@ public async IAsyncEnumerable<IBrokerQueue> GetQueueNames(
public KeyDescriptionPair[] Settings { get; } = [];

public Task<(bool Success, List<string> 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;
Expand All @@ -232,7 +232,7 @@ public void Initialize(ReadOnlyDictionary<string, string> settings)
}

public async IAsyncEnumerable<QueueThroughput> GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
[EnumeratorCancellation] CancellationToken cancellationToken)
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await Task.CompletedTask;

Expand All @@ -242,7 +242,7 @@ public async IAsyncEnumerable<QueueThroughput> GetThroughputPerDay(IBrokerQueue
}

public async IAsyncEnumerable<IBrokerQueue> GetQueueNames(
[EnumeratorCancellation] CancellationToken cancellationToken)
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
yield return new DefaultBrokerQueue("marketing");
yield return new DefaultBrokerQueue("customer");
Expand All @@ -256,7 +256,7 @@ public async IAsyncEnumerable<IBrokerQueue> GetQueueNames(
public KeyDescriptionPair[] Settings { get; } = [];

public Task<(bool Success, List<string> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Contracts;
using Persistence;
Expand Down Expand Up @@ -122,7 +123,7 @@ public async Task Build()
{
foreach (Endpoint endpoint in endpoints)
{
await store.SaveEndpoint(endpoint, default);
await store.SaveEndpoint(endpoint);
}

;
Expand All @@ -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());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

class FakeAuditCountApi : IAuditCountApi
{
public Task<IList<ServiceControl.Api.Contracts.AuditCount>> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken) => throw new NotImplementedException();
public Task<IList<ServiceControl.Api.Contracts.AuditCount>> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken = default) => throw new NotImplementedException();
}
}
Loading
Loading