Exemplo n.º 1
0
        public void SetUp()
        {
            _interactionRequest = new UnitTestInteractionRequest();

            _smtpTest = Substitute.For <ISmtpTest>();

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

            _profile = new ConversionProfile();
            var currentSettingsProvider = Substitute.For <ICurrentSettingsProvider>();

            currentSettingsProvider.SelectedProfile.Returns(_profile);

            var settings = new PdfCreatorSettings(null);

            _smtpAccounts = new ObservableCollection <SmtpAccount>();
            settings.ApplicationSettings.Accounts.SmtpAccounts = _smtpAccounts;
            currentSettingsProvider.Settings.Returns(settings);

            var commandLocator = Substitute.For <ICommandLocator>();

            commandLocator = Substitute.For <ICommandLocator>();
            commandLocator.GetMacroCommand().Returns(x => new MacroCommand(commandLocator));

            _addCommand = Substitute.For <ICommand>();
            commandLocator.GetCommand <SmtpAccountAddCommand>().Returns(_addCommand);
            _editCommand = Substitute.For <ICommand>();
            commandLocator.GetCommand <SmtpAccountEditCommand>().Returns(_editCommand);

            _tokenHelper   = new TokenHelper(new DesignTimeTranslationUpdater());
            _tokenReplacer = _tokenHelper.TokenReplacerWithPlaceHolders;

            _viewModel = new SmtpActionViewModel(_interactionRequest, _smtpTest, translationUpdater, currentSettingsProvider, commandLocator, _tokenHelper);
        }
Exemplo n.º 2
0
        public SmtpActionViewModel(IInteractionRequest interactionRequest, ISmtpTest smtpTest, ITranslationUpdater updater, ICurrentSettingsProvider currentSettingsProvider,
                                   ICommandLocator commandLocator, ITokenViewModelFactory tokenViewModelFactory, IDispatcher dispatcher) : base(updater, currentSettingsProvider, dispatcher)
        {
            _interactionRequest      = interactionRequest;
            _smtpTest                = smtpTest;
            _currentSettingsProvider = currentSettingsProvider;

            SetTokenViewModel(tokenViewModelFactory);

            if (currentSettingsProvider?.Settings != null)
            {
                _smtpAccounts    = currentSettingsProvider.Settings.ApplicationSettings.Accounts.SmtpAccounts;
                SmtpAccountsView = new ListCollectionView(_smtpAccounts);
                SmtpAccountsView.SortDescriptions.Add(new SortDescription(nameof(SmtpAccount.AccountInfo), ListSortDirection.Ascending));
            }

            AddAccountCommand = commandLocator.CreateMacroCommand()
                                .AddCommand <SmtpAccountAddCommand>()
                                .AddCommand(new DelegateCommand(o => SelectNewAccountInView()))
                                .Build();

            EditAccountCommand = commandLocator.CreateMacroCommand()
                                 .AddCommand <SmtpAccountEditCommand>()
                                 .AddCommand(new DelegateCommand(o => RefreshAccountsView()))
                                 .Build();

            EditMailTextCommand = new DelegateCommand(EditMailTextExecute);
            TestSmtpCommand     = new DelegateCommand(TextSmtpExecute);
        }
        public EmailSmtpActionViewModel(SmtpSettingsAndActionControlTranslation translation, IInteractionInvoker interactionInvoker, ISmtpTest smtpTest)
        {
            Translation         = translation;
            _interactionInvoker = interactionInvoker;
            _smtpTest           = smtpTest;

            EditMailTextCommand = new DelegateCommand(EditMailTextExecute);
            SetPasswordCommand  = new DelegateCommand(SetPasswordExecute);
            TestSmtpCommand     = new DelegateCommand(TextSmtpExecute);

            DisplayName = Translation.DisplayName;
            Description = Translation.Description;
        }
Exemplo n.º 4
0
        public EmailSmtpActionViewModel(ITranslator translator, IInteractionInvoker interactionInvoker, ISmtpTest smtpTest)
        {
            Translator          = translator;
            _interactionInvoker = interactionInvoker;
            _smtpTest           = smtpTest;

            EditMailTextCommand = new DelegateCommand(EditMailTextExecute);
            SetPasswordCommand  = new DelegateCommand(SetPasswordExecute);
            TestSmtpCommand     = new DelegateCommand(TextSmtpExecute);

            DisplayName = Translator.GetTranslation("SmtpEmailActionSettings", "DisplayName");
            Description = Translator.GetTranslation("SmtpEmailActionSettings", "Description");
        }
Exemplo n.º 5
0
        public SmtpActionViewModel(IInteractionRequest interactionRequest,
                                   ISmtpTest smtpTest,
                                   ITranslationUpdater updater,
                                   ICurrentSettingsProvider currentSettingsProvider,
                                   ICurrentSettings <Conversion.Settings.Accounts> accountsProvider,
                                   ICommandLocator commandLocator,
                                   ITokenViewModelFactory tokenViewModelFactory,
                                   IDispatcher dispatcher,
                                   IGpoSettings gpoSettings,
                                   ISelectFilesUserControlViewModelFactory selectFilesUserControlViewModelFactory)
            : base(updater, currentSettingsProvider, dispatcher)
        {
            _interactionRequest = interactionRequest;
            _smtpTest           = smtpTest;
            _accountsProvider   = accountsProvider;
            _commandLocator     = commandLocator;
            _gpoSettings        = gpoSettings;

            _smtpAccounts = _accountsProvider?.Settings.SmtpAccounts;

            if (_smtpAccounts != null)
            {
                SmtpAccountsView = new ListCollectionView(_smtpAccounts);
                SmtpAccountsView.SortDescriptions.Add(new SortDescription(nameof(SmtpAccount.AccountInfo), ListSortDirection.Ascending));
                SmtpAccountsView.CurrentChanged += (sender, args) => RaisePropertyChanged(nameof(ShowAutosaveRequiresPasswords));
            }

            SetTokenViewModel(tokenViewModelFactory);

            AdditionalAttachmentsViewModel = selectFilesUserControlViewModelFactory.Builder()
                                             .WithTitleGetter(() => Translation.MailAttachmentTitle)
                                             .WithFileListGetter(profile => profile.EmailSmtpSettings.AdditionalAttachments)
                                             .Build();

            AddAccountCommand = _commandLocator.CreateMacroCommand()
                                .AddCommand <SmtpAccountAddCommand>()
                                .AddCommand(new DelegateCommand(o => SelectNewAccountInView()))
                                .Build();

            EditAccountCommand = _commandLocator.CreateMacroCommand()
                                 .AddCommand <SmtpAccountEditCommand>()
                                 .AddCommand(new DelegateCommand(o => RefreshAccountsView()))
                                 .Build();

            EditMailTextCommand = new DelegateCommand(EditMailTextExecute);
            TestSmtpCommand     = new AsyncCommand(TestSmtpExecute);
        }
Exemplo n.º 6
0
        public SmtpActionViewModel(IInteractionRequest interactionRequest,
                                   ISmtpTest smtpTest,
                                   ITranslationUpdater updater,
                                   ICurrentSettingsProvider currentSettingsProvider,
                                   ICurrentSettings <Conversion.Settings.Accounts> accountsProvider,
                                   ICommandLocator commandLocator,
                                   ITokenViewModelFactory tokenViewModelFactory,
                                   IDispatcher dispatcher,
                                   IGpoSettings gpoSettings,
                                   IOpenFileInteractionHelper openFileInteractionHelper)
            : base(updater, currentSettingsProvider, dispatcher, openFileInteractionHelper)
        {
            _interactionRequest = interactionRequest;
            _smtpTest           = smtpTest;
            _accountsProvider   = accountsProvider;
            _commandLocator     = commandLocator;
            _gpoSettings        = gpoSettings;

            _smtpAccounts = _accountsProvider?.Settings.SmtpAccounts;

            if (_smtpAccounts != null)
            {
                SmtpAccountsView = new ListCollectionView(_smtpAccounts);
                SmtpAccountsView.SortDescriptions.Add(new SortDescription(nameof(SmtpAccount.AccountInfo), ListSortDirection.Ascending));
            }

            SetTokenViewModel(tokenViewModelFactory);

            AddAccountCommand = _commandLocator.CreateMacroCommand()
                                .AddCommand <SmtpAccountAddCommand>()
                                .AddCommand(new DelegateCommand(o => SelectNewAccountInView()))
                                .Build();

            EditAccountCommand = _commandLocator.CreateMacroCommand()
                                 .AddCommand <SmtpAccountEditCommand>()
                                 .AddCommand(new DelegateCommand(o => RefreshAccountsView()))
                                 .Build();

            EditMailTextCommand = new DelegateCommand(EditMailTextExecute);
            TestSmtpCommand     = new AsyncCommand(TestSmtpExecute);
        }