private void SendReportUsingFilter(string filterString, EventSource source = EventSource.EventLog, string externalEvents = "")
        {
            var filterConfig   = new FilterConfiguration(filterString, TimeSpan.FromHours(12), 100, "", "Security", eventSource: source, externalEventsXml: externalEvents);
            var logEventFilter = new LogEventFilter(_eventReader, filterConfig);

            _radonExecutor = new RadonExecutor(_currentEmailConfig, filterConfig, _mockEventIdentificationStore, logEventFilter);
            _radonExecutor.SendReport(_radonExecutor.GetLogEvents());
        }
        public void ShouldUseExternalEventsSourceIfSelected()
        {
            var filterConfig = new FilterConfiguration("1=1", TimeSpan.FromHours(12), 100, "", Path.GetRandomFileName(), EventSource.External, "<Events><Event><Message>External event message</Message></Event></Events>");
            var mockConfig   = MockRepository.GenerateMock <IRadonConfigurationManager>();

            mockConfig.Expect(c => c.GetEmailConfig()).Return(_currentEmailConfig);
            mockConfig.Expect(c => c.GetFilterConfig()).Return(filterConfig);

            _radonExecutor = new RadonExecutor(mockConfig);
            _radonExecutor.SendReport(_radonExecutor.GetLogEvents());

            Assert.That(_smtpServer.ReceivedEmailCount, Is.EqualTo(1), "An email should have been sent");

            var body = SmtpSenderTest.ParseMessageBody(_smtpServer.ReceivedEmail.Single().Body);

            Assert.That(body, Does.Contain("External event message"));
        }
Exemplo n.º 3
0
        public void SendReport_ShouldSendEventsInReport()
        {
            var myEvents = new List <LogEvent> {
                new LogEvent {
                    Message = "oho!!"
                }, new LogEvent {
                    Message = "vau!"
                }
            };

            _mockEmailConfiguration.Expect(m => m.GetReportSender()).Return(_mockReportSender);

            _radonExecutor.SendReport(myEvents);

            _mockEmailConfiguration.AssertWasCalled(m => m.GetReportSender());
            _mockReportSender.AssertWasCalled(sender => sender.SendReport(Arg <string> .Matches(m => m.Contains("2 latest previously unreported events")), Arg <string> .Is.Anything));
            _mockReportSender.AssertWasCalled(sender => sender.SendReport(Arg <string> .Matches(m => m.Contains("oho!!")), Arg <string> .Is.Anything));
            _mockReportSender.AssertWasCalled(sender => sender.SendReport(Arg <string> .Matches(m => m.Contains("vau!")), Arg <string> .Is.Anything));
        }
Exemplo n.º 4
0
        public RadonResult ExecuteRadon()
        {
            var result = new RadonResult();
            var events = _executor.GetLogEvents();

            if (events.Any())
            {
                _executor.SendReport(events);
                _executor.SaveAlreadyReportedEventIdentification(events.First());

                result.UserResultMessage = string.Format("Mail sent to {0}", this._executor.EmailConfig.RecipientsAsString);
                result.Success           = true;
                result.ActionSkipped     = false;
            }
            else
            {
                result.UserResultMessage = "No events. No mail has been sent from FRENDS Radon.";
                result.Success           = true;
                result.ActionSkipped     = true;
            }
            result.UnreportedEventsCount = events.Count;

            return(result);
        }