예제 #1
0
 /// <summary>
 /// Starts executing the instruction as an async task.
 /// </summary>
 /// <returns>A task which will complete with the instructions status.</returns>
 /// <param name="instruction">The instruction to execute.</param>
 /// <typeparam name="T">Return type of the test instruction.</typeparam>
 /// <inheritdoc cref="Docs.Inherit.CallerMemberWithExecutor{T}"/>
 public static Task <T> ToTask <T>(
     this ITestInstruction <T> instruction,
     TestInstructionExecutor executor,
     CancellationToken cancellationToken     = default,
     [CallerMemberName] string memberName    = "",
     [CallerFilePath] string sourceFilePath  = "",
     [CallerLineNumber] int sourceLineNumber = 0)
 => executor.RunInstruction(
     instruction.CreateState(),
     new SourceContext(nameof(ToTask), memberName, sourceFilePath, sourceLineNumber),
     cancellationToken);
 /// <summary>
 /// **Unity-only!**
 ///
 /// Start executing an explicitly created operation state.
 /// This can be used for e.g. logging the state periodically.
 /// </summary>
 /// <remarks>
 /// Be careful not to call this twice on the same state object: the consequences are undefined.
 /// </remarks>
 /// <returns>
 /// A yield instruction which will complete with the value of the test operation, once it has completed,
 /// or publish an error if the operation fails.
 /// </returns>
 /// <param name="state">Test operation state to start executing.</param>
 /// <typeparam name="T">Result type of the test operation.</typeparam>
 /// <inheritdoc cref="Docs.Inherit.YieldInstruction{T}"/>
 public static TestOperationYieldInstruction <T> ToYieldInstruction <T>(
     this ITestOperationState <T> state,
     TestInstructionExecutor executor,
     bool throwOnError = true,
     CancellationToken cancellationToken     = default,
     [CallerMemberName] string memberName    = "",
     [CallerFilePath] string sourceFilePath  = "",
     [CallerLineNumber] int sourceLineNumber = 0)
 => new TestOperationYieldInstruction <T>(executor.RunInstruction(
                                              state,
                                              new SourceContext(nameof(ToYieldInstruction), memberName, sourceFilePath, sourceLineNumber),
                                              cancellationToken),
                                          throwOnError);