Ejemplo n.º 1
0
        public void InvalidFolderStringThrows()
        {
            // Create and configure our template.
            var smtpClient    = new SmtpClient();
            var configuration = new Extensions.Email.SmtpConfiguration()
            {
                UseLocalPickupFolder = true,
                LocalPickupFolder    = @"ABC:DEF\Something"
            };

            // Push configuration to SmtpClient.
            configuration.ApplyConfigurationTo(smtpClient);
        }
Ejemplo n.º 2
0
        public void EmptyPickupFolderThrows()
        {
            // Create and configure our template.
            var smtpClient    = new SmtpClient();
            var configuration = new Extensions.Email.SmtpConfiguration()
            {
                UseLocalPickupFolder = true,
                LocalPickupFolder    = string.Empty
            };

            // Push configuration to SmtpClient.
            configuration.ApplyConfigurationTo(smtpClient);
        }
Ejemplo n.º 3
0
        public void PickupConfigurationValid()
        {
            // Create and configure our template.
            var smtpClient    = new SmtpClient();
            var configuration = new Extensions.Email.SmtpConfiguration()
            {
                UseLocalPickupFolder = true,
                LocalPickupFolder    = @"C:\"
            };

            // Push configuration to SmtpClient.
            configuration.ApplyConfigurationTo(smtpClient);

            // Ensure valid.
            Assert.AreEqual(SmtpDeliveryMethod.SpecifiedPickupDirectory, smtpClient.DeliveryMethod);
            Assert.AreEqual(@"C:\", smtpClient.PickupDirectoryLocation);
        }
Ejemplo n.º 4
0
        public void CustomPortPersisted()
        {
            // Create and configure our template.
            var smtpClient    = new SmtpClient();
            var configuration = new Extensions.Email.SmtpConfiguration()
            {
                RequiresAuthentication = false,
                ServerAddress          = "mail.mycompany.com",
                Port = 123
            };

            // Push configuration to SmtpClient.
            configuration.ApplyConfigurationTo(smtpClient);

            // Ensure valid.
            Assert.AreEqual(123, smtpClient.Port);
        }
Ejemplo n.º 5
0
        public void NetworkDeliveryConfigurationValid()
        {
            // Create and configure our template.
            var smtpClient    = new SmtpClient();
            var configuration = new Extensions.Email.SmtpConfiguration()
            {
                Credentials = new Credentials()
                {
                    AccountName = "test",
                    Password    = "******"
                },
                DefaultSender          = new Extensions.Email.EmailAddress("*****@*****.**"),
                UseEncryptedConnection = true,
                UseLocalPickupFolder   = false,
                RequiresAuthentication = true,
                ServerAddress          = "mail.mycompany.com"
            };

            // Push configuration to SmtpClient.
            configuration.ApplyConfigurationTo(smtpClient);

            // Ensure valid.
            Assert.AreEqual(configuration.UseEncryptedConnection, smtpClient.EnableSsl);
            Assert.AreEqual(SmtpDeliveryMethod.Network, smtpClient.DeliveryMethod);
            Assert.IsNotNull(smtpClient.Credentials, "Credentials not set");
            Assert.AreEqual
            (
                configuration.Credentials.AccountName,
                (smtpClient.Credentials as NetworkCredential)?.UserName
            );
            Assert.AreEqual
            (
                configuration.Credentials.Password,
                (smtpClient.Credentials as NetworkCredential)?.Password
            );
            Assert.AreEqual("mail.mycompany.com", smtpClient.Host);
            Assert.AreEqual(Extensions.Email.SmtpConfiguration.DefaultPort, smtpClient.Port);
        }