public async Task GetLaunchStateAsyncTestAsync()
        {
            _target = GetGameLaunch(false);
            var action     = Substitute.For <IAction>();
            var gameLaunch = GetGameLaunch();

            _gameletClient.GetGameLaunchStateAsync(_launchName, action)
            .Returns(Task.FromResult(gameLaunch));

            GgpGrpc.Models.GameLaunch result = await _target.GetLaunchStateAsync(action);

            Assert.That(result, Is.EqualTo(gameLaunch));
        }
        public async Task DeleteLaunchSuccessAsync()
        {
            _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);

            DeleteLaunchResult result =
                await _target.DeleteLaunchAsync(_gameLaunchName, _cancelable, _action);

            Assert.That(result.IsSuccessful, Is.EqualTo(true));
            Assert.That(result.DeletedLaunch, Is.EqualTo(lastLaunch));
            await AssertActionNotRecordedAsync();
        }
        public async Task <DeleteLaunchResult> WaitUntilGameLaunchEndedAsync(
            string gameLaunchName, ICancelable task, IAction action)
        {
            GgpGrpc.Models.GameLaunch launch =
                await _gameletClient.GetGameLaunchStateAsync(gameLaunchName, action);

            int maxPollCount     = _pollingTimeoutMs / _pollDelayMs;
            int currentPollCount = 0;

            while (launch.GameLaunchState != GameLaunchState.GameLaunchEnded &&
                   ++currentPollCount <= maxPollCount)
            {
                task.ThrowIfCancellationRequested();
                await Task.Delay(_pollDelayMs);

                launch = await _gameletClient.GetGameLaunchStateAsync(gameLaunchName, action);
            }

            return(new DeleteLaunchResult(
                       launch, launch.GameLaunchState == GameLaunchState.GameLaunchEnded));
        }
示例#4
0
 public async Task <GgpGrpc.Models.GameLaunch> GetLaunchStateAsync(IAction action) =>
 await _gameletClient.GetGameLaunchStateAsync(LaunchName, action);