Пример #1
0
        /// <summary>
        /// Runs test with recording/replaying.
        /// </summary>
        /// <typeparam name="T">Test method return type.</typeparam>
        /// <param name="sut">Subject under test.</param>
        /// <param name="action">Action to be performed (typically test method)</param>
        /// <param name="done">Indicates that the test has finished.</param>
        /// <param name="openCycle">What should be called prior to <see cref="action"/>.</param>
        /// <param name="closeCycle">What should be called after <see cref="action"/>.</param>
        /// <param name="recorder">Instance of the recorder/player.</param>
        /// <param name="recordingFileName">Name of the recording file</param>
        /// <returns>Last result of the <see cref="action"/></returns>
        public static T Run <T>(this IVortexElement sut,
                                Func <T> action,
                                Func <bool> done,
                                Action openCycle         = null,
                                Action closeCycle        = null,
                                IRecorder recorder       = null,
                                string recordingFileName = null
                                )

        {
            T retVal = default(T);

            recorder?.Begin(recordingFileName);

            while (!done())
            {
                recorder?.Act();
                openCycle?.Invoke();
                retVal = action();
                closeCycle?.Invoke();
                recorder?.Act();
            }

            recorder?.Act();

            recorder?.End(recordingFileName);

            return(retVal);
        }