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 override void Execute(object parameter) { var interaction = new DropboxAccountInteraction(); interaction.Result = DropboxAccountInteractionResult.UserCanceled; //required as default for [X]-Button _interactionInvoker.Invoke(interaction); switch (interaction.Result) { case DropboxAccountInteractionResult.Success: break; case DropboxAccountInteractionResult.AccesTokenParsingError: var parseErrorMessageInteraction = new MessageInteraction(Translation.DropboxAccountSeverResponseErrorMessage, Translation.AddDropboxAccount, MessageOptions.OK, MessageIcon.Warning); _interactionRequest.Raise(parseErrorMessageInteraction, IsDoneWithErrorCallback); return; case DropboxAccountInteractionResult.Error: var errorMessageInteraction = new MessageInteraction(Translation.DropboxAccountCreationErrorMessage, Translation.AddDropboxAccount, MessageOptions.OK, MessageIcon.Warning); _interactionRequest.Raise(errorMessageInteraction, IsDoneWithErrorCallback); return; case DropboxAccountInteractionResult.UserCanceled: default: IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel)); return; } var newAccount = interaction.DropboxAccount; var accountWithSameID = _droboxAccounts.FirstOrDefault(a => a.AccountId == newAccount.AccountId); if (accountWithSameID != null) { _droboxAccounts.Remove(accountWithSameID); } _droboxAccounts.Add(newAccount); IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success)); }