Skip to content

RaisePropertyChangeFor produces unhelpful failure message #919

@shuebner

Description

@shuebner

Description

RaisePropertyChangeFor produces unhelpful failure message.

Complete minimal example reproducing the issue

public class Bar
{
    public event PropertyChangedEventHandler PropertyChanged;

    public string Value { get; set; }

    public string OtherValue { get; set; }

    public void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}
var bar = new Bar();
using (var monitor = bar.Monitor())
{
    bar.OnPropertyChanged(nameof(Bar.OtherValue));
    monitor.Should().RaisePropertyChangeFor(b => b.Value);
}

Expected behavior:

Clear failure message including the property name of the PropertyChangedEvent that was expected, but not raised.
Maybe also a list of PropertyChangedEvents that were raised.

Actual behavior:

Unreadable message without the property name:

Expected at least one event with arguments matching (args.PropertyName == value(FluentAssertions.Events.EventAssertions`1+<>c__DisplayClass5_0[MSTestFluentAssertions.UnitTest1+Bar]).propertyName), but found none.

Versions

FluentAssertions 5.4.2.0
.NET Framework 4.6.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions