Пример #1
0
        public void MailTarget_UseSystemNetMailSettings_False_ReadFromFromConfigFile()
        {

            var mmt = new MailTarget()
            {
                From = null,
                To = "*****@*****.**",
                SmtpServer = "server1",
                SmtpPort = 27,
                Body = "${level} ${logger} ${message}",
                UseSystemNetMailSettings = false,
                SmtpSection = new SmtpSection { From = "*****@*****.**" }
            };
            Assert.Null(mmt.From);

            Assert.Throws <NLogConfigurationException>(() => mmt.Initialize(null));

        }
Пример #2
0
        public void MailTarget_UseSystemNetMailSettings_True_ReadFromFromConfigFile()
        {

            var mmt = new MailTarget()
            {
                From = null,
                To = "*****@*****.**",
                SmtpServer = "server1",
                SmtpPort = 27,
                Body = "${level} ${logger} ${message}",
                UseSystemNetMailSettings = true,
                SmtpSection = new SmtpSection { From = "*****@*****.**" }
            };
            Assert.Equal("'*****@*****.**'", mmt.From.ToString());

            mmt.Initialize(null);

            Assert.Equal("'*****@*****.**'", mmt.From.ToString());
        }