Files
Omika/tests/Omika.Tests/Observability/Outbox/DiagnosticOutboxExporterTests.cs
2026-10-23 18:46:50 +02:00

34 lines
1.3 KiB
C#

using Omika.Core.Observability;
using Omika.Core.Observability.Outbox;
namespace Omika.Tests.Observability.Outbox;
/// <summary>Tests de l'exporteur outbox : never-throw, délégation, priorité.</summary>
public class DiagnosticOutboxExporterTests
{
[Fact]
public async Task ExportAsync_DelegatesToOutbox()
{
var store = new InMemoryDiagnosticOutboxStore();
var counters = new DiagnosticCounters();
var outbox = new DiagnosticOutbox(store, new DiagnosticOutboxOptions(), counters);
var exporter = new DiagnosticOutboxExporter(outbox);
await exporter.ExportAsync([OutboxTestHarness.NewEvent(TelemetryPriority.P1)], CancellationToken.None);
Assert.Equal(1, counters.OutboxStored);
}
[Fact]
public async Task ExportAsync_ThrowingOutbox_NeverThrows()
{
var store = new InMemoryDiagnosticOutboxStore { ThrowOnStore = true };
var counters = new DiagnosticCounters();
var outbox = new DiagnosticOutbox(store, new DiagnosticOutboxOptions(), counters);
var exporter = new DiagnosticOutboxExporter(outbox);
// Ne doit pas lever : l'exporteur avale l'erreur de l'outbox (fail-open).
await exporter.ExportAsync([OutboxTestHarness.NewEvent(TelemetryPriority.P0)], CancellationToken.None);
}
}