public void SetAccessTokenAndUserInfo_ArgumentUriIsRedirectUrl_ParseAccessTokenBeforeGetDropUserInfo() { var redirectUri = new Uri(_redirectUri + "/SomethingSomethingDarkSide"); _viewModel.FinishInteraction = () => { }; _dropboxService.GetDropUserInfo(Arg.Any <string>()).Returns(new DropboxUserInfo()); _viewModel.SetAccessTokenAndUserInfo(redirectUri); Received.InOrder(() => { var accessToken = _dropboxService.ParseAccessToken(redirectUri); _dropboxService.GetDropUserInfo(accessToken); }); }
public void SetAccessTokenAndUserInfo(Uri eUri) { // if url doesnt start with redirecturl that means that current url for recieveing token isn't reach yet if (eUri.ToString().StartsWith(_dropboxData.RedirectUri, StringComparison.OrdinalIgnoreCase) == false) { return; } try { var accessToken = _dropboxService.ParseAccessToken(eUri); var currentUserInfo = _dropboxService.GetDropUserInfo(accessToken); var newDropboxAccount = new DropboxAccount { AccessToken = currentUserInfo.AccessToken, AccountInfo = currentUserInfo.AccountInfo, AccountId = currentUserInfo.AccountId }; Interaction.DropboxAccount = newDropboxAccount; Interaction.Result = DropboxAccountInteractionResult.Success; } catch (ArgumentException) { Interaction.Result = DropboxAccountInteractionResult.AccesTokenParsingError; _logger.Warn("Cannot parse dropbox access token. New Account can't be created."); } catch (Exception e) { Interaction.Result = DropboxAccountInteractionResult.Error; _logger.Warn($"Unexpected exception during determination of dropbox token.{Environment.NewLine}{e}"); } FinishInteraction(); }
public void Setup() { var translationUpdater = new TranslationUpdater(new TranslationFactory(), new ThreadManager()); _translation = new DropboxTranslation(); _dropboxService = Substitute.For <IDropboxService>(); _dropboxService.ParseAccessToken(Arg.Any <Uri>()).Returns("AccessAccount"); _dropboxAppData = new DropboxAppData("DummieAppKeyForTest", _redirectUri); _viewModel = new DropboxAccountViewModel(_dropboxService, _dropboxAppData, translationUpdater); _accountInteraction = new DropboxAccountInteraction(); _viewModel.SetInteraction(_accountInteraction); }
public void SetAccessTokenAndUserInfo(Uri eUri) { // if url doesnt start with redirecturl that means that current url for recieveing token isn't reach yet if (eUri.ToString().StartsWith(_dropboxData.RedirectUri, StringComparison.OrdinalIgnoreCase) == false) { return; } try { _dropboxService.ParseAccessToken(eUri); var currentUserInfo = _dropboxService.GetDropUserInfo(); Interaction.AccessToken = currentUserInfo.AccessToken; Interaction.AccountInfo = currentUserInfo.AccountInfo; Interaction.AccountId = currentUserInfo.AccountId; RefreshBrowser = true; Interaction.Success = true; } catch (ArgumentException) { _logger.Info("Cannot parse access token."); } FinishInteraction(); }