public void LogAllowEventWithSuccessOff()
        {
            string logFile = Path.Combine(Path.GetTempPath(), "Log2.xml");
            if (File.Exists(logFile)) File.Delete(logFile);

            FileXmlLogger logger = new FileXmlLogger();
            logger.AuditFileLocation = logFile;
            logger.LogSuccessfulEvents = false;

            logger.LogEvent("A project", "A user", SecurityEvent.ForceBuild, SecurityRight.Allow, "A message");
            Assert.IsFalse(File.Exists(logFile), "Audit log was generated");
        }
        public void LogDenyEventWithFailureOn()
        {
            string logFile = Path.Combine(Path.GetTempPath(), "Log1.xml");
            if (File.Exists(logFile)) File.Delete(logFile);

            FileXmlLogger logger = new FileXmlLogger();
            logger.AuditFileLocation = logFile;
            logger.LogFailureEvents = true;

            logger.LogEvent("A project", "A user", SecurityEvent.ForceBuild, SecurityRight.Deny, "A message");
            Assert.IsTrue(File.Exists(logFile), "Audit log not generated");
            string actual = File.ReadAllText(logFile);
            string expected = "<event>" +
                    "<dateTime>[^<]*</dateTime>" +
                    "<project>A project</project>" +
                    "<user>A user</user>" +
                    "<type>ForceBuild</type>" +
                    "<outcome>Deny</outcome>" +
                    "<message>A message</message>" +
                "</event>";
            RunRegexTest(expected, actual);
        }
        public void LogEmptyEvent()
        {
            string logFile = Path.Combine(Path.GetTempPath(), "Log1.xml");
            if (File.Exists(logFile)) File.Delete(logFile);

            FileXmlLogger logger = new FileXmlLogger();
            logger.AuditFileLocation = logFile;

            logger.LogEvent(null, null, SecurityEvent.ForceBuild, SecurityRight.Inherit, null);
            Assert.IsTrue(File.Exists(logFile), "Audit log not generated");
            string actual = File.ReadAllText(logFile);
            string expected = "<event>" +
                    "<dateTime>[^<]*</dateTime>" +
                    "<type>ForceBuild</type>" +
                "</event>";
            RunRegexTest(expected, actual);
        }