agentleFS
Sorcha-PlatformSorcha-Platform/Sorcha/.claude/skills/fluent-assertions/SKILL.md

fluent-assertions

Skill2 starsChanged 10 months agoMITView on GitHub

Creates readable test assertions with FluentAssertions library. Use when: writing unit tests, integration tests, verifying object state, testing exceptions, asserting collections

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use mcp__context7__resolve-library-id to search for "fluent-assertions"

    line 110

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

FluentAssertions Skill

FluentAssertions provides a fluent interface for writing test assertions in C#. The Sorcha codebase uses it across 1,100+ tests with xUnit. All assertions follow the subject.Should().BeX() pattern.

Quick Start

Basic Value Assertions

// Strings
wallet.Address.Should().NotBeNullOrEmpty();
blueprint.Title.Should().Be("Purchase Order");
error.Message.Should().Contain("validation");

// Numbers
blueprint.Version.Should().Be(5);
result.Count.Should().BeGreaterThan(0).And.BeLessThan(100);

// Booleans
result.IsSuccess.Should().BeTrue();
validation.IsValid.Should().BeFalse();

Exception Testing

// Sync exception testing
builder.Invoking(b => b.Build())
    .Should().Throw<InvalidOperationException>()
    .WithMessage("*title*");  // Wildcard matching

// Async exception testing
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
    await _walletManager.CreateWalletAsync("Test", null!, "user1", "tenant1"));

Collection Assertions

blueprint.Participants.Should().HaveCount(2);
blueprint.Actions.Should().NotBeEmpty();
events.Should().ContainSingle(e => e is WalletCreatedEvent);
wallets.Should().AllSatisfy(w => w.Owner.Should().Be(owner));
docket.TransactionIds.Should().ContainInOrder("tx1", "tx2", "tx3");

Key Concepts

ConceptUsageExample
Should()Entry point for all assertionsvalue.Should().Be(expected)
AndChain multiple assertions.NotBeNull().And.HaveCount(2)
Which/WhoseValueAccess nested values.ContainKey("x").WhoseValue.Should().Be("y")
InvokingTest sync exceptionsobj.Invoking(x => x.Method())
AwaitingTest async exceptionsobj.Awaiting(x => x.MethodAsync())

Common Patterns

Object Property Assertions

wallet.Should().NotBeNull();
wallet.Name.Should().Be("Test Wallet");
wallet.Status.Should().Be(WalletStatus.Active);
wallet.Metadata.Should().ContainKey("environment").WhoseValue.Should().Be("production");

Time-Based Assertions

docket.TimeStamp.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(1));
blueprint.UpdatedAt.Should().BeOnOrAfter(beforeBuild).And.BeOnOrBefore(afterBuild);

Validation Result Assertions

result.Validation.IsValid.Should().BeTrue();
result.Errors.Should().BeEmpty();

// Or for failures
result.Success.Should().BeFalse();
result.Validation.Errors.Should().NotBeEmpty();
result.Errors.Should().Contain(e => e.Contains("validation"));

See Also

  • patterns
  • workflows

Related Skills

  • See the xunit skill for test framework patterns
  • See the moq skill for mocking dependencies in tests

Documentation Resources

Fetch latest FluentAssertions documentation with Context7.

How to use Context7:

  1. Use mcp__context7__resolve-library-id to search for "fluent-assertions"
  2. Prefer website documentation (IDs starting with /websites/) over source code repositories when available
  3. Query with mcp__context7__query-docs using the resolved library ID

Library ID: /fluentassertions/fluentassertions

Recommended Queries:

  • "FluentAssertions basic assertions Should Be"
  • "FluentAssertions collection assertions HaveCount Contain"
  • "FluentAssertions exception testing ThrowAsync"
  • "FluentAssertions object equivalence BeEquivalentTo"

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.