Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 1, 2025

Addresses code review feedback from PR #116 to use .Select() instead of foreach with immediate variable mapping.

Changes

  • Refactored WithPostReplyingTo() in PostTestDataBuilder to use LINQ projection
// Before
foreach (var mentionedPostId in mentionedPostIds)
{
    var postToReply = new PostToReply { PostId = mentionedPostId, Reply = post };
    _dbContext.PostsToReplies.Add(postToReply);
}

// After
var postsToReplies = mentionedPostIds.Select(mentionedPostId => new PostToReply
{
    PostId = mentionedPostId,
    Reply = post,
});
_dbContext.PostsToReplies.AddRange(postsToReplies);

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Address feedback on integration tests and cascade delete fixes Refactor foreach loop to use LINQ Select in PostTestDataBuilder Dec 1, 2025
Copilot AI requested a review from magicxor December 1, 2025 06:30
@magicxor magicxor marked this pull request as ready for review December 1, 2025 06:34
Copilot AI review requested due to automatic review settings December 1, 2025 06:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the WithPostReplyingTo() method in PostTestDataBuilder to replace a foreach loop with LINQ's Select() method, making the code more functional and concise.

Key Changes:

  • Replaced foreach loop with Select() LINQ projection for creating PostToReply objects
  • Changed from multiple Add() calls to a single AddRange() call

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@magicxor magicxor merged commit 097b429 into feature/add-tests Dec 1, 2025
14 checks passed
@magicxor magicxor deleted the copilot/sub-pr-116 branch December 1, 2025 06:40
magicxor added a commit that referenced this pull request Dec 1, 2025
…tory & fix cascade delete bugs (#116)

* clean usings

* move common code to IntegrationTestBase

* add ban tests

* add post tests

* fix SearchPostsTests

* add thread tests

* fix cascade db operations

* clean usings

* add more tests and fix cascade delete bugs

* Refactor foreach loop to use LINQ Select in PostTestDataBuilder (#117)

* Initial plan

* Refactor foreach loop to use .Select() pattern in PostTestDataBuilder

Co-authored-by: magicxor <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: magicxor <[email protected]>

* remove unused variables

* add a comment

* rename FilterNonEmpty to WhereNotNullOrWhiteSpace

* add missing interfaces

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: magicxor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants