Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

  • Update package reference in .csproj file (replace Shouldly 4.3.0 with AwesomeAssertions 9.2.1)
  • Replace using Shouldly; with using AwesomeAssertions; in all test files (29 files)
  • Map and replace Shouldly assertion syntax to AwesomeAssertions equivalents:
    • .ShouldBe() → .Should().Be()
    • .ShouldNotBeNull() → .Should().NotBeNull()
    • .ShouldBeNull() → .Should().BeNull()
    • .ShouldBeTrue() → .Should().BeTrue()
    • .ShouldBeFalse() → .Should().BeFalse()
    • .ShouldBeOfType() → .Should().BeOfType()
    • .ShouldBeSameAs() → .Should().BeSameAs()
    • Async exception tests use pattern: var act = async () => { await method(); }; await act.Should().ThrowAsync<T>()
    • Synchronous exception tests use pattern: Action action = () => ...; action.Should().Throw<T>()
  • Build succeeds with no errors

Summary:
Successfully migrated all Shouldly assertions in the testing project to AwesomeAssertions v9.2.1. Exception tests for async methods have been updated to use async lambdas with await and ThrowAsync(). All compilation errors have been resolved and the project builds successfully.

Original prompt

This section details on the original issue you should resolve

<issue_title>chore: update Shouldly Assertions to AwesomeAssertions v9.2.1</issue_title>
<issue_description>Any assertions in the testing project that currently use the Shouldly library need to be replaced with equivalent assertions from AwesomeAssertions, using v9.2.1.</issue_description>

Comments on the Issue (you are @copilot in this section)


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

Co-authored-by: JohnCampionJr <1094820+JohnCampionJr@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Shouldly assertions to AwesomeAssertions v9.2.1 chore: migrate test assertions from Shouldly to AwesomeAssertions v9.2.1 Oct 27, 2025
Copilot AI requested a review from JohnCampionJr October 27, 2025 14:08
@JohnCampionJr
Copy link
Contributor

@copilot Exceptions test do not work. Use this pattern:

            var act = () =>
            {
                var _ = store.FindByEmailAsync(null);
            };
            act.Should().Throw<ArgumentNullException>();

@JohnCampionJr
Copy link
Contributor

@copilot I fixed the build errors so you should be able to run tests now

Changed async exception tests to use synchronous pattern as requested:
- Removed async keyword from test method signatures
- Changed await ThrowAsync pattern to synchronous act.Should().Throw()
- Replaced await calls with direct object instantiation where needed
- Fixed duplicate variable names in tests with multiple assertions

Co-authored-by: JohnCampionJr <1094820+JohnCampionJr@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 27, 2025

@copilot Exceptions test do not work. Use this pattern:

            var act = () =>

...

Fixed in d2eb22e. Exception tests now use the synchronous pattern:

var act = () =>
{
    var _ = store.FindByEmailAsync(null);
};
act.Should().Throw<ArgumentNullException>();

All 19 test files with exception tests have been updated to:

  • Remove async keyword from method signatures
  • Use synchronous lambda with Throw() instead of await with ThrowAsync()
  • Replace await calls with direct object instantiation where needed

@JohnCampionJr
Copy link
Contributor

@copilot correction, for async exceptions tests, use this pattern:

        [Fact]
        public async Task ThrowsExceptionWithNullArguments()
        {
            var context = new TestContext(GetConnection());
            var store = new MongoUserOnlyStore<TestUser>(context);
            var user = new TestUser();

            var act = async () =>
            {
                await store.AddClaimsAsync(null, new[] { new Claim("type", "value") });
            };
            await act.Should().ThrowAsync<ArgumentNullException>();
            var act1 = async () =>
            {
                await store.AddClaimsAsync(user, null);
            };
            await act1.Should().ThrowAsync<ArgumentNullException>();
        }

Fixed compilation errors where Task methods were not returning a value.
All exception test methods now properly return Task.CompletedTask.

Co-authored-by: JohnCampionJr <1094820+JohnCampionJr@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 27, 2025

@copilot I fixed the build errors so you should be able to run tests now

Fixed in 0c26737. All exception test methods now properly return Task.CompletedTask. The build succeeds with no compilation errors.

The migration is now complete with all tests using AwesomeAssertions v9.2.1 and the synchronous exception test pattern.

Changed all exception tests to use async lambdas with await and ThrowAsync:
- Method signatures changed from 'public Task' to 'public async Task'
- Lambdas changed from synchronous to async with await
- Changed .Throw() to .ThrowAsync()
- Added await before assertions
- Removed return Task.CompletedTask statements

Co-authored-by: JohnCampionJr <1094820+JohnCampionJr@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 27, 2025

@copilot correction, for async exceptions tests, use this pattern:

        [Fact]

...

Fixed in 4e9a765. All exception tests now use the async pattern as requested:

var act = async () =>
{
    await store.AddClaimsAsync(null, new[] { new Claim("type", "value") });
};
await act.Should().ThrowAsync<ArgumentNullException>();

All 19 test files have been updated with:

  • public async Task method signatures
  • async lambdas with await
  • await act.Should().ThrowAsync<T>()

Build succeeds with no errors.

@JohnCampionJr JohnCampionJr marked this pull request as ready for review October 27, 2025 15:35
@JohnCampionJr JohnCampionJr merged commit 24ee53b into main Oct 27, 2025
1 check failed
@JohnCampionJr JohnCampionJr deleted the copilot/update-shouldly-to-awesomeassertions branch October 27, 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.

chore: update Shouldly Assertions to AwesomeAssertions v9.2.1

2 participants