/// <summary> /// Asserts that an object has raised a particular event at least once. /// </summary> /// <param name="eventName"> /// The name of the event that should have been raised. /// </param> /// <param name="because"> /// A formatted phrase explaining why the assertion should be satisfied. If the phrase does not /// start with the word <i>because</i>, it is prepended to the message. /// </param> /// <param name="becauseArgs"> /// Zero or more values to use for filling in any <see cref="string.Format(string,object[])"/> compatible placeholders. /// </param> /// <remarks> /// You must call <see cref="AssertionExtensions.Monitor"/> on the same object prior to this call so that Fluent Assertions can /// subscribe for the events of the object. /// </remarks> public IEventRecorder Raise(string eventName, string because = "", params object[] becauseArgs) { IEventRecorder eventRecorder = monitor.GetEventRecorder(eventName); if (!eventRecorder.Any()) { Execute.Assertion .BecauseOf(because, becauseArgs) .FailWith("Expected object {0} to raise event {1}{reason}, but it did not.", monitor.Subject, eventName); } return(eventRecorder); }