Skip to content

Test Scenario Catalog

This is the complete test list for ObservablePortGenerator. For detailed descriptions of each scenario, refer to Part 3-07. Test Scenario.


ObservablePortGenerator tests are organized along two axes:

  • Generator snapshot tests — Verify code generation results by comparing them with .verified.txt files
  • Runtime Observability structure verification — Verify that the generated code outputs the correct tag/field structure at actual runtime

The ObservablePortGeneratorTests class verifies 8 categories x 31 scenarios.

Test MethodVerification
ObservablePortGenerator_ShouldGenerate_GenerateObservablePortAttributeAuto-generation of [GenerateObservablePort] Attribute
Test MethodVerification
Should_Generate_PipelineClass_WithSingleMethodObservable class generation for single-method adapter
Should_Generate_PipelineClass_WithMultipleMethodsAll method overrides for multi-method adapter
Should_NotGenerate_PipelineClass_WhenNoMethodsAdapter with no methods — no pipeline generated
Test MethodVerification
Should_Generate_LoggerMessageDefine_WithZeroParameters0 parameters → 4 total fields → LoggerMessage.Define
Should_Generate_LoggerMessageDefine_WithOneParameter1 parameter → 5 total fields → LoggerMessage.Define
Should_Generate_LoggerMessageDefine_WithTwoParameters2 parameters → 6 total fields → LoggerMessage.Define (boundary)
Should_Generate_LogDebugFallback_WithThreeParameters3 parameters → 7 total fields → logger.LogDebug() fallback
Should_Generate_LogDebugFallback_WithManyParametersMany parameters → logger.LogDebug() fallback
Should_Generate_CollectionCountFieldsCollection parameter → Count field added
Should_NotGenerate_Count_ForTupleParameterTuple parameter → Count not generated
Should_Generate_CollectionCountFields_WithArrayParameterArray parameter → Length field added
Test MethodVerification
Should_Generate_PipelineClass_WithSimpleReturnTypeSimple type extraction from FinT<IO, int> etc.
Should_Generate_PipelineClass_WithCollectionReturnTypeList<T>, T[] → Count/Length field generation
Should_Generate_PipelineClass_WithComplexGenericReturnTypeNested generic Dictionary<K, List<V>>
Should_Generate_PipelineClass_WithTupleReturnTypeTuple return → Count not generated
Should_Generate_PipelineClass_WithUnitReturnTypeFinT<IO, Unit> return type handling
Should_Generate_PipelineClass_WithNestedCollectionReturnTypeNested collection return type
Test MethodVerification
Should_Generate_PipelineClass_WithPrimaryConstructorC# 12+ Primary Constructor handling
Should_Generate_PipelineClass_WithMultipleConstructorsSelecting the constructor with most parameters among multiple
Should_Generate_PipelineClass_WithParameterNameConflictloggerbaseLogger name conflict resolution
Should_Generate_PipelineClass_WithNoConstructorParametersCase with no constructor parameters
Test MethodVerification
Should_Generate_PipelineClass_WithDirectIPortImplementationDirect IObservablePort implementation
Should_Generate_PipelineClass_WithInheritedIPortInterfaceInherited interface IUserRepository : IObservablePort
Should_Generate_PipelineClass_WithMultipleInterfacesMultiple interface implementation
Test MethodVerification
Should_Generate_PipelineClass_WithSimpleNamespaceSimple namespace namespace MyApp;
Should_Generate_PipelineClass_WithDeepNamespaceDeep namespace namespace Company.Domain.Adapters...;
Test MethodVerification
Should_ReportDiagnostic_WhenDuplicateParameterTypesActivitySource duplicate parameter → diagnostic warning
Should_ReportDiagnostic_WhenDuplicateMeterFactoryParameterIMeterFactory duplicate parameter → diagnostic warning
Should_ReportDiagnostic_WithCorrectLocationVerify diagnostic location points to the class declaration
Should_NotReportDiagnostic_WhenNoParameterDuplicationNormal case with no duplication → 0 diagnostics

Runtime Observability Structure Verification Tests

Section titled “Runtime Observability Structure Verification Tests”

These verify that the generated code outputs the correct Observability structure in actual runtime environments.

Verifies tag structure specification compliance.

Test MethodVerification
GeneratedCode_RequestMetrics_ShouldContainCorrectTagKeysRequest metrics 4 tags
GeneratedCode_ResponseSuccessMetrics_ShouldContainCorrectTagKeysSuccess response metrics tags
GeneratedCode_ResponseFailureMetrics_ShouldContainCorrectTagKeysFailure response metrics tags (including error.type, error.code)
GeneratedCode_MetricsNames_ShouldFollowCorrectPatternMetrics name pattern verification
GeneratedCode_TracingRequestTags_ShouldContainCorrectKeysTracing request tags
GeneratedCode_TracingSuccessTags_ShouldContainCorrectKeysTracing success tags
GeneratedCode_TracingFailureTags_ShouldContainCorrectKeysTracing failure tags
GeneratedCode_SpanName_ShouldFollowCorrectPatternSpan name pattern verification
GeneratedCode_LoggingTags_ShouldContainCorrectKeysLogging tags
GeneratedCode_ErrorHandling_ShouldClassifyErrorTypesError type classification (Expected/Exceptional/Aggregate)
GeneratedCode_ManyErrors_ShouldSelectPrimaryErrorCodeManyErrors primary error code selection

Verifies actual logging output field structure with snapshots.

Test MethodVerification
Request_Should_Log_Expected_FieldsRequest log fields
SuccessResponse_Should_Log_Expected_FieldsSuccess response log fields
WarningResponse_WithExpectedError_Should_Log_Expected_FieldsExpected error log fields
WarningResponse_WithExpectedErrorT_Should_Log_Expected_FieldsGeneric Expected error log fields
ErrorResponse_WithExceptionalError_Should_Log_Expected_FieldsExceptional error log fields
ErrorResponse_WithAggregateError_Should_Log_Expected_FieldsAggregate error log fields

Verifies metrics tag structure with snapshots.

Test MethodVerification
Handle_DurationTags_ShouldContainSameTagsAsRequestCounterDuration tags = Request tags
Handle_SuccessAndFailureResponses_ShouldHaveDifferentTagCountsSuccess 5 tags vs Failure 7 tags
Snapshot_RequestTagsRequest metrics tags snapshot
Snapshot_SuccessResponse_TagsSuccess response tags snapshot
Snapshot_FailureResponse_ExpectedError_TagsExpected error tags snapshot
Snapshot_FailureResponse_ExceptionalError_TagsExceptional error tags snapshot
Snapshot_FailureResponse_AggregateError_TagsAggregate error tags snapshot
Snapshot_DurationHistogram_TagsDuration histogram tags snapshot

Verifies Tracing (Activity) tag structure with snapshots.

Test MethodVerification
Handle_ShouldCreateActivityWithCorrectNameActivity span name pattern
Handle_Success_ShouldHaveSixTagsSuccess Activity 6 tags
Handle_Success_ShouldSetActivityStatusOkSuccess Activity status = Ok
Handle_Failure_ShouldHaveEightTagsFailure Activity 8 tags
Handle_Failure_ShouldSetActivityStatusErrorFailure Activity status = Error
Snapshot_SuccessTagsSuccess Tracing tags snapshot
Snapshot_FailureResponse_ExpectedError_TagsExpected error tags snapshot
Snapshot_FailureResponse_ExceptionalError_TagsExceptional error tags snapshot
Snapshot_FailureResponse_AggregateError_TagsAggregate error tags snapshot
Snapshot_FailureResponse_GenericError_TagsGeneric error tags snapshot