示例#1
0
        public void EnumeratorCurrentTest()
        {
            EmailSinkData sinkA = new EmailSinkData();

            sinkA.Name     = "MyName";
            sinkA.TypeName = "MyType";
            sinkDataCollection.Add(sinkA);

            EmailSinkData sinkB = new EmailSinkData();

            sinkB.Name     = "MyName2";
            sinkB.TypeName = "MyType2";
            sinkDataCollection.Add(sinkB);
            int count = 0;

            foreach (SinkData sink1 in sinkDataCollection)
            {
                Assert.IsNotNull(sink1);
                count++;
                foreach (SinkData sink2 in sinkDataCollection)
                {
                    Assert.IsNotNull(sink2);
                    count++;
                }
            }
            Assert.AreEqual(6, count);
        }
示例#2
0
        public void Init()
        {
            XmlTextReader xmlReader     = new XmlTextReader(new StringReader(xmlString));
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(SinkData));

            this.data = xmlSerializer.Deserialize(xmlReader) as EmailSinkData;
        }
示例#3
0
        public void EmailSinkDataTest()
        {
            string fromAddress        = "testFromAddress";
            string name               = "testName";
            string smtpServer         = "testSmtpServer";
            string subjectLineEnder   = "testSubjectLineEnder";
            string subjectLineStarter = "testSubjectLineStarter";
            string toAddress          = "testToAddress";
            string typeName           = typeof(EmailSink).AssemblyQualifiedName;

            EmailSinkData data = new EmailSinkData();

            data.FromAddress        = fromAddress;
            data.Name               = name;
            data.SmtpServer         = smtpServer;
            data.SubjectLineEnder   = subjectLineEnder;
            data.SubjectLineStarter = subjectLineStarter;
            data.ToAddress          = toAddress;
            data.TypeName           = typeName;

            EmailSinkNode node = new EmailSinkNode(data);

            GeneratedApplicationNode.Nodes.Add(node);
            EmailSinkData nodeData = (EmailSinkData)node.SinkData;

            Assert.AreEqual(fromAddress, nodeData.FromAddress);
            Assert.AreEqual(name, nodeData.Name);
            Assert.AreEqual(smtpServer, nodeData.SmtpServer);
            Assert.AreEqual(subjectLineEnder, nodeData.SubjectLineEnder);
            Assert.AreEqual(subjectLineStarter, nodeData.SubjectLineStarter);
            Assert.AreEqual(toAddress, nodeData.ToAddress);
            Assert.AreEqual(typeName, nodeData.TypeName);
        }
示例#4
0
        private bool ValidateParameters(LogEntry log)
        {
            EmailSinkData emailSinkData = GetEmailSinkDataFromView();

            bool valid = true;

            if (emailSinkData.ToAddress == null ||
                emailSinkData.ToAddress.Length == 0)
            {
                valid = false;
            }

            if (emailSinkData.FromAddress == null ||
                emailSinkData.FromAddress.Length == 0)
            {
                valid = false;
            }

            if (emailSinkData.SmtpServer == null ||
                emailSinkData.SmtpServer.Length == 0)
            {
                valid = false;
            }

            if (!valid)
            {
                string error = SR.EmailSinkMissingParameters;
                log.AddErrorMessage(error);
                this.defaultSink.SendMessage(log);
            }

            return(valid);
        }
示例#5
0
        private void EmailLogEntry(LogEntry logEntry, ILogFormatter formatter)
        {
            EmailSinkData emailSinkData = GetEmailSinkDataFromView();
            EmailMessage  emailMessage  = CreateEmailMessage(emailSinkData, logEntry, formatter);

            emailMessage.Send();
        }
示例#6
0
        public void EnumeratorCurrentTest()
        {
            EmailSinkData sinkA = new EmailSinkData();
            sinkA.Name = "MyName";
            sinkA.TypeName = "MyType";
            sinkDataCollection.Add(sinkA);

            EmailSinkData sinkB = new EmailSinkData();
            sinkB.Name = "MyName2";
            sinkB.TypeName = "MyType2";
            sinkDataCollection.Add(sinkB);
            int count = 0;

            foreach (SinkData sink1 in sinkDataCollection)
            {
                Assert.IsNotNull(sink1);
                count++;
                foreach (SinkData sink2 in sinkDataCollection)
                {
                    Assert.IsNotNull(sink2);
                    count++;
                }
            }
            Assert.AreEqual(6, count);
        }
示例#7
0
        public void EmailSink()
        {
            string        sinkName = "SampleEmailSink";
            EmailSinkData sink     = new EmailSinkData();

            sink.Name = sinkName;

            SinkFromFactory(sink);
        }
示例#8
0
 public void Setup()
 {
     sinkParams                    = new EmailSinkData();
     sinkParams.ToAddress          = "[email protected]";
     sinkParams.FromAddress        = "*****@*****.**";
     sinkParams.SubjectLineStarter = "EntLib-Logging:";
     sinkParams.SubjectLineEnder   = "has occurred";
     sinkParams.SmtpServer         = "smtphost";
     this.sink = new EmailSink();
     this.sink.Initialize(new TestLogSinkConfigurationView(sinkParams));
     CommonUtil.ResetEventLogCounter();
     lastMailMessageSent = null;
 }
示例#9
0
        public void EmailSinkDataPropertiesTest()
        {
            EmailSinkData data               = new EmailSinkData();
            string        fromAddress        = "From Address";
            string        smtpServer         = "Smtp Server";
            string        subjectLineEnder   = "Subject Line ENd";
            string        subjectLineStarter = "Subject Line Start";
            string        toAddress          = "To Address";

            data.FromAddress        = fromAddress;
            data.SmtpServer         = smtpServer;
            data.SubjectLineEnder   = subjectLineEnder;
            data.SubjectLineStarter = subjectLineStarter;
            data.ToAddress          = toAddress;

            Assert.AreEqual(fromAddress, data.FromAddress);
            Assert.AreEqual(smtpServer, data.SmtpServer);
            Assert.AreEqual(subjectLineEnder, data.SubjectLineEnder);
            Assert.AreEqual(subjectLineStarter, data.SubjectLineStarter);
            Assert.AreEqual(toAddress, data.ToAddress);
        }
示例#10
0
        public void EmailSinkDataPropertiesTest()
        {
            EmailSinkData data = new EmailSinkData();
            string fromAddress = "From Address";
            string smtpServer = "Smtp Server";
            string subjectLineEnder = "Subject Line ENd";
            string subjectLineStarter = "Subject Line Start";
            string toAddress = "To Address";

            data.FromAddress = fromAddress;
            data.SmtpServer = smtpServer;
            data.SubjectLineEnder = subjectLineEnder;
            data.SubjectLineStarter = subjectLineStarter;
            data.ToAddress = toAddress;

            Assert.AreEqual(fromAddress, data.FromAddress);
            Assert.AreEqual(smtpServer, data.SmtpServer);
            Assert.AreEqual(subjectLineEnder, data.SubjectLineEnder);
            Assert.AreEqual(subjectLineStarter, data.SubjectLineStarter);
            Assert.AreEqual(toAddress, data.ToAddress);
        }
示例#11
0
 /// <summary>
 /// Creates node with specified configuration data.
 /// </summary>
 /// <param name="emailSinkData">Configuration data.</param>
 public EmailSinkNode(EmailSinkData emailSinkData) : base(emailSinkData)
 {
     this.emailSinkData = emailSinkData;
 }
示例#12
0
 public EmailMessage(EmailSinkData configurationData, LogEntry logEntry, ILogFormatter formatter)
 {
     this.configurationData = configurationData;
     this.logEntry          = logEntry;
     this.formatter         = formatter;
 }
示例#13
0
 internal virtual EmailMessage CreateEmailMessage(EmailSinkData sinkParameters, LogEntry logEntry, ILogFormatter formatter)
 {
     return(new EmailMessage(sinkParameters, logEntry, formatter));
 }
示例#14
0
 public void Init()
 {
     XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlString));
     XmlSerializer xmlSerializer = new XmlSerializer(typeof(SinkData));
     this.data = xmlSerializer.Deserialize(xmlReader) as EmailSinkData;
 }
示例#15
0
 public MockEmailMessage(EmailSinkData sinkParameters, LogEntry logEntry, ILogFormatter formatter) : base(sinkParameters, logEntry, formatter)
 {
 }
示例#16
0
 internal override EmailMessage CreateEmailMessage(EmailSinkData sinkParameters, LogEntry logEntry, ILogFormatter formatter)
 {
     return(new MockEmailMessage(sinkParameters, logEntry, formatter));
 }