public void EditAccount_AccountsViewIsSorted()
        {
            var account1 = new HttpAccount()
            {
                Url = "1"
            };
            var editAccount = new HttpAccount()
            {
                Url = "0"
            };                                                 //for editing
            var account3 = new HttpAccount()
            {
                Url = "3"
            };

            _httpAccounts.Add(account3);
            _httpAccounts.Add(editAccount);
            _httpAccounts.Add(account1);
            _editCommand.Execute(Arg.Do <object>(o =>
            {
                var editAccountAsParameter = o as HttpAccount;
                editAccountAsParameter.Url = "2";
            }));

            _viewModel.EditAccountCommand.Execute(editAccount);

            _viewModel.HttpAccountsView.MoveCurrentToPosition(0);
            Assert.AreSame(account1, _viewModel.HttpAccountsView.CurrentItem);
            _viewModel.HttpAccountsView.MoveCurrentToPosition(1);
            Assert.AreSame(editAccount, _viewModel.HttpAccountsView.CurrentItem);
            _viewModel.HttpAccountsView.MoveCurrentToPosition(2);
            Assert.AreSame(account3, _viewModel.HttpAccountsView.CurrentItem);
        }
Example #2
0
        public void SetUp()
        {
            _accounts = new Accounts();
            _profile  = new ConversionProfile();

            _existingFtpAccount           = new FtpAccount();
            _existingFtpAccount.AccountId = "ftpAccountID";

            _existingSmtpAccount           = new SmtpAccount();
            _existingSmtpAccount.AccountId = "smtpAccountID";

            _existingHttpAccount           = new HttpAccount();
            _existingHttpAccount.AccountId = "httpAccountID";

            _existingDropboxAccount           = new DropboxAccount();
            _existingDropboxAccount.AccountId = "dropboxAccountID";

            _existingTimeServerAccount           = new TimeServerAccount();
            _existingTimeServerAccount.AccountId = "timeserverAccountID";

            _accounts.FtpAccounts.Add(_existingFtpAccount);
            _accounts.SmtpAccounts.Add(_existingSmtpAccount);
            _accounts.HttpAccounts.Add(_existingHttpAccount);
            _accounts.DropboxAccounts.Add(_existingDropboxAccount);
            _accounts.TimeServerAccounts.Add(_existingTimeServerAccount);
        }
Example #3
0
        public override void Execute(object parameter)
        {
            _currentAccount = parameter as HttpAccount;
            if (_currentAccount == null)
            {
                return;
            }

            _usedInProfilesList = Profiles.Where(p => p.HttpSettings.AccountId.Equals(_currentAccount.AccountId)).ToList();

            var title = Translation.RemoveHttpAccount;

            var messageSb = new StringBuilder();

            messageSb.AppendLine(_currentAccount.AccountInfo);
            messageSb.AppendLine(Translation.SureYouWantToDeleteAccount);

            if (_usedInProfilesList.Count > 0)
            {
                messageSb.AppendLine();
                messageSb.AppendLine(Translation.GetAccountIsUsedInFollowingMessage(_usedInProfilesList.Count));
                messageSb.AppendLine();
                foreach (var profile in _usedInProfilesList)
                {
                    messageSb.AppendLine(profile.Name);
                }
                messageSb.AppendLine();
                messageSb.AppendLine(Translation.GetHttppGetsDisabledMessage(_usedInProfilesList.Count));
            }
            var message     = messageSb.ToString();
            var icon        = _usedInProfilesList.Count > 0 ? MessageIcon.Warning : MessageIcon.Question;
            var interaction = new MessageInteraction(message, title, MessageOptions.YesNo, icon);

            _interactionRequest.Raise(interaction, DeleteAccountCallback);
        }
        public void AddAccount_AccountsListisSorted()
        {
            var account1 = new HttpAccount()
            {
                Url = "1"
            };
            var account2 = new HttpAccount()
            {
                Url = "2"
            };
            var account3 = new HttpAccount()
            {
                Url = "3"
            };

            _httpAccounts.Add(account3);
            _httpAccounts.Add(account1);
            _addCommand.Execute(Arg.Do <object>(o => _httpAccounts.Add(account2)));

            _viewModel.AddAccountCommand.Execute(null);

            _viewModel.HttpAccountsView.MoveCurrentToPosition(0);
            Assert.AreSame(account1, _viewModel.HttpAccountsView.CurrentItem);
            _viewModel.HttpAccountsView.MoveCurrentToPosition(1);
            Assert.AreSame(account2, _viewModel.HttpAccountsView.CurrentItem);
            _viewModel.HttpAccountsView.MoveCurrentToPosition(2);
            Assert.AreSame(account3, _viewModel.HttpAccountsView.CurrentItem);
        }
Example #5
0
        public override void Execute(object parameter)
        {
            var newAccount = new HttpAccount();

            newAccount.AccountId = Guid.NewGuid().ToString();

            var interaction = new HttpAccountInteraction(newAccount, Translation.AddHttpAccount);

            _interactionRequest.Raise(interaction, AddHttpAccountCallback);
        }
Example #6
0
        public void GetHttpAccount_HttpAccountIsNotEmpty_GetHttpAccountIsCalledWithEmptyString_ReturnsNull()
        {
            var httpAccountWithEmptyId = new HttpAccount();

            httpAccountWithEmptyId.AccountId = "";
            _accounts.HttpAccounts.Add(httpAccountWithEmptyId);
            _profile.HttpSettings.AccountId = "";

            var fetchedHttpAccount = _accounts.GetHttpAccount(_profile);

            Assert.IsNull(fetchedHttpAccount);
        }
        public void AddAccount_LatestAccountIsCurrentItemInView()
        {
            _httpAccounts.Add(new HttpAccount());

            var latestAccount = new HttpAccount();

            _addCommand.Execute(Arg.Do <object>(o => _httpAccounts.Add(latestAccount)));

            _viewModel.AddAccountCommand.Execute(null);

            Assert.AreSame(latestAccount, _viewModel.HttpAccountsView.CurrentItem, "Latest Account is not selected Item");
        }
        public void EditAccount_EditedAccountRemainsCurrentItemInView()
        {
            _httpAccounts.Add(new HttpAccount());
            var editAccount = new HttpAccount();

            _httpAccounts.Add(editAccount);
            _viewModel.HttpAccountsView.MoveCurrentTo(editAccount);
            _editCommand.Execute(Arg.Do <object>(o => editAccount.UserName = "******"));

            _viewModel.EditAccountCommand.Execute(null);

            Assert.AreSame(editAccount, _viewModel.HttpAccountsView.CurrentItem, "Latest Account is not selected Item");
        }
Example #9
0
        public void ChangeHttpAccountsCollection_TriggersRaiseCanExecuteChanged()
        {
            var newAccount = new HttpAccount();

            _httpAccounts.Add(newAccount);
            var wasRaised = false;

            _httpAccountRemoveCommand.CanExecuteChanged += (sender, args) => wasRaised = true;

            _httpAccounts.Remove(newAccount);

            Assert.IsTrue(wasRaised);
        }
Example #10
0
        protected override void HandleInteractionObjectChanged()
        {
            _httpAccount = Interaction.HttpAccount;

            RaisePropertyChanged(nameof(Url));
            RaisePropertyChanged(nameof(Username));
            RaisePropertyChanged(nameof(Password));
            AskForPasswordLater = string.IsNullOrWhiteSpace(Password);
            RaisePropertyChanged(nameof(AskForPasswordLater));
            HasBasicAuthentication = _httpAccount.IsBasicAuthentication;
            RaisePropertyChanged(nameof(HasBasicAuthentication));
            RaisePropertyChanged(nameof(Timeout));
            SaveCommand.RaiseCanExecuteChanged();
        }
        public void Setup()
        {
            _httpAccount = new HttpAccount()
            {
                AccountId = "HttpAccountID1"
            };

            var accounts = new Accounts();

            accounts.HttpAccounts.Add(_httpAccount);

            _job = new Job(null, new ConversionProfile(), accounts);
            _job.Profile.HttpSettings.AccountId = _httpAccount.AccountId;
        }
        public void Setup()
        {
            _account           = new HttpAccount();
            _account.AccountId = "TestID";

            var profile = new ConversionProfile();

            profile.HttpSettings.AccountId = _account.AccountId;

            var accounts = new Accounts();

            accounts.HttpAccounts.Add(_account);

            _job = new Job(null, profile, accounts);
        }
        public void AddAccount_UserAppliesInteraction_AccountIsCurrentItemInView()
        {
            var collectionView = CollectionViewSource.GetDefaultView(_httpAccounts);

            HttpAccount newAccount = new HttpAccount();

            _interactionRequest.RegisterInteractionHandler <HttpAccountInteraction>(i =>
            {
                i.Success  = true;
                newAccount = i.HttpAccount;
            });

            _httpAccountAddCommand.Execute(null);

            Assert.AreSame(collectionView.CurrentItem, newAccount);
        }
Example #14
0
        public void SetUp()
        {
            _interactionRequest = new UnitTestInteractionRequest();
            _translation        = new HttpTranslation();

            _httpAccounts = new ObservableCollection <HttpAccount>();

            _usedAccount           = new HttpAccount();
            _usedAccount.AccountId = nameof(_usedAccount);
            _usedAccount.Url       = "www.pdfforge1.org";
            _usedAccount.UserName  = "******";
            _httpAccounts.Add(_usedAccount);

            _unusedAccount           = new HttpAccount();
            _unusedAccount.AccountId = nameof(_unusedAccount);
            _unusedAccount.Url       = "www.pdfforge2.org";
            _unusedAccount.UserName  = "******";
            _httpAccounts.Add(_unusedAccount);

            _profiles = new ObservableCollection <ConversionProfile>();

            _profileWithHttpAccountEnabled      = new ConversionProfile();
            _profileWithHttpAccountEnabled.Name = nameof(_profileWithHttpAccountEnabled);
            _profileWithHttpAccountEnabled.HttpSettings.Enabled   = true;
            _profileWithHttpAccountEnabled.HttpSettings.AccountId = _usedAccount.AccountId;
            _profiles.Add(_profileWithHttpAccountEnabled);

            _profileWithHttpAccountDisabled      = new ConversionProfile();
            _profileWithHttpAccountDisabled.Name = nameof(_profileWithHttpAccountDisabled);
            _profileWithHttpAccountDisabled.HttpSettings.Enabled   = false;
            _profileWithHttpAccountDisabled.HttpSettings.AccountId = _usedAccount.AccountId;
            _profiles.Add(_profileWithHttpAccountDisabled);

            var settings = new PdfCreatorSettings(null);

            settings.ApplicationSettings.Accounts.HttpAccounts = _httpAccounts;
            settings.ConversionProfiles = _profiles;
            var currentSettingsProvider = Substitute.For <ICurrentSettingsProvider>();

            currentSettingsProvider.Settings.Returns(settings);
            currentSettingsProvider.Profiles.Returns(_profiles);

            var translationUpdater = new TranslationUpdater(new TranslationFactory(), new ThreadManager());

            _httpAccountRemoveCommand = new HttpAccountRemoveCommand(_interactionRequest, currentSettingsProvider, translationUpdater);
        }
Example #15
0
        public void SetUp()
        {
            var translationUpdater = new TranslationUpdater(new TranslationFactory(null), new ThreadManager());

            _httpAccount = new HttpAccount
            {
                AccountId             = new Guid().ToString(),
                Url                   = "www.pdfforge.org",
                UserName              = "******",
                Password              = "******",
                IsBasicAuthentication = true
            };

            _httpAccountInteraction = new HttpAccountInteraction(_httpAccount, "HttpAccountTestTitle");

            _viewModel = new HttpAccountViewModel(translationUpdater);
            _viewModel.SetPasswordAction = s => { };
        }
Example #16
0
        public void SetUp()
        {
            _accounts = new Accounts();

            _httpAccount                       = new HttpAccount();
            _httpAccount.AccountId             = "1";
            _httpAccount.Url                   = "http://http_URL";
            _httpAccount.IsBasicAuthentication = true;
            _httpAccount.UserName              = "******";
            _httpAccount.Password              = "******";

            _accounts.HttpAccounts.Add(_httpAccount);

            _profile = new ConversionProfile();
            _profile.HttpSettings.AccountId = _httpAccount.AccountId;
            _profile.HttpSettings.Enabled   = true;

            _httpAction = new HttpAction();
        }
        public override void Execute(object parameter)
        {
            _currentAccount = parameter as HttpAccount;
            if (_currentAccount == null)
            {
                return;
            }

            var httpAccounts = _currentSettingsProvider.Settings.ApplicationSettings.Accounts.HttpAccounts;

            if (!httpAccounts.Contains(_currentAccount))
            {
                return;
            }

            var interaction = new HttpAccountInteraction(_currentAccount.Copy(), Translation.EditHttpAccount);

            _interactionRequest.Raise(interaction, UpdateHttpAccountsCallback);
        }
        public void AddAccount_UserAppliesInteraction_AccountGetsAdded()
        {
            var newAccount = new HttpAccount();

            newAccount.Url      = "New Url";
            newAccount.Password = "******";
            newAccount.UserName = "******";

            _interactionRequest.RegisterInteractionHandler <HttpAccountInteraction>(i =>
            {
                i.Success     = true;
                i.HttpAccount = newAccount;
            });

            _httpAccountAddCommand.Execute(null);

            Assert.AreEqual(1, _httpAccounts.Count);
            Assert.AreSame(newAccount, _httpAccounts.FirstOrDefault());
        }
Example #19
0
        public void SetUp()
        {
            _interactionRequest = new UnitTestInteractionRequest();
            _translation        = new HttpTranslation();
            _currentHttpAccount = new HttpAccount()
            {
                UserName = "******"
            };
            _httpAccounts = new ObservableCollection <HttpAccount>();
            _httpAccounts.Add(_currentHttpAccount);
            var settings = new PdfCreatorSettings();

            settings.ApplicationSettings.Accounts.HttpAccounts = _httpAccounts;
            _accountsProvider = Substitute.For <ICurrentSettings <Accounts> >();
            _accountsProvider.Settings.Returns(settings.ApplicationSettings.Accounts);

            var translationUpdater = new TranslationUpdater(new TranslationFactory(), new ThreadManager());

            _httpAccountEditCommand = new HttpAccountEditCommand(_interactionRequest, _accountsProvider, translationUpdater);
        }
        public void SetUp()
        {
            _accounts = new Accounts();

            _httpAccount           = new HttpAccount();
            _httpAccount.AccountId = "httpAccountId";
            _httpAccount.Password  = "******";

            _ftpAccount           = new FtpAccount();
            _ftpAccount.AccountId = "ftpAccountId";
            _ftpAccount.Password  = "******";

            _smtpAccount           = new SmtpAccount();
            _smtpAccount.AccountId = "smtpAccountId";
            _smtpAccount.Password  = "******";

            _accounts.HttpAccounts.Add(_httpAccount);
            _accounts.FtpAccounts.Add(_ftpAccount);
            _accounts.SmtpAccounts.Add(_smtpAccount);

            _profile = new ConversionProfile();
        }
Example #21
0
        public void SetUp()
        {
            _account = new HttpAccount();

            _account.Url = GetUrl();
            _account.IsBasicAuthentication = false;
            _account.AccountId             = "1";

            var bootstrapper = new IntegrationTestBootstrapper();
            var container    = bootstrapper.ConfigureContainer();

            _th = container.GetInstance <TestHelper>();
            _th.InitTempFolder("HttpRequestTest");

            _th.GenerateGsJob_WithSetOutput(TestFile.PDFCreatorTestpage_GS9_19_PDF);

            _th.Job.Accounts.HttpAccounts.Add(_account);

            _th.Job.Profile.HttpSettings.Enabled   = true;
            _th.Job.Profile.HttpSettings.AccountId = _account.AccountId;

            _httpAction = new HttpAction();
        }
 public void SaveCanExecute_AccountIsNull_TimeoutIsDefaultValue()
 {
     _httpAccount = null;
     Assert.AreEqual(60, _viewModel.Timeout);
 }
Example #23
0
 public HttpAccountInteraction(HttpAccount httpAccount, string title)
 {
     HttpAccount = httpAccount;
     Title       = title;
 }