Exemplo n.º 1
0
        public void Should_send_an_email()
        {
            SmtpFacade facade = new SmtpFacade("localhost", 25000);
            facade.Send("*****@*****.**", "*****@*****.**", "Empty", "N/A");

            Assert.AreEqual(1, this._server.ReceivedEmailCount);
            Assert.AreEqual("*****@*****.**", this._server.ReceivedEmail[0].Headers["from"]);
            Assert.AreEqual("*****@*****.**", this._server.ReceivedEmail[0].Headers["to"]);
            Assert.AreEqual("Empty", this._server.ReceivedEmail[0].Headers["subject"]);
            Assert.AreEqual("N/A", this._server.ReceivedEmail[0].MessageParts[0].BodyData);
        }
Exemplo n.º 2
0
        public void Should_send_an_attachment_with_mime_type()
        {
            SmtpFacade facade = new SmtpFacade("localhost", 25000);
            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes("function() { return 1; }"));
            facade.Send("*****@*****.**", "*****@*****.**", "Empty", "N/A", stream, "application/javascript");

            Assert.AreEqual(1, this._server.ReceivedEmailCount);

            SmtpMessagePart[] parts = this._server.ReceivedEmail[0].MessageParts;

            Assert.AreEqual(2, parts.Length);
            Assert.AreEqual("application/javascript", parts[1].Headers["content-type"]);
        }
Exemplo n.º 3
0
        public void Should_send_an_attachment()
        {
            SmtpFacade facade = new SmtpFacade("localhost", 25000);
            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes("function() { return 1; }"));
            facade.Send("*****@*****.**", "*****@*****.**", "Empty", "N/A", stream);

            Assert.AreEqual(1, this._server.ReceivedEmailCount);

            SmtpMessagePart[] parts = this._server.ReceivedEmail[0].MessageParts;

            Assert.AreEqual(2, parts.Length);

            string attr = Encoding.UTF8.GetString(Convert.FromBase64String(parts[1].BodyData));

            Assert.AreEqual("function() { return 1; }", attr);
        }