public static SinkSubscription<EmailSink> LogToEmail(this IObservable<EventEntry> eventStream, string host, int port, string recipients, string subject, string credentials, IEventTextFormatter formatter = null) { var sink = new EmailSink(host, port, recipients, subject, credentials, formatter); var subscription = eventStream.Subscribe(sink); return new SinkSubscription<EmailSink>(subscription, sink); }
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; }
public IObserver<EventEntry> CreateSink(XElement element) { var host = (string)element.Attribute("host"); var port = (int)element.Attribute("port"); var recipients = (string)element.Attribute("recipients"); var subject = (string)element.Attribute("subject"); var credentials = (string)element.Attribute("credentials"); var formatter = FormatterElementFactory.Get(element); var sink = new EmailSink(host, port, recipients, subject, credentials, formatter); return sink; }
public void MissingRequiredParameters() { // create a flatfile sink without the required parameters EmailSink badSink = new EmailSink(); badSink.Initialize(new TestLogSinkConfigurationView(new EmailSinkData())); badSink.SendMessage(CommonUtil.GetDefaultLogEntry()); Assert.AreEqual(1, CommonUtil.EventLogEntryCount()); string entry = CommonUtil.GetLastEventLogEntry(); string expected = SR.DefaultLogDestinationMessage + Environment.NewLine + Environment.NewLine + "E-Mail Sink is missing one of these keys in the Distributor's XML file: ToAddress, FromAddress, and/or SmtpServer"; Assert.IsTrue(entry.IndexOf(expected) > -1, "confirm error message"); expected = CommonUtil.FormattedMessage; Assert.IsTrue(entry.IndexOf(expected) > -1, "confirm message is inside"); }