Refactor portal error handling, add integration tests#4825
Conversation
Removed redundant catch/rethrow blocks from GrpcPortal, RabbitMqPortal, and HttpPortal methods to simplify error handling. Cleaned up using directives and parameter formatting. Added comprehensive integration and unit tests for all three portal hosts, improving coverage of core operations, error scenarios, and context handling. Tests use MSTest and FluentAssertions with fake IDataPortalServer implementations.
There was a problem hiding this comment.
Pull request overview
This pull request addresses issue #4465 by removing redundant catch/rethrow blocks from three portal implementations (HttpPortal, GrpcPortal, and RabbitMqPortal). These catch blocks were creating DataPortalErrorInfo objects that were never used because the exception would be re-thrown and caught at a higher level (in HttpPortalController, GrpcPortal.InvokePortal, and RabbitMqPortal.InvokePortal respectively), where the error is properly converted to a DataPortalResponse with error data. The PR also includes minor code cleanup (using directive organization, whitespace normalization) and adds comprehensive test coverage for HttpPortal. Additionally, it adds integration test files for RabbitMq and Grpc portals, though these tests don't actually test the portal implementations themselves.
Changes:
- Removed redundant catch/rethrow blocks from Create, Fetch, Update, and Delete methods in HttpPortal, GrpcPortal, and RabbitMqPortal
- Added comprehensive unit tests for HttpPortal covering success and error scenarios for all operations
- Added integration test files for RabbitMq and Grpc portals (though these test FakeDataPortalServer directly rather than the actual portal classes)
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/Csla.Web.Mvc.Shared/Server/Hosts/HttpPortal.cs | Removed redundant catch/rethrow blocks from all CRUD methods; reorganized using directives alphabetically; normalized whitespace |
| Source/Csla.Channels.RabbitMq/RabbitMqPortal.cs | Removed redundant catch/rethrow blocks from all CRUD methods; removed unused System.Diagnostics using; normalized whitespace |
| Source/Csla.Channels.Grpc/GrpcPortal.cs | Removed redundant catch/rethrow blocks from all CRUD methods; normalized whitespace in cast expressions |
| Source/tests/Csla.test/Server/Hosts/HttpPortalTests.cs | Added comprehensive unit tests for HttpPortal including constructor validation, CRUD operations, error handling, and primitive criteria handling |
| Source/tests/Csla.test/Channels/RabbitMq/RabbitMqPortalIntegrationTests.cs | Added tests that validate IDataPortalServer behavior but don't actually test RabbitMqPortal class |
| Source/tests/Csla.test/Channels/Grpc/GrpcPortalIntegrationTests.cs | Added tests that validate IDataPortalServer behavior but don't actually test GrpcPortal class |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Refactored GrpcPortal, RabbitMqPortal, and HttpPortal tests to use a standardized TestCslaObject for criteria and return values. Updated test assertions to check ErrorData instead of Error. Simplified context and principal preservation tests. Added project references for Grpc and RabbitMq channels. Removed obsolete FakeMobileObject class.
…luizfbicalho/csla into feature/remove-catch-dataportal
RabbitMqPortalIntegrationTests.cs and all related tests were deleted. The Csla.Channels.RabbitMq project reference was also removed from Csla.Tests.csproj, eliminating RabbitMQ dependencies from the test project.
…luizfbicalho/csla into feature/remove-catch-dataportal
Removed redundant catch/rethrow blocks from GrpcPortal, RabbitMqPortal, and HttpPortal methods to simplify error handling. Cleaned up using directives and parameter formatting. Added comprehensive integration and unit tests for all three portal hosts, improving coverage of core operations, error scenarios, and context handling. Tests use MSTest and FluentAssertions with fake IDataPortalServer implementations.
#4465