Skip to content

Assertions for IParsable<T>, ISpanParsable<T> and IUtf8SpanParsable<T> #2447

Description

@WhatzGames

Hi!

Just as an FYI: Before I switched to TUnit I had already created an issue a while back at fluentassertions/fluentassertions#2632.

The idea is pretty much to verify, that a given string is in such a format, that an instance of type TTarget can be created out of it.

So yes, TTarget is expected to have a ready implementation of the Parsing Methods.

In my previous issue I hadn't payed attention, but there are also interfaces dedicated to ReadOnlySpan<char> and ReadOnlySpan<byte>, so I'd include those in my idea here.

Since there are always two methods Parse and TryParse there was a discussion on which one was to be used, with the former being settled on.

In my mind TUnit would then end up having new APIs like so:

Assert.That(...)
    .IsParsableInto<TTarget>()
    .WithFormatProvider(IFormatProvider? provider);
Assert.That(...)
    .IsNotParsableInto<TTarget>()
    .WithFormatProvider(IFormatProvider? provider);

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions