Alpinely.TownCrier.Tests.IntegrationTests.CanSendPlainEmail C# (CSharp) Method

CanSendPlainEmail() private method

private CanSendPlainEmail ( ) : void
return void
        public void CanSendPlainEmail()
        {
            var factory = new MergedEmailFactory(new TemplateParser());

            var tokenValues = new Dictionary<string, string>
                                  {
                                      {"name", "Joe"},
                                      {"userid", "123"}
                                  };

            MailMessage message = factory
                .WithTokenValues(tokenValues)
                .WithPlainTextBodyFromFile(@"templates\sample-email.txt")
                .Create();

            var from = new MailAddress("[email protected]", "Automated Emailer");
            var to = new MailAddress("[email protected]", "Joe Bloggs");
            message.From = from;
            message.To.Add(to);

            using (var output = new MemoryStream())
            {
                message.Save(output);
                var result = StreamToString(output);

                Assert.That(result, Contains.Substring(@"Content-Type: text/plain"));

                Assert.That(result, Contains.Substring(@"Dear Joe"));

                // Note that actually the email is encoded with RFC 2045 "Quoted Printable" Encoding, but .NET doesn't ship
                // with a decoder so we'll add the =3D into our test for simplicity.
                Assert.That(result, Contains.Substring(@"http://localhost/trackedLink?userId=3D123"));

                Console.WriteLine(result);
            }
        }