public void WithSmtp_ExtractsSmtpAccount()
        {
            var account = new SmtpAccount
            {
                Address  = "*****@*****.**",
                Password = "******",
                Port     = 123,
                Server   = "smtp.local",
                Ssl      = true,
                UserName = "******"
            };

            var data = CreateV6Storage();

            StoreSmtpAccount(data, 0, account);

            var upgrader = new CreatorSettingsUpgrader(data);

            upgrader.Upgrade(7);

            var settings = CreateSettings(data);

            Assert.IsNotEmpty(settings.ApplicationSettings.Accounts.SmtpAccounts);
            Assert.IsNotNull(settings.ConversionProfiles[0].EmailSmtpSettings.AccountId);
            Assert.IsNotEmpty(settings.ConversionProfiles[0].EmailSmtpSettings.AccountId);
            AssertSmtpAccountsAreEqual(account, settings.ApplicationSettings.Accounts.SmtpAccounts[0]);
        }
示例#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);
        }
        public void Setup()
        {
            _smtpTestAccount           = new SmtpAccount();
            _smtpTestAccount.AccountId = "SmtpTestAccountId";

            _profile = new ConversionProfile();
            //Attention
            _profile.EmailSmtpSettings.AccountId = _smtpTestAccount.AccountId;
            //The AccountAssosiation is mocked below. The _smtpTestAccount is always used.

            _accounts = new Accounts();
            _accounts.SmtpAccounts.Add(_smtpTestAccount);

            _interactionRequest = new UnitTestInteractionRequest();
            _interactionInvoker = Substitute.For <IInteractionInvoker>();
            _interactionInvoker.Invoke(Arg.Do <PasswordOverlayInteraction>(i => i.Result = PasswordResult.StorePassword));

            _interactionRequest.RegisterInteractionHandler <PasswordOverlayInteraction>(interaction => interaction.Result = PasswordResult.StorePassword);

            _file       = Substitute.For <IFile>();
            _path       = Substitute.For <IPath>();
            _smtpAction = Substitute.For <ISmtpMailAction>();
            _smtpAction.Check(Arg.Any <ConversionProfile>(), _accounts, Arg.Any <CheckLevel>()).Returns(x => new ActionResult());
            _smtpAction.ProcessJob(Arg.Any <Job>()).Returns(x => new ActionResult());
            //_smtpAction.GetSmtpAccount(_profile, _accounts).Returns(_smtpTestAccount);

            _mailSignatureHelper = Substitute.For <IMailSignatureHelper>();
            _mailSignatureHelper.ComposeMailSignature().Returns(_mailSignature);

            _tokenReplacer        = new TokenReplacer();
            _tokenReplacerFactory = Substitute.For <ITokenReplacerFactory>();
            _tokenReplacerFactory.BuildTokenReplacerWithOutputfiles(Arg.Any <Job>()).Returns(_tokenReplacer);

            _translation = new SmtpTranslation();
        }
示例#4
0
        public void SetUp()
        {
            _smtpTestAccount           = new SmtpAccount();
            _smtpTestAccount.AccountId = "TestAccountId";
            _smtpTestAccount.Address   = "*****@*****.**";
            _smtpTestAccount.UserName  = "******";
            _smtpTestAccount.Server    = "randomHost";
            _smtpTestAccount.Port      = 25;
            _smtpTestAccount.Ssl       = false;
            _smtpTestAccount.Password  = "******";

            _profile = new ConversionProfile();
            _profile.EmailSmtpSettings.Enabled      = true;
            _profile.EmailSmtpSettings.AccountId    = _smtpTestAccount.AccountId;
            _profile.EmailSmtpSettings.Recipients   = "*****@*****.**";
            _profile.EmailSmtpSettings.Subject      = "";
            _profile.EmailSmtpSettings.Content      = "";
            _profile.EmailSmtpSettings.AddSignature = false;

            _accounts = new Accounts();
            _accounts.SmtpAccounts.Add(_smtpTestAccount);

            _mailSignatureHelper = Substitute.For <IMailSignatureHelper>();
            _mailSignatureHelper.ComposeMailSignature().Returns("Signature!");

            _smtpAction = new SmtpMailAction(_mailSignatureHelper);
        }
 private void AssertSmtpAccountsAreEqual(SmtpAccount first, SmtpAccount second)
 {
     Assert.AreEqual(first.UserName, second.UserName);
     Assert.AreEqual(first.Password, second.Password);
     Assert.AreEqual(first.Server, second.Server);
     Assert.AreEqual(first.Port, second.Port);
 }
示例#6
0
        public void AddAccount_AccountsListisSorted()
        {
            var account1 = new SmtpAccount()
            {
                Address = "1"
            };
            var account2 = new SmtpAccount()
            {
                Address = "2"
            };
            var account3 = new SmtpAccount()
            {
                Address = "3"
            };

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

            _viewModel.AddAccountCommand.Execute(null);

            _viewModel.SmtpAccountsView.MoveCurrentToPosition(0);
            Assert.AreSame(account1, _viewModel.SmtpAccountsView.CurrentItem);
            _viewModel.SmtpAccountsView.MoveCurrentToPosition(1);
            Assert.AreSame(account2, _viewModel.SmtpAccountsView.CurrentItem);
            _viewModel.SmtpAccountsView.MoveCurrentToPosition(2);
            Assert.AreSame(account3, _viewModel.SmtpAccountsView.CurrentItem);
        }
示例#7
0
        public void EditAccount_AccountsViewIsSorted()
        {
            var account1 = new SmtpAccount()
            {
                Address = "1"
            };
            var editAccount = new SmtpAccount()
            {
                Address = "0"
            };                                                     //for editing
            var account3 = new SmtpAccount()
            {
                Address = "3"
            };

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

            _viewModel.EditAccountCommand.Execute(editAccount);

            _viewModel.SmtpAccountsView.MoveCurrentToPosition(0);
            Assert.AreSame(account1, _viewModel.SmtpAccountsView.CurrentItem);
            _viewModel.SmtpAccountsView.MoveCurrentToPosition(1);
            Assert.AreSame(editAccount, _viewModel.SmtpAccountsView.CurrentItem);
            _viewModel.SmtpAccountsView.MoveCurrentToPosition(2);
            Assert.AreSame(account3, _viewModel.SmtpAccountsView.CurrentItem);
        }
示例#8
0
        public override void Execute(object parameter)
        {
            _currentAccount = parameter as SmtpAccount;
            if (_currentAccount == null)
            {
                return;
            }

            _usedInProfilesList = _profiles.Where(p => p.EmailSmtpSettings.AccountId.Equals(_currentAccount.AccountId)).ToList();

            var title = Translation.RemoveSmtpAccount;

            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.GetSmtpGetsDisabledMessage(_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 SystemSettingsDto(Dom.SystemSettings systemSettings)
 {
     smtpAccount = new SmtpAccount();
     if (systemSettings != null)
     {
         this.smtpAccount.Update(systemSettings);
     }
 }
示例#10
0
        public void AddSmtpAccount(SmtpAccount smtpAccount)
        {
            smtpAccount.PasswordEncrypted = _dataProtector.Protect(smtpAccount.Password);

            Accounts.SmtpAccounts.Add(smtpAccount);

            Save();
        }
示例#11
0
        public override void Execute(object parameter)
        {
            var newAccount = new SmtpAccount();

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

            var interaction = new SmtpAccountInteraction(newAccount, Translation.AddSmtpAccount);

            _interactionRequest.Raise(interaction, AddSmtpAccountCallback);
        }
示例#12
0
        public IActionResult OnPostCreate()
        {
            if (!ModelState.IsValid)
            {
                Data.SmptAccounts = _accountService.Accounts.SmtpAccounts.Select(account =>
                                                                                 new SelectListItem(account.Label, account.Id.ToString()))
                                    .Concat(new[] { new SelectListItem("Add New", Guid.Empty.ToString()) }).ToList();
                Data.Accounts = new List <SelectListItem>
                {
                    new SelectListItem(_accountService.Accounts.HiDriveAccount.UserName,
                                       _accountService.Accounts.HiDriveAccount.AccountId)
                };

                return(Page());
            }

            if (Data.SmptAccountId == Guid.Empty.ToString() && Data.NewSmtpAccount != null)
            {
                var smtpAccount = new SmtpAccount
                {
                    Id       = Guid.NewGuid(),
                    Label    = Data.NewSmtpAccount.Label,
                    Server   = Data.NewSmtpAccount.Server,
                    Username = Data.NewSmtpAccount.Username,
                    Password = Data.NewSmtpAccount.Password,
                    EmailTo  = Data.NewSmtpAccount.EmailTo
                };
                _accountService.AddSmtpAccount(smtpAccount);
                Data.SmptAccountId = smtpAccount.Id.ToString();
            }

            Data.Id = Guid.NewGuid();

            var folderConfiguration = new FolderConfiguration
            {
                Id                        = Data.Id,
                Label                     = Data.Label,
                SourcePath                = Data.SourcePath,
                DestinationPath           = Data.DestinationPath,
                LogPath                   = Data.LogPath,
                LogLevel                  = Data.LogLevel,
                Schedule                  = Data.Schedule,
                AccountId                 = Data.AccountId,
                NotificationConfiguration = new FolderNotificationConfiguration
                {
                    EmailConfigurationId = Guid.Parse(Data.SmptAccountId),
                    SendEmail            = Data.SendEmail,
                    SendEmailOnlyOnError = Data.SendEmailOnlyOnError
                }
            };

            _folderConfigService.AddFolderConfig(folderConfiguration);

            return(RedirectToPage("/Index"));
        }
 private void StoreSmtpAccount(Data data, int profileId, SmtpAccount account)
 {
     data.SetValue(@"ConversionProfiles\numClasses", (profileId + 1).ToString());
     data.SetValue($@"ConversionProfiles\{profileId}\EmailSmtpSettings\Enabled", "True");
     data.SetValue($@"ConversionProfiles\{profileId}\EmailSmtpSettings\Address", account.Address);
     data.SetValue($@"ConversionProfiles\{profileId}\EmailSmtpSettings\Password", Data.Encrypt(account.Password));
     data.SetValue($@"ConversionProfiles\{profileId}\EmailSmtpSettings\Port", account.Port.ToString());
     data.SetValue($@"ConversionProfiles\{profileId}\EmailSmtpSettings\Server", account.Server);
     data.SetValue($@"ConversionProfiles\{profileId}\EmailSmtpSettings\Ssl", account.Ssl.ToString());
     data.SetValue($@"ConversionProfiles\{profileId}\EmailSmtpSettings\UserName", account.UserName);
 }
示例#14
0
        public void AddAccount_LatestAccountIsCurrentItemInView()
        {
            _smtpAccounts.Add(new SmtpAccount());

            var latestAccount = new SmtpAccount();

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

            _viewModel.AddAccountCommand.Execute(null);

            Assert.AreSame(latestAccount, _viewModel.SmtpAccountsView.CurrentItem, "Latest Account is not selected Item");
        }
示例#15
0
        public void GetSmtpAccount_SmtpAccountIsNotEmpty_CallGetSmtpAccountWithEmptyString_ReturnsNull()
        {
            var smtpAccountWithEmptyID = new SmtpAccount();

            smtpAccountWithEmptyID.AccountId = "";
            _accounts.SmtpAccounts.Add(smtpAccountWithEmptyID);
            _profile.EmailSmtpSettings.AccountId = "";

            var fetchedSmtpAccount = _accounts.GetSmtpAccount(_profile);

            Assert.IsNull(fetchedSmtpAccount);
        }
示例#16
0
 private Models.SmtpAccount Convert(SmtpAccount source)
 {
     return(new Models.SmtpAccount
     {
         Id = source.Id,
         EnableSSl = source.EnableSSl,
         FromAddress = source.FromAddress,
         Password = "******",
         Port = source.Port,
         Server = source.Server,
         UserName = source.UserName
     });
 }
示例#17
0
        public void EditAccount_EditedAccountRemainsCurrentItemInView()
        {
            _smtpAccounts.Add(new SmtpAccount());
            var editAccount = new SmtpAccount();

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

            _viewModel.EditAccountCommand.Execute(null);

            Assert.AreSame(editAccount, _viewModel.SmtpAccountsView.CurrentItem, "Latest Account is not selected Item");
        }
        public void ChangeSmtpAccountsCollection_TriggersRaiseCanExecuteChanged()
        {
            var newAccount = new SmtpAccount();

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

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

            _smtpAccounts.Remove(newAccount);

            Assert.IsTrue(wasRaised);
        }
示例#19
0
        public void UpdateSmtpAccount(SmtpAccount updateParam)
        {
            Logger.Info("SystemAdministrationController.UpdateSmtpAccount()");
            var systemSettingsDom = uow.SystemSettings.Get(ApplicationUser);
            var isNew             = systemSettingsDom.id <= 0;

            if (isNew)
            {
                uow.SystemSettings.Add(systemSettingsDom);
            }
            systemSettingsDom.UpdateSmtpAccount(ApplicationUser, updateParam);
            uow.SaveChanges();
        }
示例#20
0
        public IActionResult OnPostStart()
        {
            if (!ModelState.IsValid)
            {
                Data.SmptAccounts = _accountService.Accounts.SmtpAccounts.Select(account =>
                                                                                 new SelectListItem(account.Label, account.Id.ToString()))
                                    .Concat(new[] { new SelectListItem("Add New", Guid.Empty.ToString()) }).ToList();
                Data.Accounts = new List <SelectListItem>
                {
                    new SelectListItem(_accountService.Accounts.HiDriveAccount.UserName,
                                       _accountService.Accounts.HiDriveAccount.AccountId)
                };
                return(Page());
            }
            var folderConfiguration = _folderConfigService.GetAllConfigs().FirstOrDefault(configuration => configuration.Id == Data.Id);

            if (folderConfiguration == null)
            {
                return(NotFound());
            }
            if (Data.SmptAccountId == Guid.Empty.ToString() && Data.NewSmtpAccount != null)
            {
                var smtpAccount = new SmtpAccount
                {
                    Id       = Guid.NewGuid(),
                    Label    = Data.NewSmtpAccount.Label,
                    Server   = Data.NewSmtpAccount.Server,
                    Port     = Data.NewSmtpAccount.Port,
                    Username = Data.NewSmtpAccount.Username,
                    Password = Data.NewSmtpAccount.Password,
                    EmailTo  = Data.NewSmtpAccount.EmailTo
                };
                _accountService.AddSmtpAccount(smtpAccount);
                Data.SmptAccountId = smtpAccount.Id.ToString();
            }

            folderConfiguration.SourcePath      = Data.SourcePath;
            folderConfiguration.Schedule        = Data.Schedule;
            folderConfiguration.DestinationPath = Data.DestinationPath;
            folderConfiguration.LogPath         = Data.LogPath;
            folderConfiguration.LogLevel        = Data.LogLevel;
            folderConfiguration.AccountId       = Data.AccountId;
            folderConfiguration.NotificationConfiguration.EmailConfigurationId = Guid.Parse(Data.SmptAccountId);
            folderConfiguration.NotificationConfiguration.SendEmail            = Data.SendEmail;
            folderConfiguration.NotificationConfiguration.SendEmailOnlyOnError = Data.SendEmailOnlyOnError;
            _folderConfigService.Save(folderConfiguration);
            var hiDriveSyncTask = _hiDriveSyncService.GetTask(folderConfiguration.Id);

            hiDriveSyncTask?.StartNow();
            return(RedirectToPage("/Index"));
        }
示例#21
0
        public void Setup()
        {
            _smtpAccout = new SmtpAccount()
            {
                AccountId = "SmtpAccountID1"
            };

            var accounts = new Accounts();

            accounts.SmtpAccounts.Add(_smtpAccout);

            _job = new Job(null, new ConversionProfile(), new JobTranslations(), accounts);
            _job.Profile.EmailSmtpSettings.AccountId = _smtpAccout.AccountId;
        }
示例#22
0
        protected override void HandleInteractionObjectChanged()
        {
            _smtpAccount = Interaction.SmtpAccount;

            RaisePropertyChanged(nameof(Address));
            RaisePropertyChanged(nameof(Server));
            RaisePropertyChanged(nameof(Username));
            RaisePropertyChanged(nameof(Password));
            RaisePropertyChanged(nameof(Port));
            RaisePropertyChanged(nameof(Ssl));
            AskForPasswordLater = string.IsNullOrWhiteSpace(Password);
            RaisePropertyChanged(nameof(AskForPasswordLater));
            SaveCommand.RaiseCanExecuteChanged();
        }
示例#23
0
        public void SetUp()
        {
            _smtpTestAccount           = new SmtpAccount();
            _smtpTestAccount.AccountId = "TestAccountId";

            _profile = new ConversionProfile();
            _profile.EmailSmtpSettings.Enabled   = true;
            _profile.EmailSmtpSettings.AccountId = _smtpTestAccount.AccountId;

            _accounts = new Accounts();
            _accounts.SmtpAccounts.Add(_smtpTestAccount);

            _smtpAction = new SmtpMailAction();
        }
示例#24
0
        private ActionResult Check(ConversionProfile profile, SmtpAccount smtpAccount)
        {
            var actionResult = new ActionResult();

            if (smtpAccount == null)
            {
                Logger.Error($"The specified SMTP account with ID \"{profile.EmailSmtpSettings.AccountId}\" is not configured.");
                actionResult.Add(ErrorCode.Smtp_NoAccount);
                return(actionResult);
            }

            if (string.IsNullOrWhiteSpace(smtpAccount.Address))
            {
                Logger.Error("No SMTP email address is specified.");
                actionResult.Add(ErrorCode.Smtp_NoEmailAddress);
            }
            if (string.IsNullOrWhiteSpace(profile.EmailSmtpSettings.Recipients))
            {
                Logger.Error("No SMTP email recipients are specified.");
                actionResult.Add(ErrorCode.Smtp_NoRecipients);
            }
            if (string.IsNullOrWhiteSpace(smtpAccount.Server))
            {
                Logger.Error("No SMTP host is specified.");
                actionResult.Add(ErrorCode.Smtp_NoServerSpecified);
            }

            if (smtpAccount.Port < 0)
            {
                Logger.Error("Invalid SMTP port.");
                actionResult.Add(ErrorCode.Smtp_InvalidPort);
            }

            if (string.IsNullOrWhiteSpace(smtpAccount.UserName))
            {
                Logger.Error("No SMTP UserName is specified.");
                actionResult.Add(ErrorCode.Smtp_NoUserSpecified);
            }

            if (profile.AutoSave.Enabled)
            {
                if (string.IsNullOrWhiteSpace(smtpAccount.Password))
                {
                    Logger.Error("No SMTP password for automatic saving.");
                    actionResult.Add(ErrorCode.Smtp_NoPasswordSpecified);
                }
            }

            return(actionResult);
        }
        public override void Execute(object parameter)
        {
            _currentAccount = parameter as SmtpAccount;
            if (_currentAccount == null)
            {
                return;
            }
            if (!SmtpAccounts.Contains(_currentAccount))
            {
                return;
            }

            var interaction = new SmtpAccountInteraction(_currentAccount.Copy(), Translation.EditSmtpAccount);

            _interactionRequest.Raise(interaction, UpdateSmtpAccountsCallback);
        }
示例#26
0
        private void V7ExtractSmtpAccounts()
        {
            var accounts = new Dictionary <SmtpAccount, List <int> >();

            ForAllProfiles((s, i) =>
            {
                var path = s + @"EmailSmtpSettings\";
                if (GetBool(Data.GetValue(path + "Enabled")) != true)
                {
                    return;
                }

                var account      = new SmtpAccount();
                account.Address  = Data.GetValue(path + "Address");
                account.Password = Data.Decrypt(Data.GetValue(path + "Password"));
                account.Port     = GetInt(Data.GetValue(path + "Port")) ?? 25;
                account.Server   = Data.GetValue(path + "Server");
                account.Ssl      = GetBool(Data.GetValue(path + "Ssl")) == true;
                account.UserName = Data.GetValue(path + "UserName");

                var existingAccount = accounts.Keys.FirstOrDefault(a => a.Equals(account));
                if (existingAccount != null)
                {
                    accounts[existingAccount].Add(i);
                }
                else
                {
                    accounts[account] = new List <int>();
                    accounts[account].Add(i);
                }
            });

            for (var i = 0; i < accounts.Count; i++)
            {
                var account = accounts.Keys.ToArray()[i];
                account.AccountId = Guid.NewGuid().ToString();

                account.StoreValues(Data, $@"ApplicationSettings\Accounts\SmtpAccounts\{i}\");

                foreach (var profileId in accounts[account])
                {
                    Data.SetValue($@"ConversionProfiles\{profileId}\EmailSmtpSettings\AccountId", account.AccountId);
                }
            }
            Data.SetValue(@"ApplicationSettings\Accounts\SmtpAccounts\numClasses", accounts.Keys.Count.ToString());
        }
示例#27
0
        protected void ExtractSmtpAccounts(string sourceProfilePath, string targetAccountsPath)
        {
            var accounts = new Dictionary <SmtpAccount, List <int> >();

            ForAllProfiles((pathToProfile, indexOfProfile) =>
            {
                var path = pathToProfile + @"EmailSmtpSettings\";
                if (GetBool(Data.GetValue(path + "Enabled")) != true)
                {
                    return;
                }

                var account      = new SmtpAccount();
                account.Address  = Data.GetValue(path + "Address");
                account.Password = Data.Decrypt(Data.GetValue(path + "Password"));
                account.Port     = GetInt(Data.GetValue(path + "Port")) ?? 25;
                account.Server   = Data.GetValue(path + "Server");
                account.Ssl      = GetBool(Data.GetValue(path + "Ssl")) == true;
                account.UserName = Data.GetValue(path + "UserName");

                var existingAccount = accounts.Keys.FirstOrDefault(a => a.Equals(account));
                if (existingAccount != null)
                {
                    accounts[existingAccount].Add(indexOfProfile);
                }
                else
                {
                    accounts[account] = new List <int>();
                    accounts[account].Add(indexOfProfile);
                }
            }, sourceProfilePath);

            for (var i = 0; i < accounts.Count; i++)
            {
                var account = accounts.Keys.ToArray()[i];
                account.AccountId = Guid.NewGuid().ToString();

                account.StoreValues(Data, $@"{targetAccountsPath}\Accounts\SmtpAccounts\{i}\");

                foreach (var profileId in accounts[account])
                {
                    Data.SetValue($@"{sourceProfilePath}\{profileId}\EmailSmtpSettings\AccountId", account.AccountId);
                }
            }
            Data.SetValue($@"{targetAccountsPath}\Accounts\SmtpAccounts\numClasses", accounts.Keys.Count.ToString());
        }
        public void SetUp()
        {
            _interactionRequest = new UnitTestInteractionRequest();
            _translation        = new SmtpTranslation();

            _smtpAccounts = new ObservableCollection <SmtpAccount>();

            _usedAccount           = new SmtpAccount();
            _usedAccount.AccountId = nameof(_usedAccount);
            _usedAccount.UserName  = "******";
            _usedAccount.Server    = "SV1";
            _smtpAccounts.Add(_usedAccount);

            _unusedAccount           = new SmtpAccount();
            _unusedAccount.AccountId = nameof(_unusedAccount);
            _unusedAccount.UserName  = "******";
            _unusedAccount.Server    = "SV2";
            _smtpAccounts.Add(_unusedAccount);

            _profiles = new ObservableCollection <ConversionProfile>();

            _profileWithSmtpAccountEnabled      = new ConversionProfile();
            _profileWithSmtpAccountEnabled.Name = nameof(_profileWithSmtpAccountEnabled);
            _profileWithSmtpAccountEnabled.EmailSmtpSettings.Enabled   = true;
            _profileWithSmtpAccountEnabled.EmailSmtpSettings.AccountId = _usedAccount.AccountId;
            _profiles.Add(_profileWithSmtpAccountEnabled);

            _profileWithSmtpAccountDisabled      = new ConversionProfile();
            _profileWithSmtpAccountDisabled.Name = nameof(_profileWithSmtpAccountDisabled);
            _profileWithSmtpAccountDisabled.EmailSmtpSettings.Enabled   = false;
            _profileWithSmtpAccountDisabled.EmailSmtpSettings.AccountId = _usedAccount.AccountId;
            _profiles.Add(_profileWithSmtpAccountDisabled);

            var settings = new PdfCreatorSettings(null);

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

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

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

            _smtpAccountRemoveCommand = new SmtpAccountRemoveCommand(_interactionRequest, currentSettingsProvider, translationUpdater);
        }
示例#29
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var smtpAccount = new SmtpAccount
            {
                Id      = Guid.NewGuid(), Label = Data.Label, Server = Data.Server, Port = Data.Port, Username = Data.Username,
                EmailTo = Data.EmailTo, Password = Data.Password
            };

            _accountService.AddSmtpAccount(smtpAccount);

            return(RedirectToPage("/Account/Index"));
        }
        public void AddAccount_UserAppliesInteraction_AccountGetsAdded()
        {
            var newAccount = new SmtpAccount();

            newAccount.Address  = "New Address";
            newAccount.Password = "******";
            newAccount.Server   = "New Server";

            _interactionRequest.RegisterInteractionHandler <SmtpAccountInteraction>(i =>
            {
                i.Success     = true;
                i.SmtpAccount = newAccount;
            });

            _smtpAccountAddCommand.Execute(null);

            Assert.AreEqual(1, _smtpAccounts.Count);
            Assert.AreSame(newAccount, _smtpAccounts.FirstOrDefault());
        }