Пример #1
0
        public void ExportTestEnum_ContainsTranslationsForEachEntry()
        {
            var catalog = DoExport(typeof(TestEnum));

            Assert.True(HasTranslation(catalog, TranslationAttribute.GetValue(TestEnum.FirstValue)));
            Assert.True(HasTranslation(catalog, TranslationAttribute.GetValue(TestEnum.SecondValue)));
            Assert.True(HasTranslation(catalog, TranslationAttribute.GetValue(TestEnum.ThirdValue)));
        }
Пример #2
0
        public void ExportThisAssembly_ContainsTranslations()
        {
            var catalog     = ExportCurrentAssembly();
            var translation = new TestTranslation();

            Assert.Equal(9, catalog.Entries.Count);

            Assert.True(HasTranslation(catalog, translation.Title));
            Assert.True(HasTranslation(catalog, TranslationAttribute.GetValue(TestEnum.FirstValue)));
        }
Пример #3
0
        public void WhenProfileInvalid_DisplaysErrorMessage()
        {
            var expectedError = ErrorCode.Smtp_NoPasswordSpecified;

            _smtpAction.ProcessJob(Arg.Any <Job>()).Returns(x => new ActionResult(expectedError));
            var assistant = BuildAssistant();

            assistant.SendTestMail(_profile, _accounts);

            _interactionRequest.AssertWasRaised <MessageInteraction>();
            var messageInteraction = _interactionRequest.AssertWasRaised <MessageInteraction>();

            Assert.AreEqual(_translation.SendTestMail, messageInteraction.Title);
            Assert.AreEqual(TranslationAttribute.GetValue(expectedError), messageInteraction.Text);
            Assert.AreEqual(MessageIcon.Error, messageInteraction.Icon);
        }
Пример #4
0
        public void WhenSendingMailFails_ShowsErrorMessage()
        {
            var expectedError = ErrorCode.Smtp_AuthenticationDenied;

            _smtpAction.ProcessJob(Arg.Any <Job>()).Returns(new ActionResult(expectedError));
            var assistant = BuildAssistant();

            assistant.SendTestMail(_profile, _accounts);

            _interactionRequest.AssertWasRaised <MessageInteraction>();

            var messageInteraction = _interactionRequest.AssertWasRaised <MessageInteraction>();

            Assert.AreEqual(_translation.SendTestMail, messageInteraction.Title);
            Assert.AreEqual(TranslationAttribute.GetValue(expectedError), messageInteraction.Text);
            Assert.AreEqual(MessageIcon.Error, messageInteraction.Icon);
        }
Пример #5
0
        public void WhenSendingMailFails_ShowsErrorMessage()
        {
            var translation   = new SmtpSettingsAndActionControlTranslation();
            var expectedError = ErrorCode.Smtp_AuthenticationDenied;

            _smtpAction.ProcessJob(Arg.Any <Job>()).Returns(new ActionResult(expectedError));
            var assistant = BuildAssistant();

            assistant.SendTestMail(_profile, new Accounts());

            _interactionInvoker.Received().Invoke(Arg.Any <MessageInteraction>());

            var messageInteraction =
                _interactions.Where(x => x is MessageInteraction).Cast <MessageInteraction>().First();

            Assert.AreEqual(translation.SendTestMail, messageInteraction.Title);
            Assert.AreEqual(TranslationAttribute.GetValue(expectedError), messageInteraction.Text);
            Assert.AreEqual(MessageIcon.Error, messageInteraction.Icon);
        }
Пример #6
0
        public void WhenProfileInvalid_DisplaysErrorMessage()
        {
            var translation   = new SmtpSettingsAndActionControlTranslation();
            var expectedError = ErrorCode.Smtp_NoPasswordSpecified;

            _smtpAction.Check(_profile, Arg.Any <Accounts>()).Returns(x => new ActionResult(expectedError));
            var assistant = BuildAssistant();

            assistant.SendTestMail(_profile, new Accounts());

            _interactionInvoker.Received().Invoke(Arg.Any <MessageInteraction>());

            var messageInteraction =
                _interactions.Where(x => x is MessageInteraction).Cast <MessageInteraction>().First();

            var errorCodeInt = (int)expectedError;

            Assert.AreEqual(translation.SendTestMail, messageInteraction.Title);
            Assert.AreEqual(TranslationAttribute.GetValue(expectedError), messageInteraction.Text);
            Assert.AreEqual(MessageIcon.Error, messageInteraction.Icon);
        }
Пример #7
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var sourceType = value.GetType();

            if (!sourceType.IsEnum)
            {
                throw new InvalidOperationException("The target must be an enum");
            }

            if (_translationFactory?.TranslationSource == null)
            {
                return(null);
            }

            try
            {
                return(_translationFactory.TranslationSource.GetTranslation(TranslationAttribute.GetValue(value)));
            }
            catch
            {
                return(value.ToString());
            }
        }