public virtual ITestAccountClientFactory GetTestAccountClientFactory() { if (_testAccountClientFactory == null) { _testAccountClientFactory = new TestAccountClient.Factory(); } return(_testAccountClientFactory); }
public void SetUp() { _targetPath = "/any/old/target/path"; var fileSystem = new MockFileSystem(); fileSystem.AddFile(_targetPath, new MockFileData("")); _outputDirectory = Path.GetTempPath(); _project = Substitute.For <IAsyncProject>(); _project.GetTargetPathAsync().Returns(_targetPath); _project.GetTargetDirectoryAsync().Returns(Path.GetDirectoryName(_targetPath)); _project.GetTargetFileNameAsync().Returns(Path.GetFileName(_targetPath)); _project.GetOutputDirectoryAsync().Returns(_outputDirectory); _project.GetAbsoluteRootPathAsync().Returns(_testProjectDir); _project.GetApplicationAsync().Returns(_testApplicationName); _project.GetQueryParamsAsync().Returns(_customQueryParams); var sdkConfigFactory = Substitute.For <SdkConfig.Factory>(); var sdkConfig = new SdkConfig(); sdkConfig.OrganizationId = _testOrganizationId; sdkConfig.ProjectId = _testProjectId; sdkConfigFactory.LoadOrDefault().Returns(sdkConfig); _gameletClient = Substitute.For <IGameletClient>(); var gameletClientFactory = Substitute.For <GameletClient.Factory>(); gameletClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(_gameletClient); var remoteCommand = Substitute.For <IRemoteCommand>(); _remoteDeploy = Substitute.For <IRemoteDeploy>(); _dialogUtil = Substitute.For <IDialogUtil>(); var credentialManager = Substitute.For <YetiCommon.ICredentialManager>(); credentialManager.LoadAccount().Returns(_testAccount); var cancelableTaskFactory = FakeCancelableTask.CreateFactory(new JoinableTaskContext(), false); _applicationClient = Substitute.For <IApplicationClient>(); var application = new Application { Id = _testApplicationId, Name = _testApplicationName }; _applicationClient.LoadByNameOrIdAsync(_testApplicationName) .Returns(Task.FromResult(application)); var applicationClientFactory = Substitute.For <ApplicationClient.Factory>(); applicationClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(_applicationClient); _testAccountClientFactory = Substitute.For <TestAccountClient.Factory>(); var testAccount = new TestAccount() { Name = $"organizations/{_testOrganizationId}" + $"/projects/{_testProjectId}/testAccounts/{_testTestAccountId}" }; var testAccountClient = Substitute.For <ITestAccountClient>(); testAccountClient .LoadByIdOrGamerTagAsync(_testOrganizationId, _testProjectId, _testTestAccountId) .Returns(new List <TestAccount> { testAccount }); _testAccountClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(testAccountClient); Substitute.For <IExtensionOptions>(); _yetiVsiService = Substitute.For <IYetiVSIService>(); var options = Substitute.For <IExtensionOptions>(); var debuggerOptions = new YetiVSI.DebuggerOptions.DebuggerOptions(); _yetiVsiService.DebuggerOptions.Returns(debuggerOptions); options.LaunchGameApiFlow.Returns(LaunchGameApiFlow.DISABLED); _yetiVsiService.Options.Returns(options); _metrics = Substitute.For <IMetrics>(); _metrics.NewDebugSessionId().Returns(_testDebugSessionId); var debugMetrics = new DebugSessionMetrics(_metrics); var cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, new CloudConnection(), new GgpSDKUtil()); _gameletSelector = Substitute.For <IGameletSelector>(); _gameletSelectorFactory = Substitute.For <IGameletSelectorFactory>(); _gameletSelectorFactory.Create(Arg.Any <bool>(), Arg.Any <ActionRecorder>()) .Returns(_gameletSelector); var serializer = new JsonUtil(); _launchCommandFormatter = new ChromeClientLaunchCommandFormatter(serializer); _paramsFactory = new YetiVSI.DebugEngine.DebugEngine.Params.Factory(serializer); _gameLauncher = Substitute.For <IGameLauncher>(); _gameLauncher.LaunchGameApiEnabled.Returns(false); _gameLaunch = Substitute.For <IVsiGameLaunch>(); _gameLaunch.LaunchName.Returns("launch_name"); _ggpDebugQueryTarget = new GgpDebugQueryTarget(fileSystem, sdkConfigFactory, gameletClientFactory, applicationClientFactory, cancelableTaskFactory, _dialogUtil, _remoteDeploy, debugMetrics, credentialManager, _testAccountClientFactory, _gameletSelectorFactory, cloudRunner, _sdkVersion, _launchCommandFormatter, _paramsFactory, _yetiVsiService, _gameLauncher); }