nuget reorganization
This commit is contained in:
@@ -15,9 +15,13 @@ public class RuntimeFactsIngestionServiceTests
|
||||
{
|
||||
var factRepository = new InMemoryReachabilityFactRepository();
|
||||
var scoringService = new RecordingScoringService();
|
||||
var cache = new InMemoryReachabilityCache();
|
||||
var eventsPublisher = new RecordingEventsPublisher();
|
||||
var service = new RuntimeFactsIngestionService(
|
||||
factRepository,
|
||||
TimeProvider.System,
|
||||
cache,
|
||||
eventsPublisher,
|
||||
scoringService,
|
||||
NullLogger<RuntimeFactsIngestionService>.Instance);
|
||||
|
||||
@@ -75,6 +79,40 @@ public class RuntimeFactsIngestionServiceTests
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class InMemoryReachabilityCache : IReachabilityCache
|
||||
{
|
||||
private readonly Dictionary<string, ReachabilityFactDocument> cache = new(StringComparer.Ordinal);
|
||||
|
||||
public Task<ReachabilityFactDocument?> GetAsync(string subjectKey, CancellationToken cancellationToken)
|
||||
{
|
||||
cache.TryGetValue(subjectKey, out var doc);
|
||||
return Task.FromResult(doc);
|
||||
}
|
||||
|
||||
public Task SetAsync(ReachabilityFactDocument document, CancellationToken cancellationToken)
|
||||
{
|
||||
cache[document.SubjectKey] = document;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task InvalidateAsync(string subjectKey, CancellationToken cancellationToken)
|
||||
{
|
||||
cache.Remove(subjectKey);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class RecordingEventsPublisher : IEventsPublisher
|
||||
{
|
||||
public ReachabilityFactDocument? Last { get; private set; }
|
||||
|
||||
public Task PublishFactUpdatedAsync(ReachabilityFactDocument fact, CancellationToken cancellationToken)
|
||||
{
|
||||
Last = fact;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class RecordingScoringService : IReachabilityScoringService
|
||||
{
|
||||
public ReachabilityRecomputeRequest? LastRequest { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user