-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Description
Monitor OccurredEvents ordering seems to be random and does not reflect the order in which events were raised.
Complete minimal example reproducing the issue
public class MyClass
{
public event EventHandler FirstEvent;
public event EventHandler SecondEvent;
public event EventHandler ThirdEvent;
public void RaiseFirstEvent()
{
FirstEvent?.Invoke(this, EventArgs.Empty);
}
public void RaiseSecondEvent()
{
SecondEvent?.Invoke(this, EventArgs.Empty);
}
public void RaiseThirdEvent()
{
ThirdEvent?.Invoke(this, EventArgs.Empty);
}
}
[Test]
public void Test()
{
var myObj = new MyClass();
using (var monitor = myObj.Monitor())
{
myObj.RaiseFirstEvent();
myObj.RaiseSecondEvent();
myObj.RaiseThirdEvent();
monitor.OccurredEvents[0].EventName.Should().Be(nameof(myObj.FirstEvent));
monitor.OccurredEvents[1].EventName.Should().Be(nameof(myObj.SecondEvent));
monitor.OccurredEvents[2].EventName.Should().Be(nameof(myObj.ThirdEvent));
}
}Expected behavior:
OccurredEvents ordering should be the same as the raised events
Actual behavior:
OccurredEvents ordering is random, and changes with every run
Versions
I'm using FluentAssertions 5.6.0.
.NET Framework version 4.8.