-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
If I'm extending the fluent asertions library with some extension methods, it would be nice to be able to iterate through the underlying IMonitor<> of the EventAssertions<> class.
A Pseudo example:
public class Fixture
{
public void Test()
{
//Arrange
var parameter = "Hello";
var sut = new MyService();
using var monitor = sut.Monitor();
//Act
sut.DoTheThing();
//Assert
monitor
.Should()
.NotRaiseMyEventWithParameter(parameter);
}
}
public static class MyExtension
{
public static IEventRecording NotRaiseMyEventWithParameter<T>(this EventAssertions<T> assertion, string parameter)
{
// Monitor not exposed in the EventAssertions!!!!!
var recordings = assertion.**Monitor**.GetRecordingFor(nameof(IMyInterface.MyEvent));
//Do the assertion here
}
}It is possible to make the extensions method directly on the monitor object, but then the Should() method is not invoked, and semantically it does not fit in with the fluent interface structure.
monitor.ShouldNotRaiseMyEventWithParameter(parameter).