public async Task WaitForGameLaunchEndedAndRecordTestAsync(EndReason?reason, bool throws) { _target = GetGameLaunch(false); var action = Substitute.For <IAction>(); DeveloperLogEvent devEvent = SetupUpdateEvent(action); action.RecordAsync(Arg.Any <Task>()).Returns(callInfo => callInfo.Arg <Task>()); _actionRecorder.CreateToolAction(ActionType.GameLaunchWaitForEnd).Returns(action); var endResult = new DeleteLaunchResult( GetGameLaunch(GameLaunchState.GameLaunchEnded, reason), true); _gameLaunchBeHelper .WaitUntilGameLaunchEndedAsync(_launchName, Arg.Any <ICancelable>(), action) .Returns(Task.FromResult(endResult)); if (throws) { Assert.ThrowsAsync <GameLaunchFailError>( async() => await _target.WaitForGameLaunchEndedAndRecordAsync()); } else { await _target.WaitForGameLaunchEndedAndRecordAsync(); } Assert.That(devEvent.GameLaunchData.LaunchId, Is.EqualTo(_launchId)); Assert.That(devEvent.GameLaunchData.EndReason, Is.EqualTo((int?)reason)); await action.Received(1).RecordAsync(Arg.Any <Task>()); }
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 void LaunchOnWebTest() { _target = GetGameLaunch(false); const string url = "https://test"; const string workingDir = "C:/dir"; _params.Endpoint = StadiaEndpoint.PlayerEndpoint; _launcher.MakePlayerClientUrl(Arg.Any <string>()).Returns(url); _target.LaunchInChrome(_launcher, workingDir); _launcher.Received(1).MakePlayerClientUrl(_launchId); _launcher.DidNotReceive().MakeTestClientUrl(_launchName); _launcher.Received(1).LaunchGame(url, workingDir); }
public void WaitUntilGameLaunchedTest(GameLaunchState[] launchStates, int[] stateRepeat, bool launchResult, EndReason?endReason = null, bool isDevResumeOfferEnabled = false) { _target = GetGameLaunch(isDevResumeOfferEnabled); Func <ICancelable, Task> currentTask = null; var action = Substitute.For <IAction>(); DeveloperLogEvent devEvent = SetupUpdateEvent(action); _actionRecorder.CreateToolAction(ActionType.GameLaunchWaitForStart).Returns(action); var cancelable = Substitute.For <ICancelableTask>(); action.Record(Arg.Any <Func <bool> >()).Returns(callInfo => { new JoinableTaskFactory(new JoinableTaskContext()).Run( () => currentTask(new NothingToCancel())); return(true); }); _cancelableTaskFactory.Create( TaskMessages.LaunchingGame, Arg.Any <Func <ICancelable, Task> >()).Returns(callInfo => { currentTask = callInfo.Arg <Func <ICancelable, Task> >(); return(cancelable); }); List <GameLaunchState> statusSequence = launchStates .Select((state, i) => Enumerable.Repeat(state, stateRepeat[i])) .SelectMany(states => states).ToList(); Task <GgpGrpc.Models.GameLaunch>[] launches = statusSequence.Select( (state, i) => Task.FromResult(GetGameLaunch(state, i == statusSequence.Count - 1 ? endReason : null))).ToArray(); _gameletClient.GetGameLaunchStateAsync(_launchName, action) .Returns(launches[0], launches.Skip(1).ToArray()); bool launched = _target.WaitUntilGameLaunched(); Assert.That(launched, Is.EqualTo(launchResult)); if (!launchResult) { _dialogUtil.Received(1).ShowError(Arg.Any <string>()); } Assert.That(devEvent.GameLaunchData.LaunchId, Is.EqualTo(_launchId)); Assert.That(devEvent.GameLaunchData.EndReason, Is.EqualTo((int?)endReason)); action.Received(1).Record(Arg.Any <Func <bool> >()); }
public void IdentifiersTest() { _target = GetGameLaunch(false); Assert.That(_target.LaunchName, Is.EqualTo(_launchName)); Assert.That(_target.LaunchId, Is.EqualTo(_launchId)); }