Пример #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);
        }
    public void BuildCustomBody_PreparesCorrectDestination()
    {
      // Arrange
      var fromAddress = new MailAddress("*****@*****.**");
      var toAddress = new MailAddress("*****@*****.**");
      var anotherAddress = new MailAddress("*****@*****.**");

      // Act
      var builder = new EmailDestinationBuilder(fromAddress, new[] { toAddress, anotherAddress }, ServerName);
      string result = builder.Body("Bizz").Build();

      // Assert
      var expected =
        string.Format(
          "Type=Mail;From={0};To={1},{2};UseAttachment={3};CustomBody={4};SmtpServer={5};UseSSL=yes;Port=465;UseAuthentication=no;", 
          fromAddress.Address, 
          toAddress.Address, 
          anotherAddress.Address, 
          "false", 
          "Bizz", 
          ServerName);

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

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

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

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

              // Act
              var builder = new EmailDestinationBuilder(fromAddress, new[] { toAddress, anotherAddress }, ServerName);
              string result = builder.Priority(MailPriority.High).Build();

              // Assert
              var expected =
            string.Format(
              "Type=Mail;From={0};To={1},{2};UseAttachment={3};SmtpServer={4};UseSsl=true;Port=465;Priority={5};UseAuthentication=false;",
              fromAddress.Address,
              toAddress.Address,
              anotherAddress.Address,
              "false",
              ServerName,
              MailPriority.High);

              Assert.Equal(expected, result);
        }
Пример #5
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);
        }
    public void BuildWithCc_DefaultsToSecuredAnonymousConnectionNoAttachments()
    {
      // Arrange
      var fromAddress = new MailAddress("*****@*****.**");
      var toAddress = new MailAddress("*****@*****.**");
      var anotherAddress = new MailAddress("*****@*****.**");
      var cc1 = new MailAddress("*****@*****.**");
      var cc2 = new MailAddress("*****@*****.**");

      // Act
      var builder = new EmailDestinationBuilder(fromAddress, new[] { toAddress, anotherAddress }, ServerName);

      string result = builder.Cc(new[] { cc1, cc2 }).Build();

      // Assert
      var expected =
        string.Format(
          "Type=Mail;From={0};To={1},{2};Cc={3},{4};UseAttachment={5};SmtpServer={6};UseSSL=yes;Port=465;UseAuthentication=no;", 
          fromAddress.Address, 
          toAddress.Address, 
          anotherAddress.Address, 
          cc1.Address, 
          cc2.Address, 
          "false", 
          ServerName);

      Assert.Equal(expected, result);
    }