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

Fields/Properties based checks are undefined for empty types. #288

Closed dupdob closed 5 years ago

dupdob commented 5 years ago

Fields/property based checks are not applied to empty types, i.e. type without any property nor field. Those are simply ignored.

Expected Behavior

I expect the check to be done on the instance itself, since it has no members. Or to document current behaviour as target, or to make this somehow controllable.

Current Behavior

Instances of empty classes are not considered for any checks.

Possible Solution

Either: 1) document existing behaviour 2) fix behaviour to cater for empty instances 3) add an option to choose between behaviour

Code that reproduce the issue

....
            Check.ThatCode(() => 
            Check.That(new {child = new EmptyChild()}).Considering().All.Properties.IsEqualTo(new {child = new EmptyAncestor()})
            ).IsAFailingCheckWithMessage("");
...
        private class EmptyAncestor
        {
            public override string ToString()
            {
                return string.Empty;
            }
        }

        private class EmptyChild : EmptyAncestor
        {}
...