Пример #1
0
 private void AssertLogFileToParse(IPBanLogFileToParse file, string failedLoginRegex, int maxFileSize, string pathAndMask, int pingInterval, string platformRegex,
                                   bool recursive, string source, string successfulLoginRegex)
 {
     Assert.AreEqual(IPBanConfig.ParseRegex(failedLoginRegex)?.ToString(), IPBanConfig.ParseRegex(file.FailedLoginRegex)?.ToString());
     Assert.AreEqual(maxFileSize, file.MaxFileSize);
     Assert.AreEqual(Regex.Replace(pathAndMask.Trim().Replace('\n', '|'), "\\s+", string.Empty), Regex.Replace(file.PathAndMask.Trim().Replace('\n', '|'), "\\s+", string.Empty));
     Assert.AreEqual(pingInterval, file.PingInterval);
     Assert.AreEqual(IPBanConfig.ParseRegex(platformRegex)?.ToString(), IPBanConfig.ParseRegex(file.PlatformRegex)?.ToString());
     Assert.AreEqual(recursive, file.Recursive);
     Assert.AreEqual(source, file.Source);
     Assert.AreEqual(IPBanConfig.ParseRegex(successfulLoginRegex)?.ToString(), IPBanConfig.ParseRegex(file.SuccessfulLoginRegex)?.ToString());
 }
Пример #2
0
 private void AssertLogFileToParse(IPBanLogFileToParse file, string failedLoginRegex, string failedLoginRegexTimestampFormat,
                                   int maxFileSize, string pathAndMask, int pingInterval, string platformRegex,
                                   string source, string successfulLoginRegex, string successfulLoginRegexTimestampFormat,
                                   LogLevel failedLogLevel = LogLevel.Warning, LogLevel successLogLevel = LogLevel.Warning)
 {
     Assert.AreEqual(IPBanConfig.ParseRegex(failedLoginRegex)?.ToString(), IPBanConfig.ParseRegex(file.FailedLoginRegex)?.ToString());
     Assert.AreEqual(failedLoginRegexTimestampFormat, file.FailedLoginRegexTimestampFormat);
     Assert.AreEqual(maxFileSize, file.MaxFileSize);
     Assert.AreEqual(Regex.Replace(pathAndMask.Trim().Replace('\n', '|'), "\\s+", string.Empty), Regex.Replace(file.PathAndMask.Trim().Replace('\n', '|'), "\\s+", string.Empty));
     Assert.AreEqual(pingInterval, file.PingInterval);
     Assert.AreEqual(IPBanConfig.ParseRegex(platformRegex)?.ToString(), IPBanConfig.ParseRegex(file.PlatformRegex)?.ToString());
     Assert.AreEqual(source, file.Source);
     Assert.AreEqual(IPBanConfig.ParseRegex(successfulLoginRegex)?.ToString(), IPBanConfig.ParseRegex(file.SuccessfulLoginRegex)?.ToString());
     Assert.AreEqual(successfulLoginRegexTimestampFormat, file.SuccessfulLoginRegexTimestampFormat);
     Assert.AreEqual(failedLogLevel, file.FailedLoginLogLevel);
     Assert.AreEqual(successLogLevel, file.SuccessfulLoginLogLevel);
 }
Пример #3
0
 private void AssertEventViewerGroup(EventViewerExpressionGroup group, string keywords, int windowsMinimumMajorVersion, int windowsMinimumMinorVersion,
                                     bool notifyOnly, string path, string source, params string[] expressions)
 {
     Assert.NotNull(group);
     Assert.AreEqual(keywords, group.Keywords);
     Assert.AreEqual(ulong.Parse(keywords.Replace("0x", string.Empty), System.Globalization.NumberStyles.HexNumber), group.KeywordsULONG);
     Assert.AreEqual(windowsMinimumMajorVersion, group.MinimumWindowsMajorVersion);
     Assert.AreEqual(windowsMinimumMinorVersion, group.MinimumWindowsMinorVersion);
     Assert.AreEqual(notifyOnly, group.NotifyOnly);
     Assert.AreEqual(path, group.Path);
     Assert.AreEqual(source, group.Source);
     Assert.NotNull(group.Expressions);
     Assert.AreEqual(group.Expressions.Count, expressions.Length / 2);
     for (int i = 0; i < expressions.Length;)
     {
         int   groupIndex = i / 2;
         Regex regex      = IPBanConfig.ParseRegex(group.Expressions[groupIndex].Regex);
         Assert.AreEqual(expressions[i++], group.Expressions[groupIndex].XPath?.Trim());
         Assert.AreEqual(expressions[i++], (regex is null ? string.Empty : regex.ToString()));
     }
 }