public void ShouldSendEmailsAnonymouslyIfNoUsernameOrPasswordGiven()
        {
            this.SendReportUsingFilter("Message.Contains(\"logged on\")");

            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("logon"));
        }
        public void ShouldReportLogonAndLogoffEventsFilteredByEventId()
        {
            this.SendReportUsingFilter("EventID = 4672 Or EventID = 4700"); // apparently, if you use less than or greater than operators, the email body is encoded in base64 - so don't do that

            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("logon"));
        }
        public void CanRunAndReturnsUserResultSuccess()
        {
            const string eventName = "RadonWFTestMessage CanRunAndReturnsUserResultSuccess";

            WriteToLogWithStandardLog(eventName, EventLogEntryType.Error, 666);
            var outParams = RunWorkflow(GetEmailSettings(), GetFilterSettings("EntryType = \"Error\" And EventID = 666"));

            Assert.That(outParams.UserResultMessage, Iz.EqualTo("Mail sent to [email protected]"));
            Assert.That(smtpServer.ReceivedEmailCount, Is.EqualTo(1));
            var body = SmtpSenderTest.ParseMessageBody(smtpServer.ReceivedEmail.Single().Body);

            Assert.That(body, Does.Contain(eventName));
            smtpServer.ClearReceivedEmail();
        }
        public void CanReadOtherThanApplicationLog()
        {
            const string eventName = "TestEvent CanReadOtherThanApplicationLog";

            WriteToLogWithCustomLog("TestLog", "TestLogSource", eventName, null);

            var outParams = RunWorkflow(GetEmailSettings(), GetFilterSettings("", "", "TestLog"));

            Assert.That(outParams.UserResultMessage, Iz.EqualTo("Mail sent to [email protected]"));
            Assert.That(smtpServer.ReceivedEmailCount, Is.EqualTo(1));

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

            Assert.That(body, Does.Contain(eventName));
            smtpServer.ClearReceivedEmail();
        }
        public void CanReadRemoteEventLog()
        {
            const string eventName     = "TestEvent CanReadRemoteEventLog";
            var          remoteMachine = ConfigurationManager.AppSettings["RemoteMachineName"];

            WriteToLogWithCustomLog("Application", "testSource", eventName, remoteMachine);

            var outParams = RunWorkflow(GetEmailSettings(), GetFilterSettings("EntryType = \"Error\" And EventID = 666", remoteMachine, ""));

            Assert.That(outParams.UserResultMessage, Iz.EqualTo("Mail sent to [email protected]"));
            Assert.That(smtpServer.ReceivedEmailCount, Is.EqualTo(1));

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

            Assert.That(body, Does.Contain(eventName));
            smtpServer.ClearReceivedEmail();
        }
        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"));
        }