Esempio n. 1
0
        /// <summary>
        /// Verifies that a <see cref="Task" /> completes.
        /// </summary>
        /// <typeparam name="T">The <see cref="Task" /> type.</typeparam>
        /// <param name="task">The task to verify completes.</param>
        /// <param name="message">A message to display if the assertion fails. This message can
        /// be seen in the unit test results.</param>
        /// <remarks>
        /// <para>If this assertion fails you may have a deadlock or the task simply is taking too long
        /// to complete. If you need control over how long to wait before failing use one of the other overloads
        /// of this assertion.</para>
        /// <para>There are no overloads for working with <see cref="Task"/> collections, but you can easily
        /// make assertions by using the <see cref="M:Task.WhenAny"/> or <see cref="M:Task.WhenAll"/> methods.
        /// For example: <code>Assert(Task.WhenAll(tasks)).Complete();</code></para>
        /// </remarks>
        /// <exception cref="ArgumentNullException"><paramref name="task"/> (or it's value) is <c>null</c>.</exception>
        /// <exception cref="AssertionException">The <paramref name="task"/> did not complete in the alloted time.</exception>
        public static void Completes <T>(this ActualValue <T> task, string message)
            where T : Task
        {
            Argument.NotNull(task, nameof(task));
            Argument.NotNull(task.Value, nameof(task));

            task.Completes(DeadlockTimeout, message, null);
        }
Esempio n. 2
0
        /// <summary>
        /// Verifies that a <see cref="Task" /> completes.
        /// </summary>
        /// <typeparam name="T">The <see cref="Task" /> type.</typeparam>
        /// <param name="task">The task to verify completes.</param>
        /// <param name="millisecondsTimeout">The amount of time in milliseconds to wait for the <see cref="Task"/> to complete.</param>
        /// <remarks>
        /// <para>If this assertion fails you may have a deadlock or the task simply is taking too long
        /// to complete.</para>
        /// <para>There are no overloads for working with <see cref="Task"/> collections, but you can easily
        /// make assertions by using the <see cref="M:Task.WhenAny"/> or <see cref="M:Task.WhenAll"/> methods.
        /// For example: <code>Assert(Task.WhenAll(tasks)).Complete();</code></para>
        /// </remarks>
        /// <exception cref="ArgumentNullException"><paramref name="task"/> (or it's value) is <c>null</c>.</exception>
        /// <exception cref="AssertionException">The <paramref name="task"/> did not complete in the alloted time.</exception>
        public static void Completes <T>(this ActualValue <T> task, int millisecondsTimeout)
            where T : Task
        {
            Argument.NotNull(task, nameof(task));
            Argument.NotNull(task.Value, nameof(task));

            task.Completes(millisecondsTimeout, null);
        }