Problem
1. SheshaNHibernateInterceptor bugs force workarounds in every Shesha application
Two bugs in SheshaNHibernateInterceptor currently require every Shesha application to implement custom interceptor workarounds:
- Null
previousState in OnFlushDirty: When NHibernate calls OnFlushDirty during soft-delete detection, the previousState parameter can be null, causing a NullReferenceException. Every application must guard against this independently.
- Null
EntityChangeEventHelper during early bootstrap: During application startup, the EntityChangeEventHelper property (which relies on property injection) hasn't been set yet, leading to null reference errors when the interceptor fires during early bootstrap operations.
2. No reusable test infrastructure package
Every Shesha application currently needs to copy-paste ~500 lines of test infrastructure from the framework's internal Shesha.Tests project because it is not published as a NuGet package. This causes:
- Drift: Each application independently patches framework test bugs, leading to divergent implementations
- Duplicated interceptor workarounds: Every test project must independently work around the two NHibernate interceptor bugs described above
- Inconsistent test patterns: Without a shared base, each application develops its own conventions for integration test setup, database fixtures, and module configuration
- High onboarding cost: New Shesha applications require significant boilerplate (~500 lines) just to set up basic integration testing
Requirements
Bug Fixes
- Fix
OnFlushDirty null previousState: Add a null guard for previousState in SheshaNHibernateInterceptor.OnFlushDirty before accessing it for soft-delete detection
- Fix null
EntityChangeEventHelper during bootstrap: Add a null check for EntityChangeEventHelper before invoking it, so the interceptor gracefully handles the case where property injection hasn't completed yet
New Shesha.Testing NuGet Package
Create a new Shesha.Testing NuGet package that extracts and publishes the reusable test infrastructure currently locked in the unpublished Shesha.Tests project. The package should include:
ShaIntegratedTestBase<T> - Base class for integrated tests with ABP dependency injection and module lifecycle support
SheshaNhTestBase<T> - Base class for NHibernate-backed integration tests with session management
- Database fixtures for multiple providers:
- SQL Server fixture (Testcontainers-based)
- PostgreSQL fixture (Testcontainers-based)
- Local SQL Server fixture (for local development)
ConfigureForTesting() helper - An extension method or helper that encapsulates the ~40 lines of common module boilerplate needed to configure a Shesha module for testing (e.g., disabling background jobs, configuring test-specific settings, setting up in-memory caches)
Validation
- Update
Shesha.Tests to consume Shesha.Testing instead of its own internal infrastructure, validating that the package works correctly
- The migration should significantly reduce the test module code (e.g., from ~142 lines to ~65 lines)
- All existing tests must continue to pass after the migration
Acceptance Criteria
Problem
1. SheshaNHibernateInterceptor bugs force workarounds in every Shesha application
Two bugs in
SheshaNHibernateInterceptorcurrently require every Shesha application to implement custom interceptor workarounds:previousStateinOnFlushDirty: When NHibernate callsOnFlushDirtyduring soft-delete detection, thepreviousStateparameter can benull, causing aNullReferenceException. Every application must guard against this independently.EntityChangeEventHelperduring early bootstrap: During application startup, theEntityChangeEventHelperproperty (which relies on property injection) hasn't been set yet, leading to null reference errors when the interceptor fires during early bootstrap operations.2. No reusable test infrastructure package
Every Shesha application currently needs to copy-paste ~500 lines of test infrastructure from the framework's internal
Shesha.Testsproject because it is not published as a NuGet package. This causes:Requirements
Bug Fixes
OnFlushDirtynullpreviousState: Add a null guard forpreviousStateinSheshaNHibernateInterceptor.OnFlushDirtybefore accessing it for soft-delete detectionEntityChangeEventHelperduring bootstrap: Add a null check forEntityChangeEventHelperbefore invoking it, so the interceptor gracefully handles the case where property injection hasn't completed yetNew
Shesha.TestingNuGet PackageCreate a new
Shesha.TestingNuGet package that extracts and publishes the reusable test infrastructure currently locked in the unpublishedShesha.Testsproject. The package should include:ShaIntegratedTestBase<T>- Base class for integrated tests with ABP dependency injection and module lifecycle supportSheshaNhTestBase<T>- Base class for NHibernate-backed integration tests with session managementConfigureForTesting()helper - An extension method or helper that encapsulates the ~40 lines of common module boilerplate needed to configure a Shesha module for testing (e.g., disabling background jobs, configuring test-specific settings, setting up in-memory caches)Validation
Shesha.Teststo consumeShesha.Testinginstead of its own internal infrastructure, validating that the package works correctlyAcceptance Criteria
SheshaNHibernateInterceptor.OnFlushDirtyhandles nullpreviousStatewithout throwingSheshaNHibernateInterceptorhandles nullEntityChangeEventHelperduring early bootstrapShesha.TestingNuGet package is created withShaIntegratedTestBase<T>,SheshaNhTestBase<T>, database fixtures, andConfigureForTesting()helperShesha.Testsis updated to consumeShesha.Testingand all existing tests passShesha.Tests