public async Task TestParallelGroupCommandUndo() { // Arrange TimeSpan delay = TimeSpan.FromSeconds(5); var cts = new CancellationTokenSource(); Mock <ICommand>[] commands = { this.MakeDelayingCommand("c1", delay), this.MakeDelayingCommand("c2", delay), this.MakeDelayingCommand("c3", delay), }; ICommand groupCommand = new ParallelGroupCommand( commands.Select(m => m.Object).ToArray()); // Act Task executeTask = groupCommand.UndoAsync(cts.Token); Task waitTask = Task.Delay(delay.Add(TimeSpan.FromSeconds(1))); Task completedTask = await Task.WhenAny(executeTask, waitTask); // Assert Assert.Equal(completedTask, executeTask); commands[0].Verify(m => m.UndoAsync(cts.Token), Times.Once()); commands[1].Verify(m => m.UndoAsync(cts.Token), Times.Once()); commands[2].Verify(m => m.UndoAsync(cts.Token), Times.Once()); }
public async Task TestUndoAsync( Option <TestPlanRecorder> recorder, List <TestRecordType> moduleExecutionList, List <ICommand> commandList) { ICommand g = new ParallelGroupCommand(commandList.ToArray()); var token = default(CancellationToken); await g.UndoAsync(token); this.AssertUndo(recorder, commandList, moduleExecutionList); }