Exemplo n.º 1
0
        public void TestBuildMessage_MissingTemplate()
        {
            var context = new Mock<IEmailContext>();
            context.Setup(c => c.TemplateKey).Returns(_testTemplate.Title);

            var builder = new MessageBuilder();

            var message = builder.BuildMessage(context.Object, _mockTemplateRepo.Object);
        }
Exemplo n.º 2
0
        public void TestBuildMessage()
        {
            var context = new Mock<IEmailContext>();
            context.Setup(c => c.ToAddress).Returns("*****@*****.**");
            context.Setup(c => c.TemplateKey).Returns(_testTemplate.Title);
            context.Setup(c => c.TokenData).Returns(new Object());
            _mockTemplateRepo.Setup(r => r.GetByKey(_testTemplate.Title)).Returns(_testTemplate);

            var builder = new MessageBuilder();

            var message = builder.BuildMessage(context.Object, _mockTemplateRepo.Object);

            Assert.IsNotNull(message);
            Assert.AreEqual(context.Object.ToAddress, message.To.First().Address);
            Assert.AreEqual(_testTemplate.Body, message.Body);
            Assert.AreEqual(_testTemplate.FromAddress, message.From.Address);
            Assert.AreEqual(_testTemplate.Subject, message.Subject);
        }