public SelectTestInstruction(
     ITestInstruction <T1> first,
     Func <T1, T2> selector,
     SourceContext sourceContext)
     : base(() => new SelectOperationState <T1, T2>(first.CreateState(), selector, sourceContext))
 {
 }
 public State(
     ITestInstruction <T1> first,
     ITestInstruction <T2> second,
     SourceContext sourceContext)
     : base(sourceContext)
 {
     this.first  = first.CreateState();
     this.second = second.CreateState();
 }
 public State(
     ITestInstruction <T1> first,
     Func <T1, ITestInstruction <T2> > selector,
     SourceContext sourceContext)
     : base(sourceContext)
 {
     this.first        = first.CreateState();
     this.continuation = new Continuation <T1, T2>(firstResult => selector(firstResult).CreateState());
 }
Ejemplo n.º 4
0
 public State(
     ITestInstruction <T1> first,
     Func <T1, ITestInstruction <T2> > selector,
     SourceContext sourceContext)
     : base(sourceContext)
 {
     this.first    = first.CreateState();
     this.selector = selector;
 }
Ejemplo n.º 5
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!**
 ///
 /// Starts executing an instruction, and returns a yield instruction which can be awaited,
 /// using <c>yield return</c> in a Unity coroutine.
 /// </summary>
 /// <returns>Yield instruction for Unity, which will complete when the instruction has completed.</returns>
 /// <param name="instruction">Instruction to execute.</param>
 /// <typeparam name="T">Return type of the test instruction to start.</typeparam>
 /// <inheritdoc cref="Docs.Inherit.YieldInstruction{T}"/>
 public static TestOperationYieldInstruction <T> ToYieldInstruction <T>(
     this ITestInstruction <T> instruction,
     TestInstructionExecutor executor,
     bool throwOnError = true,
     CancellationToken cancellationToken     = default,
     [CallerMemberName] string memberName    = "",
     [CallerFilePath] string sourceFilePath  = "",
     [CallerLineNumber] int sourceLineNumber = 0)
 => new TestOperationYieldInstruction <T>(executor.RunInstruction(
                                              instruction.CreateState(),
                                              new SourceContext(nameof(ToYieldInstruction), memberName, sourceFilePath, sourceLineNumber),
                                              cancellationToken),
                                          throwOnError);
Ejemplo n.º 7
0
 public BoxedTestInstruction(ITestInstruction <T> instruction)
     : base(() => new BoxedOperationState <T>(instruction.CreateState()))
 {
 }
 public BoxedTestInstruction(ITestInstruction <T> instruction)
     : base(() => new BoxedOperationState <T, object>(
                instruction.CreateState(),
                value => (object)value))
 {
 }