Premiere commit - Omika
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
using Omika.Core.Observability;
|
||||
using Omika.Core.Observability.External;
|
||||
using Omika.Core.Observability.Outbox;
|
||||
using Omika.Diagnostics.Import;
|
||||
using Omika.Diagnostics.Models;
|
||||
|
||||
namespace Omika.Diagnostics.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// T18 (§14/§84) : ScreenCode/FeatureCode traversent le transport (OmikaEvent → DTO →
|
||||
/// JSONL/Record) ; les données anciennes (NULL) restent compatibles partout.
|
||||
/// </summary>
|
||||
public class DiagnosticUsageTransportTests
|
||||
{
|
||||
[Fact]
|
||||
public void Mapper_ToDto_CarriesScreenAndFeatureCode()
|
||||
{
|
||||
var @event = new TelemetryEvent
|
||||
{
|
||||
EventCode = TelemetryEventCodes.MobileScreenView,
|
||||
ScreenCode = DiagnosticScreenCodes.Agenda,
|
||||
FeatureCode = DiagnosticFeatureCodes.EmailSend
|
||||
};
|
||||
|
||||
DiagnosticEventDto? dto = DiagnosticEventMapper.ToDto(@event, maxStringLength: 256);
|
||||
|
||||
Assert.NotNull(dto);
|
||||
Assert.Equal(DiagnosticScreenCodes.Agenda, dto!.ScreenCode);
|
||||
Assert.Equal(DiagnosticFeatureCodes.EmailSend, dto.FeatureCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Mapper_ToDto_NullUsage_StaysNull()
|
||||
{
|
||||
var @event = new TelemetryEvent { EventCode = TelemetryEventCodes.MobileAppStarted };
|
||||
|
||||
DiagnosticEventDto? dto = DiagnosticEventMapper.ToDto(@event, maxStringLength: 256);
|
||||
|
||||
Assert.NotNull(dto);
|
||||
Assert.Null(dto!.ScreenCode);
|
||||
Assert.Null(dto.FeatureCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RecordMapper_CarriesScreenAndFeatureCode()
|
||||
{
|
||||
var record = new RemoteDiagnosticRecord
|
||||
{
|
||||
Event = new DiagnosticEventDto
|
||||
{
|
||||
EventId = Guid.NewGuid(),
|
||||
EventCode = TelemetryEventCodes.MobileScreenView.Value!,
|
||||
ScreenCode = DiagnosticScreenCodes.SiteDetail,
|
||||
FeatureCode = DiagnosticFeatureCodes.ReportGenerate
|
||||
}
|
||||
};
|
||||
|
||||
DiagnosticEventRecord? mapped = DiagnosticEventRecordMapper.ToRecord(record, "mobile");
|
||||
|
||||
Assert.NotNull(mapped);
|
||||
Assert.Equal(DiagnosticScreenCodes.SiteDetail, mapped!.ScreenCode);
|
||||
Assert.Equal(DiagnosticFeatureCodes.ReportGenerate, mapped.FeatureCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RecordMapper_OldDataNullUsage_StaysNull()
|
||||
{
|
||||
var record = new RemoteDiagnosticRecord
|
||||
{
|
||||
Event = new DiagnosticEventDto
|
||||
{
|
||||
EventId = Guid.NewGuid(),
|
||||
EventCode = "OMK-MOB-APP-001"
|
||||
}
|
||||
};
|
||||
|
||||
DiagnosticEventRecord? mapped = DiagnosticEventRecordMapper.ToRecord(record, "mobile");
|
||||
|
||||
Assert.NotNull(mapped);
|
||||
Assert.Null(mapped!.ScreenCode);
|
||||
Assert.Null(mapped.FeatureCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user