using Omika.Core.Observability; using Omika.Core.Observability.Outbox; namespace Omika.Tests.Observability.Outbox; /// Tests de l'exporteur outbox : never-throw, délégation, priorité. 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); } }