SendAttachments() публичный Метод

public SendAttachments ( ) : EmailDestinationBuilder
Результат EmailDestinationBuilder
Пример #1
0
        public void BuildAttachmentsAndShortServerOptions_PreparesCorrectDestination()
        {
            // Arrange
              var fromAddress = new MailAddress("*****@*****.**");
              var toAddress = new MailAddress("*****@*****.**");
              var anotherAddress = new MailAddress("*****@*****.**");

              // Act
              var builder = new EmailDestinationBuilder(fromAddress, new[] { toAddress, anotherAddress }, ServerName);
              var credential = new NetworkCredential("test", "foo");

              string result = builder.SendAttachments().UseServer(false, credential).Build();

              // Assert
              var expected =
            string.Format(
              "Type=Mail;From={0};To={1},{2};UseAttachment={3};SmtpServer={4};UseSsl=false;Port=25;UseAuthentication=true;Username={5};Password={6};",
              fromAddress.Address,
              toAddress.Address,
              anotherAddress.Address,
              "true",
              ServerName,
              "test",
              "foo");

              Assert.Equal(expected, result);
        }
Пример #2
0
        public void BuildDefaultsToSecuredAnonymousConnectionWithAttachmentsTestUsingMailObject()
        {
            // Arrange
              var fromAddress = new MailAddress("*****@*****.**");
              var toAddress = new MailAddress("*****@*****.**");
              var anotherAddress = new MailAddress("*****@*****.**");

              // Act
              var builder = new EmailDestinationBuilder(fromAddress, new[] { toAddress, anotherAddress }, ServerName);
              builder = builder.SendAttachments();
              string result = builder.Build();
              Mail mail = new Mail(result);

              // Assert
              Assert.Equal("*****@*****.**", mail.From);
              Assert.Equal("[email protected],[email protected]", mail.To);
              Assert.Equal(true, mail.UseAttachment);
              Assert.Equal(ServerName, mail.SmtpServer);
              Assert.Equal(true, mail.UseSsl);
              Assert.Equal(465, mail.Port);
              Assert.Equal(false, mail.UseAuthentication);
        }