Пример #1
0
        /// <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 as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <paramref name="because"/>.
        /// </param>
        public IEventRecording Raise(string eventName, string because = "", params object[] becauseArgs)
        {
            IEventRecording recording = monitor.GetRecordingFor(eventName);

            if (!recording.Any())
            {
                Execute.Assertion
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected object {0} to raise event {1}{reason}, but it did not.", monitor.Subject, eventName);
            }

            return(recording);
        }