public void SendTemplate_GivenValidSimpleTemplate_SendMail()
		{
			var senderMock = new Mock<IEmailSender>();
			var mcmRepository = new Mock<IMcmRepository>();
			var service = new Portal.EmailService.EmailService(senderMock.Object);

			const string to = "*****@*****.**";
			const string from = "*****@*****.**";
			const string subject = "Test Email";

			var templateMetadataIdentifier = new MetadataIdentifier(Guid.NewGuid(), Guid.NewGuid(), null);
			var templateObject = CreateObjectWithMetadata(templateMetadataIdentifier,
				"<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><html><body><h1>Hallo</h1><p>How are you <xsl:value-of select=\"//Name\"/>?</p></body></html></xsl:template></xsl:stylesheet>");
			
			var data = XElement.Parse("<Person><Name>Albert Einstein</Name></Person>");

			SendEmailRequest request = null;

			mcmRepository.Setup(r => r.ObjectGet(templateMetadataIdentifier.ObjectGuid, true, false, false, false, false)).Returns(templateObject);
			senderMock.Setup(s => s.Send(It.IsAny<SendEmailRequest>())).Callback<SendEmailRequest>(r => request = r);

			service.SendTemplate(from, to, subject, mcmRepository.Object, templateMetadataIdentifier, data);

			senderMock.Verify(s => s.Send(It.IsAny<SendEmailRequest>()), Times.Once());

			Assert.That(request, Is.Not.Null);
			Assert.That(request.Message.Body.Html.Data, Is.EqualTo("<html>\r\n  <body>\r\n    <h1>Hallo</h1>\r\n    <p>How are you Albert Einstein?</p>\r\n  </body>\r\n</html>"));
		}
        public void Send_GivenTemplate_TransformData()
        {
            var senderMock = new Mock<IEmailSender>();
            IEmailService service = new Portal.EmailService.EmailService(senderMock.Object);

            const string to = "*****@*****.**";
            const string from = "*****@*****.**";
            const string subject = "Test Email";
            var template = XElement.Load("EmailService/EmailTemplate01.xml");
            var data = XElement.Parse("<Person><Name>Albert Einstein</Name></Person>");

            SendEmailRequest request = null;

            senderMock.Setup(s => s.Send(It.IsAny<SendEmailRequest>())).Callback<SendEmailRequest>(r => request = r);

            service.SendTemplate(from, to, subject, template, data);

            Assert.That(request, Is.Not.Null);
            Assert.That(request.Message.Body.Html.Data, Is.EqualTo("<html>\r\n  <body>\r\n    <h1>Hallo</h1>\r\n    <p>\r\n\t\t\t\t\tHow are you Albert Einstein?\r\n\t\t\t\t</p>\r\n  </body>\r\n</html>"));
        }
        public void Send_GivenTemplateAndMultipleData_TransformData()
        {
            var senderMock = new Mock<IEmailSender>();
            IEmailService service = new Portal.EmailService.EmailService(senderMock.Object);

            const string to = "*****@*****.**";
            const string from = "*****@*****.**";
            const string subject = "Test Email";
            var template = XElement.Load("EmailService/EmailTemplate02.xml");
            var datas = new List<XElement>
            {
                XElement.Parse("<Person><Name>Richard Dawkins</Name></Person>"),
                XElement.Parse("<Order><Name>The God Delusion</Name></Order>")
            };

            SendEmailRequest request = null;

            senderMock.Setup(s => s.Send(It.IsAny<SendEmailRequest>())).Callback<SendEmailRequest>(r => request = r);

            service.SendTemplate(from, to, subject, template, datas);

            Assert.That(request, Is.Not.Null);
            Assert.That(request.Message.Body.Html.Data, Is.EqualTo("<html>\r\n  <body>\r\n    <h1>Hallo</h1>\r\n    <p>\r\n\t\t\t\t\tHow are you Richard Dawkins?\r\n\t\t\t\t</p>\r\n    <p>\r\n\t\t\t\t\tYou ordered The God Delusion.\r\n\t\t\t\t</p>\r\n  </body>\r\n</html>"));
        }