public async Task DeleteLaunchCanceledAsync()
        {
            _gameletClient.DeleteGameLaunchAsync(_gameLaunchName, _action).Returns(
                GetLaunch(_gameLaunchName, GameLaunchState.RunningGame));
            GgpGrpc.Models.GameLaunch lastLaunch =
                GetLaunch(_gameLaunchName, GameLaunchState.GameLaunchEnded,
                          EndReason.GameExitedWithSuccessfulCode);
            _gameletClient.GetGameLaunchStateAsync(_gameLaunchName, _action).Returns(
                GetLaunch(_gameLaunchName, GameLaunchState.RunningGame),
                GetLaunch(_gameLaunchName, GameLaunchState.RunningGame), lastLaunch);
            _cancelable.When(c => c.ThrowIfCancellationRequested())
            .Do(callInfo => throw new TaskAbortedException(new Exception()));

            Assert.ThrowsAsync <TaskAbortedException>(
                () => _target.DeleteLaunchAsync(_gameLaunchName, _cancelable, _action));
            await AssertActionNotRecordedAsync();
        }
Ejemplo n.º 2
0
        public Task <int> RunToExitAsync()
        {
            if (_expectedOutput != null)
            {
                foreach (string message in _expectedOutput)
                {
                    OutputDataReceived?.Invoke(null, new TextReceivedEventArgs(message));
                    if (_cancels)
                    {
                        _cancelable.When(t => t.ThrowIfCancellationRequested())
                        .Throw <OperationCanceledException>();
                        break;
                    }
                }
            }

            if (_errorMessage != null)
            {
                ErrorDataReceived?.Invoke(null, new TextReceivedEventArgs(_errorMessage));
            }

            return(Task.FromResult(0));
        }