protected override async Task <bool> TrySetJobPasswords(Job job)
        {
            var smtpAccount = job.Accounts.GetSmtpAccount(job.Profile);

            if (smtpAccount == null) //The account must be checked, since it is executed before the Action.Check...
            {
                var message = new MessageInteraction(Translation.NoAccount, Translation.SendTestMail, MessageOptions.OK, MessageIcon.Error);
                InteractionRequest.Raise(message);
                return(false);
            }

            job.Passwords.SmtpPassword = smtpAccount.Password;

            if (!string.IsNullOrWhiteSpace(job.Passwords.SmtpPassword))
            {
                return(true);
            }

            var recipientsString = GetRecipientsString(job.Profile.EmailSmtpSettings);
            var title            = Translation.SetSmtpServerPassword;
            var description      = Translation.SmtpServerPasswordLabel;
            var interaction      = new PasswordOverlayInteraction(PasswordMiddleButton.None, title, description, false);

            interaction.IntroText = recipientsString;

            await InteractionRequest.RaiseAsync(interaction);

            if (interaction.Result != PasswordResult.StorePassword)
            {
                return(false);
            }

            job.Passwords.SmtpPassword = interaction.Password;
            return(true);
        }
Пример #2
0
        public async Task WhenEventIsRaisedAsync_NotificationIsPassedBackAsync()
        {
            var request          = new InteractionRequest <INotification>();
            var trigger          = new TestableInteractionRequestTrigger();
            var associatedObject = new DependencyObject();
            var action           = new TestableTriggerAction();
            var notification     = new Notification();

            trigger.Actions.Add(action);
            trigger.Attach(associatedObject);
            trigger.SourceObject = request;

            Assert.IsTrue(action.ExecutionCount == 0);

            var result = await request.RaiseAsync(notification);

            Assert.IsTrue(action.ExecutionCount == 1);
            Assert.ReferenceEquals(notification, result);
        }