private static EmailMessage GetEmailMessage(IntegrationResult result, bool includeDetails)
        {
            EmailPublisher publisher = EmailPublisherMother.Create();

            publisher.IncludeDetails = includeDetails;
            return(new EmailMessage(DecorateIntegrationResult(result), publisher));
        }
        public void SerializeToXml()
        {
            publisher = EmailPublisherMother.Create();
            string xml = NetReflector.Write(publisher);

            XmlUtil.VerifyXmlIsWellFormed(xml);
        }
        public void EmailSubjectForStillBrokenBuild_DefaultMessage()
        {
            EmailPublisher publisher = EmailPublisherMother.Create();

            publisher.SubjectSettings = new EmailSubject[0];

            IntegrationResult result = IntegrationResultMother.CreateFailed(ThoughtWorks.CruiseControl.Remote.IntegrationStatus.Failure);

            string subject = new EmailMessage(DecorateIntegrationResult(result), publisher).Subject;

            Assert.AreEqual("CCNET: Project#9 is still broken", subject);
        }
        public void ShouldPopulateXslFiles()
        {
            string      configXml         = @"<email from=""*****@*****.**"" mailhost=""smtp.example.com""> <users/> <groups/>
					  <xslFiles> 
                        <file>xsl\NCover.xsl</file>
					   <file>xsl\NCoverExplorer.xsl</file>
					</xslFiles>
                </email>";
            XmlDocument configXmlDocument = XmlUtil.CreateDocument(configXml);

            publisher = EmailPublisherMother.Create(configXmlDocument.DocumentElement);

            Assert.AreEqual(2, publisher.XslFiles.Length);
            Assert.AreEqual(@"xsl\NCover.xsl", publisher.XslFiles[0]);
            Assert.AreEqual(@"xsl\NCoverExplorer.xsl", publisher.XslFiles[1]);
        }
        public void PopulateFromConfiguration()
        {
            publisher = EmailPublisherMother.Create();

            Assert.AreEqual("smtp.telus.net", publisher.MailHost);
            Assert.AreEqual(26, publisher.MailPort);
            Assert.AreEqual("mailuser", publisher.MailhostUsername);
            Assert.IsNotNull(publisher.MailhostPassword);
            Assert.AreEqual("mailpassword", publisher.MailhostPassword.PrivateValue);
            Assert.AreEqual("*****@*****.**", publisher.FromAddress);
            Assert.AreEqual(2, publisher.ModifierNotificationTypes.Length);
            Assert.AreEqual(EmailGroup.NotificationType.Failed, publisher.ModifierNotificationTypes[0]);
            Assert.AreEqual(EmailGroup.NotificationType.Fixed, publisher.ModifierNotificationTypes[1]);

            Assert.AreEqual(1, publisher.Converters.Length);
            Assert.AreEqual("$", ((EmailRegexConverter)publisher.Converters[0]).Find);
            Assert.AreEqual("@TheCompany.com", ((EmailRegexConverter)publisher.Converters[0]).Replace);

            Assert.AreEqual(6, publisher.IndexedEmailUsers.Count);
            var expected = new List <EmailUser>();

            expected.Add(new EmailUser("buildmaster", "buildmaster", "*****@*****.**"));
            expected.Add(new EmailUser("orogers", "developers", "*****@*****.**"));
            expected.Add(new EmailUser("manders", "developers", "*****@*****.**"));
            expected.Add(new EmailUser("dmercier", "developers", "*****@*****.**"));
            expected.Add(new EmailUser("rwan", "developers", "*****@*****.**"));
            expected.Add(new EmailUser("owjones", "successdudes", "*****@*****.**"));
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.IsTrue(publisher.IndexedEmailUsers.ContainsValue(expected[i]));
            }

            Assert.AreEqual(3, publisher.IndexedEmailGroups.Count);
            EmailGroup developers   = new EmailGroup("developers", new EmailGroup.NotificationType[] { EmailGroup.NotificationType.Change });
            EmailGroup buildmaster  = new EmailGroup("buildmaster", new EmailGroup.NotificationType[] { EmailGroup.NotificationType.Always });
            EmailGroup successdudes = new EmailGroup("successdudes", new EmailGroup.NotificationType[] { EmailGroup.NotificationType.Success });

            Assert.AreEqual(developers, publisher.IndexedEmailGroups["developers"]);
            Assert.AreEqual(buildmaster, publisher.IndexedEmailGroups["buildmaster"]);
            Assert.AreEqual(successdudes, publisher.IndexedEmailGroups["successdudes"]);
        }
        public void ShouldPopulateFromMinimalConfiguration()
        {
            string      configXml         = @"<email from=""*****@*****.**"" mailhost=""smtp.example.com""> <users/> <groups/> </email>";
            XmlDocument configXmlDocument = XmlUtil.CreateDocument(configXml);

            publisher = EmailPublisherMother.Create(configXmlDocument.DocumentElement);

            Assert.AreEqual("smtp.example.com", publisher.MailHost);
            Assert.AreEqual(25, publisher.MailPort);
            Assert.AreEqual(null, publisher.MailhostUsername);
            Assert.AreEqual(null, publisher.MailhostPassword);
            Assert.AreEqual(null, publisher.ReplyToAddress);
            Assert.AreEqual(false, publisher.IncludeDetails);
            Assert.AreEqual("*****@*****.**", publisher.FromAddress);
            Assert.AreEqual(1, publisher.ModifierNotificationTypes.Length);
            Assert.AreEqual(EmailGroup.NotificationType.Always, publisher.ModifierNotificationTypes[0]);

            Assert.AreEqual(0, publisher.Converters.Length);
            Assert.AreEqual(0, publisher.IndexedEmailUsers.Count);
            Assert.AreEqual(0, publisher.IndexedEmailGroups.Count);
        }
 public void SetUp()
 {
     publisher              = EmailPublisherMother.Create();
     mockGateway            = new DynamicMock(typeof(EmailGateway));
     publisher.EmailGateway = (EmailGateway)mockGateway.MockInstance;
 }
Exemple #8
0
 public void SetUp()
 {
     publisher              = EmailPublisherMother.Create();
     mockGateway            = new Mock <EmailGateway>();
     publisher.EmailGateway = (EmailGateway)mockGateway.Object;
 }