nuget reorganization

This commit is contained in:
master
2025-11-18 23:45:25 +02:00
parent 77cee6a209
commit d3ecd7f8e6
7712 changed files with 13963 additions and 10007504 deletions

View File

@@ -0,0 +1,64 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using StellaOps.Signals.Models;
using StellaOps.Signals.Services;
using Xunit;
namespace StellaOps.Signals.Tests;
public class InMemoryEventsPublisherTests
{
[Fact]
public async Task PublishFactUpdatedAsync_EmitsStructuredEvent()
{
var logger = new TestLogger<InMemoryEventsPublisher>();
var publisher = new InMemoryEventsPublisher(logger);
var fact = new ReachabilityFactDocument
{
SubjectKey = "tenant:image@sha256:abc",
CallgraphId = "cg-123",
ComputedAt = System.DateTimeOffset.Parse("2025-11-18T12:00:00Z"),
States = new List<ReachabilityStateDocument>
{
new() { Target = "pkg:pypi/django", Reachable = true, Confidence = 0.9 },
new() { Target = "pkg:pypi/requests", Reachable = false, Confidence = 0.2 }
},
RuntimeFacts = new List<RuntimeFactDocument>
{
new() { SymbolId = "funcA", HitCount = 3 }
}
};
await publisher.PublishFactUpdatedAsync(fact, CancellationToken.None);
Assert.Contains("signals.fact.updated", logger.LastMessage);
Assert.Contains("\"subjectKey\":\"tenant:image@sha256:abc\"", logger.LastMessage);
Assert.Contains("\"callgraphId\":\"cg-123\"", logger.LastMessage);
Assert.Contains("\"reachableCount\":1", logger.LastMessage);
Assert.Contains("\"unreachableCount\":1", logger.LastMessage);
Assert.Contains("\"runtimeFactsCount\":1", logger.LastMessage);
}
private sealed class TestLogger<T> : ILogger<T>
{
public string LastMessage { get; private set; } = string.Empty;
public IDisposable BeginScope<TState>(TState state) => NullScope.Instance;
public bool IsEnabled(LogLevel logLevel) => true;
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, System.Exception? exception, Func<TState, System.Exception?, string> formatter)
{
LastMessage = formatter(state, exception);
}
private sealed class NullScope : IDisposable
{
public static readonly NullScope Instance = new();
public void Dispose() { }
}
}
}