Ejemplo n.º 1
0
        public async Task TestCreate(
            Option <TestPlanRecorder> recorder,
            List <TestRecordType> moduleExecutionList,
            List <ICommand> commandList)
        {
            var g = new GroupCommand(commandList.ToArray());

            var token = new CancellationToken();

            await g.ExecuteAsync(token);

            this.AssertCommands(recorder, commandList, moduleExecutionList);
        }
Ejemplo n.º 2
0
        public async Task TestGroupCommandCancellation()
        {
            // Arrange
            var cts = new CancellationTokenSource();

            Mock <ICommand>[] commands =
            {
                this.MakeMockCommand("c1"),
                this.MakeMockCommand("c2", () => cts.Cancel()),
                this.MakeMockCommand("c3"),
            };
            ICommand groupCommand = new GroupCommand(
                commands.Select(m => m.Object).ToArray());

            // Act
            await groupCommand.ExecuteAsync(cts.Token);

            // Assert
            commands[0].Verify(m => m.ExecuteAsync(cts.Token), Times.Once());
            commands[1].Verify(m => m.ExecuteAsync(cts.Token), Times.Once());
            commands[2].Verify(m => m.ExecuteAsync(cts.Token), Times.Never());
        }