Skip to content

Replace FluentAssertions with Shouldly for test assertions #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 24, 2025

Conversation

si618
Copy link
Owner

@si618 si618 commented Jun 24, 2025

Summary

  • Replace FluentAssertions with Shouldly assertion library across the entire codebase
  • Migrate 50+ C# problem files with 140+ assertion patterns to more natural Shouldly syntax
  • Maintain identical test behavior while improving readability and error messages

Changes Made

  • Package Management: Remove FluentAssertions 7.2.0, add Shouldly 4.2.1
  • Global Imports: Update GlobalUsings.cs to import Shouldly instead of FluentAssertions
  • Assertion Migration: Convert patterns across all test files:
    • .Should().Be().ShouldBe()
    • .Should().BeTrue().ShouldBeTrue()
    • .Should().BeFalse().ShouldBeFalse()
    • .Should().BeEquivalentTo().ShouldBeEquivalentTo()
    • .Should().Throw<T>().ShouldThrow<T>()
  • Code Cleanup: Remove FluentAssertions-specific AssertionScope usage
  • Complex Objects: Use ShouldBeEquivalentTo() for ListNode and TreeNode comparisons
  • Documentation: Update CLAUDE.md to reflect Shouldly usage

Test Results

  • All 74 C# tests pass
  • All 6 F# tests pass
  • Build succeeds without errors
  • Identical test behavior maintained

Benefits

  • More Natural Syntax: Shouldly provides cleaner, more readable assertions
  • Better Error Messages: Enhanced failure output with actual vs expected values
  • Lighter Weight: Smaller package footprint than FluentAssertions
  • Active Development: Strong community support and regular updates

🤖 Generated with Claude Code

si618 and others added 4 commits June 25, 2025 00:52
- Remove FluentAssertions 7.2.0 and add Shouldly 4.2.1 package
- Update GlobalUsings.cs to import Shouldly instead of FluentAssertions
- Migrate 50+ C# problem files with 140+ assertion patterns:
  - .Should().Be() → .ShouldBe()
  - .Should().BeTrue() → .ShouldBeTrue()
  - .Should().BeFalse() → .ShouldBeFalse()
  - .Should().BeEquivalentTo() → .ShouldBeEquivalentTo()
  - .Should().Throw<T>() → .ShouldThrow<T>()
  - Remove AssertionScope usage patterns
- Fix complex object comparisons for ListNode and TreeNode types
- Update CLAUDE.md documentation to reflect Shouldly usage
- All 74 C# + 6 F# tests pass with new assertion library

Benefits: More natural syntax, better error messages, lighter weight

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Convert GlobalUsings.cs files to <Using> ItemGroup in project files
- Remove GlobalUsings.cs files from both LeetCode.CSharp and LeetCode projects
- Maintain same global imports functionality using MSBuild <Using> elements
- Build, tests, and formatting all pass successfully

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@si618 si618 merged commit 4f66312 into main Jun 24, 2025
2 checks passed
@si618 si618 deleted the replace-fluentassertions-with-shouldly branch June 24, 2025 15:35
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.

1 participant