コード例 #1
0
        public void ShouldThrowIfEmptyBody()
        {
            // Arrange
            IEmailRequestBuilder builder = new EmailRequestBuilder()
                .AddTo("*****@*****.**")
                .WithSubject("Hello");

            // Act & Assert
            Should.Throw<DreamFactoryException>(() => builder.Build());
        }
コード例 #2
0
        public void ShouldThrowIfNoTitle()
        {
            // Arrange
            IEmailRequestBuilder builder = new EmailRequestBuilder()
                .AddTo("*****@*****.**")
                .WithBody("Hello, World!");

            // Act & Assert
            Should.Throw<DreamFactoryException>(() => builder.Build());
        }
コード例 #3
0
        public void ShouldThrowIfNoRecipients()
        {
            // Arrange
            IEmailRequestBuilder builder = new EmailRequestBuilder()
                .WithSubject("Hello")
                .WithBody("Hello, World!");

            // Act & Assert
            Should.Throw<DreamFactoryException>(() => builder.Build());
        }
コード例 #4
0
        public void ShouldBuildEmailRequest()
        {
            // Arrange
            IEmailRequestBuilder builder = new EmailRequestBuilder()
                .AddTo("*****@*****.**")
                .WithSubject("Hello")
                .WithBody("Hello, World!");

            // Act
            EmailRequest request = builder.Build();

            // Assert
            request.subject.ShouldBe("Hello");
            request.body_text.ShouldBe("Hello, World!");
            request.to.Single().email.ShouldBe("*****@*****.**");
        }
コード例 #5
0
        public async Task RunAsync(IRestContext context)
        {
            // Send an email
            Console.WriteLine("Sending email...");

            // Using the builder is good for simple emails
            EmailRequest request = new EmailRequestBuilder().AddTo("*****@*****.**")
                                                            .WithSubject("Hello")
                                                            .WithBody("Hello, world!")
                                                            .Build();

            IEmailApi emailApi = context.Factory.CreateEmailApi("email");
            int count = await emailApi.SendEmailAsync(request);

            Console.WriteLine("{0} email(s) sent.", count);
        }
コード例 #6
0
        public void ShouldBuildEmailRequest()
        {
            // Arrange
            IEmailRequestBuilder builder = new EmailRequestBuilder()
                .AddTo("*****@*****.**")
                .WithSubject("Hello")
                .WithBody("Hello, World!");

            // Act
            EmailRequest request = builder.Build();

            // Assert
            request.Subject.ShouldBe("Hello");
            request.BodyText.ShouldBe("Hello, World!");
            request.To.Single().Email.ShouldBe("*****@*****.**");

            Should.Throw<ArgumentNullException>(() => builder.AddTo(null));
            Should.Throw<ArgumentNullException>(() => builder.WithSubject(null));
            Should.Throw<ArgumentNullException>(() => builder.WithBody(null));
        }