Skip to content

Testing: assertions on a Task or ValueTask of an Option, a Result and a Patch #87

Closed

Description

@CaffeinatedCoder

CodoMetis.TypeKit.Testing asserts on an Option, a Result, a Patch and a composed fault, but only when the test already holds the value. A test of an async method writes (await service.Find(id)).ShouldBeSuccess(). The roadmap's 2.3.0 section lists async assertions.

Proposal

The assertions on a Task<…> and a ValueTask<…> of each: await service.Find(id).ShouldBeSuccess(), ShouldBeError(…), ShouldBeSome(), ShouldBeNone(), and the Patch ones, returning what the synchronous form returns. Messages as the synchronous forms write them.

Done when

  • Every synchronous assertion has its Task and ValueTask form, checked by a completeness test over the public surface.

  • A faulted task's exception propagates as it is, not wrapped in an assertion failure.

  • The Testing README shows them as compiled samples.

  • An assertion on a task left without await is reported (CMTK0003). Without await it passes whatever the task holds, and C# warns only in an async method. The rule knows the assertions by the Testing assembly's identity, so a consumer's own extension on a pending result is not reported, and no build that worked before 2.3 breaks. (Scope added while implementing.)

Activity

  1. added this to the 2.3.0 milestone on Oct 28, 2026
  2. CaffeinatedCoder commented on Oct 28, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Done in PR #95, merged into release/2.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/option-resultOption, Result and their extensionsenhancementNew feature or requestpackage/analyzersAffects CodoMetis.TypeKit.Analyzerspackage/testingAffects CodoMetis.TypeKit.Testing

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions