tpierrain / NFluent

Smooth your .NET TDD experience with NFluent! NFluent is an ergonomic assertion library which aims to fluent your .NET TDD experience (based on simple Check.That() assertion statements). NFluent aims your tests to be fluent to write (with a super-duper-happy 'dot' auto-completion experience), fluent to read (i.e. as close as possible to plain English expression), but also fluent to troubleshoot, in a less-error-prone way comparing to the classical .NET test frameworks. NFluent is also directly inspired by the awesome Java FEST Fluent assertion/reflection library (http://fest.easytesting.org/)
Apache License 2.0
310 stars 53 forks source link

FormatException in Verifies when test fail #340

Closed Roxeez closed 10 months ago

Roxeez commented 1 year ago

Bug Type Please pick one:

Describe the bug I'm getting this exception when my test fail (in Verifies scope)

System.FormatException
Input string was not in a correct format.
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ReadOnlySpan`1 args)
   at System.Text.StringBuilder.AppendFormat(String format, Object arg0, Object arg1)
   at NFluent.Extensibility.FluentMessage.ToString()
   at NFluent.Kernel.CheckLogic`1.EndCheck()
   at NFluent.CheckMember`2.Verifies(Action`1 func)
Check.That(result).IsInstanceOf<OkObjectResult>()
    .Which
    .WhichMember(x => x.Value)
    .Verifies(x =>
    {
        x.IsNull();
    });

To Reproduce

public class MyEntity
{

}

public class MyExample
{
    public object Value { get; init; }
}

var value = new MyExample
{
    Value = new List<MyEntity>()
};

// Assert
Check.That(value).IsInstanceOf<MyExample>()
    .Which
    .WhichMember(x => x.Value)
    .Verifies(x =>
    {
        x.IsNull();
    });

Expected behavior I expected it toshow me explicitly what's the problem instead of a FormatException

Desktop (please complete the following information):

dupdob commented 1 year ago

hi thanks for reporting this. I have reproduced and fixed this issue. I will be releasing a fix in the coming days

dupdob commented 1 year ago

Hi I did publish V3.0.2.327-beta that contains the fix. Could you please test it and report ? if the problem is fixed, I will publish an official release.

Roxeez commented 1 year ago

Yes looks like it's fixed !