Phase 2: Create .NET Core 6.0 Web API with Read-Only Endpoints#12
Open
devin-ai-integration[bot] wants to merge 2 commits intodevin/1765826585-migration-assessmentfrom
Open
Conversation
… Tags, and Posts
Phase 2 of the .NET Framework to .NET Core migration:
- Create SampleWebApp.Core class library with:
- Entity classes (Blog, Post, Tag)
- DTOs (BlogDto, TagDto, SimplePostDto, DetailPostDto)
- MediatR handlers for read-only queries
- AutoMapper mapping profile
- Create SampleWebApp.Api Web API project with:
- DbContext configured for SQL Server (same database as existing app)
- BlogsController with GET /api/blogs and GET /api/blogs/{id}
- TagsController with GET /api/tags and GET /api/tags/{id}
- PostsController with GET /api/posts?blogId={blogId} and GET /api/posts/{id}
- Swagger/OpenAPI documentation
- MediatR and AutoMapper integration
Co-Authored-By: Abhay Aggarwal <abhay.aggarwal@codeium.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Add SampleWebApp.Api.Tests project with xUnit, FluentAssertions, Moq - Add TestDbContextFixture for in-memory database testing - Add AutoMapperFixture for mapping configuration - Add unit tests for Blog handlers (GetBlogsHandler, GetBlogByIdHandler) - Add unit tests for Tag handlers (GetTagsHandler, GetTagByIdHandler) - Add unit tests for Post handlers (GetPostsHandler, GetPostByIdHandler) - Add integration tests for BlogsController, TagsController, PostsController - Add CustomWebApplicationFactory for integration testing with in-memory database - Update Program.cs with partial class for test accessibility All 42 tests pass successfully. Co-Authored-By: Abhay Aggarwal <abhay.aggarwal@codeium.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2: Add .NET Core 6.0 Web API with Read-Only Endpoints
Summary
This PR implements Phase 2 of the .NET Framework to .NET Core migration by creating a new .NET Core 6.0 Web API project that runs alongside the existing .NET Framework MVC application, sharing the same SQL Server database.
Three new projects are added:
SampleWebApp.Core - Class library containing entities, DTOs, and MediatR handlers for read-only queries. Handlers use AutoMapper to map entities to DTOs and include related data via EF Core's
.Include().SampleWebApp.Api - Web API project with three controllers exposing read-only endpoints:
GET /api/blogsandGET /api/blogs/{id}GET /api/tagsandGET /api/tags/{id}GET /api/posts?blogId={blogId}andGET /api/posts/{id}SampleWebApp.Api.Tests - Test project with 42 unit and integration tests using xUnit, FluentAssertions, and EF Core InMemory provider.
The API includes Swagger UI for testing endpoints in development mode.
Updates Since Last Revision
Added comprehensive test suite (
SampleWebApp.Api.Tests):Review & Testing Checklist for Human
SampleWebApp.Core/Entities/against the existingDataLayer/DataClasses/Concrete/to ensure all properties and constraints match.Server=(localdb)\\mssqllocaldb). Update for your environment if needed.Recommended test plan:
dotnet test SampleWebApp.Api.Teststo verify all 42 tests passdotnet run --project SampleWebApp.Api/swaggerand test each endpointNotes
The handlers inject
DbContext(abstract base class) rather than the concreteSampleWebAppDbContext. This is registered in DI viaAddScoped<DbContext>(provider => provider.GetRequiredService<SampleWebAppDbContext>()).The test project uses EF Core InMemory provider which does not enforce referential integrity the same way SQL Server does. Integration tests verify API behavior but do not guarantee database compatibility.
Link to Devin run: https://app.devin.ai/sessions/d522c71ef39e4168b74915566b62b279
Requested by: Abhay Aggarwal (@abhay-codeium)