Skip to content

Refactor BoolExtensions into dedicated BooleanAssertions type#191

Merged
MrKWatkins merged 3 commits intomainfrom
copilot/refactor-boolextensions-to-booleanassertions
Feb 18, 2026
Merged

Refactor BoolExtensions into dedicated BooleanAssertions type#191
MrKWatkins merged 3 commits intomainfrom
copilot/refactor-boolextensions-to-booleanassertions

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

Promotes boolean assertions from extension methods on ObjectAssertions<bool> to a dedicated BooleanAssertions class, matching the IntegerAssertions<T> pattern.

Changes

  • BooleanAssertions — New sealed class inheriting ObjectAssertions<bool> with BeTrue(), NotBeTrue(), BeFalse(), NotBeFalse() returning BooleanAssertionsChain
  • BooleanAssertionsChain — New readonly struct with And and Value properties for fluent chaining
  • ShouldExtensions — Added Should(this bool) overload with [OverloadResolutionPriority(1)] returning BooleanAssertions
  • BooleanExtensions — Stripped to only nullable bool? overloads (still extension methods on ObjectAssertions<bool?>)
  • Tests — Split into BooleanAssertionsTests (non-nullable) and BooleanExtensionsTests (nullable); added chaining and inherited method tests
  • Docs — Updated tree, class docs, and method docs to reflect new structure

Before/After

// Before: extension method returns ObjectAssertionsChain<bool>
true.Should().BeTrue().And.Equal(true);

// After: instance method returns BooleanAssertionsChain, .And gives BooleanAssertions
true.Should().BeTrue().And.NotEqual(false);
//   ^^^^^^^^           ^^^
//   BooleanAssertions  BooleanAssertions (inherits ObjectAssertions<bool>)

Also fixed a pre-existing bug in NotBeTrue's error message — it previously said "was false" when the value was actually true.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 15, 2026 16:43
- Create BooleanAssertions class inheriting ObjectAssertions<bool>
- Create BooleanAssertionsChain struct for method chaining
- Add Should(bool) overload in ShouldExtensions
- Move non-nullable bool methods from BooleanExtensions to BooleanAssertions
- Keep nullable bool? extension methods in BooleanExtensions
- Add BooleanAssertionsTests with tests for new class
- Update BooleanExtensionsTests to only test nullable overloads
- Update API documentation to reflect new structure

Co-authored-by: MrKWatkins <345796+MrKWatkins@users.noreply.github.com>
Co-authored-by: MrKWatkins <345796+MrKWatkins@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor BoolExtensions into BooleanAssertions type Refactor BoolExtensions into dedicated BooleanAssertions type Feb 15, 2026
Copilot AI requested a review from MrKWatkins February 15, 2026 16:47
@MrKWatkins MrKWatkins marked this pull request as ready for review February 18, 2026 16:04
@MrKWatkins MrKWatkins merged commit 7e83c71 into main Feb 18, 2026
6 checks passed
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

Comments