up
This commit is contained in:
@@ -49,6 +49,7 @@ public sealed class ScannerToSignalsReachabilityTests
|
||||
parserResolver,
|
||||
artifactStore,
|
||||
callgraphRepo,
|
||||
new CallgraphNormalizationService(),
|
||||
Options.Create(new SignalsOptions()),
|
||||
TimeProvider.System,
|
||||
NullLogger<CallgraphIngestionService>.Instance);
|
||||
@@ -65,10 +66,15 @@ public sealed class ScannerToSignalsReachabilityTests
|
||||
var ingestResponse = await ingestionService.IngestAsync(request, CancellationToken.None);
|
||||
ingestResponse.CallgraphId.Should().NotBeNullOrWhiteSpace();
|
||||
|
||||
var scoringOptions = new SignalsOptions();
|
||||
var scoringService = new ReachabilityScoringService(
|
||||
callgraphRepo,
|
||||
new InMemoryReachabilityFactRepository(),
|
||||
TimeProvider.System,
|
||||
Options.Create(scoringOptions),
|
||||
new InMemoryReachabilityCache(),
|
||||
new InMemoryUnknownsRepository(),
|
||||
new NullEventsPublisher(),
|
||||
NullLogger<ReachabilityScoringService>.Instance);
|
||||
|
||||
var truth = JsonDocument.Parse(File.ReadAllText(Path.Combine(variantPath, "reachgraph.truth.json"))).RootElement;
|
||||
@@ -180,6 +186,46 @@ public sealed class ScannerToSignalsReachabilityTests
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class InMemoryReachabilityCache : IReachabilityCache
|
||||
{
|
||||
private readonly Dictionary<string, ReachabilityFactDocument> storage = new(StringComparer.Ordinal);
|
||||
|
||||
public Task<ReachabilityFactDocument?> GetAsync(string subjectKey, CancellationToken cancellationToken)
|
||||
{
|
||||
storage.TryGetValue(subjectKey, out var document);
|
||||
return Task.FromResult(document);
|
||||
}
|
||||
|
||||
public Task SetAsync(ReachabilityFactDocument document, CancellationToken cancellationToken)
|
||||
{
|
||||
storage[document.SubjectKey] = document;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task InvalidateAsync(string subjectKey, CancellationToken cancellationToken)
|
||||
{
|
||||
storage.Remove(subjectKey);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class InMemoryUnknownsRepository : IUnknownsRepository
|
||||
{
|
||||
public Task UpsertAsync(string subjectKey, IEnumerable<UnknownSymbolDocument> items, CancellationToken cancellationToken) =>
|
||||
Task.CompletedTask;
|
||||
|
||||
public Task<IReadOnlyList<UnknownSymbolDocument>> GetBySubjectAsync(string subjectKey, CancellationToken cancellationToken) =>
|
||||
Task.FromResult((IReadOnlyList<UnknownSymbolDocument>)Array.Empty<UnknownSymbolDocument>());
|
||||
|
||||
public Task<int> CountBySubjectAsync(string subjectKey, CancellationToken cancellationToken) =>
|
||||
Task.FromResult(0);
|
||||
}
|
||||
|
||||
private sealed class NullEventsPublisher : IEventsPublisher
|
||||
{
|
||||
public Task PublishFactUpdatedAsync(ReachabilityFactDocument fact, CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
|
||||
private sealed class InMemoryCallgraphArtifactStore : ICallgraphArtifactStore
|
||||
{
|
||||
public async Task<StoredCallgraphArtifact> SaveAsync(CallgraphArtifactSaveRequest request, Stream content, CancellationToken cancellationToken)
|
||||
|
||||
Reference in New Issue
Block a user