Skip to content

Commit 1f4c1c2

Browse files
committed
Added unit tests to cover even more cases.
1 parent 2ca471e commit 1f4c1c2

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

Source/Shared/Plugins/Default/010_EventExclusionPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void Run(EventPluginContext context) {
2020

2121
if (context.Event.IsLog()) {
2222
var minLogLevel = context.Client.Configuration.Settings.GetMinLogLevel(context.Event.Source);
23-
var logLevel = LogLevel.FromString(context.Event.Data.GetValueOrDefault(Event.KnownDataKeys.Level, "Trace").ToString());
23+
var logLevel = LogLevel.FromString(context.Event.Data.GetValueOrDefault(Event.KnownDataKeys.Level, "Other").ToString());
2424

2525
if (logLevel != LogLevel.Other && (logLevel == LogLevel.Off || logLevel < minLogLevel)) {
2626
context.Log.Info("Cancelling log event due to minimum log level.");

Source/Tests/Plugins/PluginTests.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,30 @@ public void EventExclusionPlugin_LogLevels(string source, string level, string s
166166
}
167167

168168
[Theory]
169-
[InlineData(null, null, null, null, true)]
170-
[InlineData("Test", null, null, null, true)]
169+
[InlineData(null, null, null, null, false)]
170+
[InlineData("feature", null, null, null, false)]
171+
[InlineData("feature", "test", null, null, false)]
172+
[InlineData("feature", "test", "@@feature:Test", "true", false)]
173+
[InlineData("feature", "test", "@@feature:Test", "false", true)]
174+
[InlineData("feature", "test", "@@feature:*", "false", true)]
175+
[InlineData("404", "/unknown", "@@404:*", "false", true)]
176+
[InlineData("404", "/unknown", "@@404:/unknown", "false", true)]
177+
[InlineData("404", "/unknown", "@@404:/unknown", "true", false)]
178+
public void EventExclusionPlugin_SourceType(string type, string source, string settingKey, string settingValue, bool cancelled) {
179+
var client = CreateClient();
180+
if (settingKey != null)
181+
client.Configuration.Settings.Add(settingKey, settingValue);
182+
183+
var ev = new Event { Type = type, Source = source };
184+
var context = new EventPluginContext(client, ev);
185+
var plugin = new EventExclusionPlugin();
186+
plugin.Run(context);
187+
Assert.Equal(cancelled, context.Cancel);
188+
}
189+
190+
[Theory]
191+
[InlineData(null, null, null, null, false)]
192+
[InlineData("Test", null, null, null, false)]
171193
[InlineData("Test", "Trace", null, null, true)]
172194
[InlineData("Test", "Warn", null, null, false)]
173195
[InlineData("Test", "Error", SettingsDictionary.KnownKeys.LogLevelPrefix + "Test", "Debug", false)]
@@ -195,7 +217,7 @@ public void EventExclusionPlugin_LogLevelsWithInfoDefault(string source, string
195217
[InlineData("@@error:System.Exception", true)]
196218
[InlineData("@@error:*Exception", true)]
197219
[InlineData("@@error:*", true)]
198-
public void EventExclusionPlugin_SimpleException(string settingKey, bool cancelled) {
220+
public void EventExclusionPlugin_ExceptionType(string settingKey, bool cancelled) {
199221
var client = CreateClient();
200222
if (settingKey != null)
201223
client.Configuration.Settings.Add(settingKey, Boolean.FalseString);

0 commit comments

Comments
 (0)