Example #1
0
        public void Building_a_greeting_sets_up_greeting_message()
        {
            Email email = EmailBuilder
                          .CreateNew()
                          .AddSubject("A simple email builder")
                          .AddFrom("*****@*****.**")
                          .AddBody("This pattern could be useful for complex setup")
                          .AddTo("*****@*****.**")
                          .Build();

            Assert.Equal(
                expected: "A simple email builder",
                actual: email.Subject);
        }
Example #2
0
        public void Building_a_greeting_with_missing_values_throws_exception()
        {
            var ex = Assert.Throws <ArgumentException>(() =>
            {
                Email email = EmailBuilder
                              .CreateNew()
                              .AddSubject("")
                              .AddFrom("*****@*****.**")
                              .AddBody("This pattern could be useful for complex setup")
                              .AddTo("*****@*****.**")
                              .Build();
            });

            Assert.Equal(
                expected: "Subject must be set",
                actual: ex.Message);
        }