8
8
using Exceptionless . Plugins . Default ;
9
9
using Exceptionless . Models ;
10
10
using Exceptionless . Models . Data ;
11
+ using Exceptionless . Submission ;
11
12
using Exceptionless . Tests . Utility ;
12
13
using Xunit ;
13
14
using Xunit . Abstractions ;
@@ -41,7 +42,7 @@ public void ConfigurationDefaults_EnsureNoDuplicateTagsOrData() {
41
42
}
42
43
}
43
44
44
- [ Fact ]
45
+ [ Fact ]
45
46
public void ConfigurationDefaults_IgnoredProperties ( ) {
46
47
var client = new ExceptionlessClient ( ) ;
47
48
client . Configuration . DefaultData . Add ( "Message" , "Test" ) ;
@@ -58,6 +59,73 @@ public void ConfigurationDefaults_IgnoredProperties() {
58
59
Assert . Equal ( 1 , context . Event . Data . Count ) ;
59
60
Assert . Equal ( "Test" , context . Event . Data [ "Message" ] ) ;
60
61
}
62
+
63
+ [ Fact ]
64
+ public void IgnoreUserAgentPlugin_DiscardBot ( ) {
65
+ var client = new ExceptionlessClient ( ) ;
66
+ client . Configuration . AddUserAgentBotPatterns ( "*Bot*" ) ;
67
+ var plugin = new IgnoreUserAgentPlugin ( ) ;
68
+
69
+ var ev = new Event ( ) ;
70
+ var context = new EventPluginContext ( client , ev ) ;
71
+ plugin . Run ( context ) ;
72
+ Assert . False ( context . Cancel ) ;
73
+
74
+ ev . AddRequestInfo ( new RequestInfo { UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4" } ) ;
75
+ context = new EventPluginContext ( client , ev ) ;
76
+ plugin . Run ( context ) ;
77
+ Assert . False ( context . Cancel ) ;
78
+
79
+ ev . AddRequestInfo ( new RequestInfo { UserAgent = "Mozilla/5.0 (compatible; bingbot/2.0 +http://www.bing.com/bingbot.htm)" } ) ;
80
+ context = new EventPluginContext ( client , ev ) ;
81
+ plugin . Run ( context ) ;
82
+ Assert . True ( context . Cancel ) ;
83
+ }
84
+
85
+ [ Fact ]
86
+ public void HandleAggregateExceptionsPlugin_SingleInnerException ( ) {
87
+ var client = new ExceptionlessClient ( ) ;
88
+ var plugin = new HandleAggregateExceptionsPlugin ( ) ;
89
+
90
+ var exceptionOne = new Exception ( "one" ) ;
91
+ var exceptionTwo = new Exception ( "two" ) ;
92
+
93
+ var context = new EventPluginContext ( client , new Event ( ) ) ;
94
+ context . ContextData . SetException ( exceptionOne ) ;
95
+ plugin . Run ( context ) ;
96
+ Assert . False ( context . Cancel ) ;
97
+
98
+ context = new EventPluginContext ( client , new Event ( ) ) ;
99
+ context . ContextData . SetException ( new AggregateException ( exceptionOne ) ) ;
100
+ plugin . Run ( context ) ;
101
+ Assert . False ( context . Cancel ) ;
102
+ Assert . Equal ( exceptionOne , context . ContextData . GetException ( ) ) ;
103
+
104
+ context = new EventPluginContext ( client , new Event ( ) ) ;
105
+ context . ContextData . SetException ( new AggregateException ( exceptionOne , exceptionTwo ) ) ;
106
+ plugin . Run ( context ) ;
107
+ Assert . False ( context . Cancel ) ;
108
+ Assert . Equal ( exceptionOne , context . ContextData . GetException ( ) ) ;
109
+ }
110
+
111
+ [ Fact ]
112
+ public void HandleAggregateExceptionsPlugin_MultipleInnerException ( ) {
113
+ var submissionClient = new InMemorySubmissionClient ( ) ;
114
+ var client = new ExceptionlessClient ( "LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw" ) ;
115
+ client . Configuration . Resolver . Register < ISubmissionClient > ( submissionClient ) ;
116
+
117
+ var plugin = new HandleAggregateExceptionsPlugin ( ) ;
118
+ var exceptionOne = new Exception ( "one" ) ;
119
+ var exceptionTwo = new Exception ( "two" ) ;
120
+
121
+ var context = new EventPluginContext ( client , new Event ( ) ) ;
122
+ context . ContextData . SetException ( new AggregateException ( exceptionOne , exceptionTwo ) ) ;
123
+ plugin . Run ( context ) ;
124
+ Assert . True ( context . Cancel ) ;
125
+
126
+ client . ProcessQueue ( ) ;
127
+ Assert . Equal ( 2 , submissionClient . Events . Count ) ;
128
+ }
61
129
62
130
[ Fact ]
63
131
public void ErrorPlugin_DiscardDuplicates ( ) {
@@ -143,7 +211,7 @@ public void ErrorPlugin_CanProcessDifferentExceptionDataDictionaryTypes(IDiction
143
211
Assert . Equal ( processedDataItemCount , error . Data . Count ) ;
144
212
}
145
213
}
146
-
214
+
147
215
[ Fact ]
148
216
public void ErrorPlugin_CopyExceptionDataToRootErrorData ( ) {
149
217
var errorPlugins = new List < IEventPlugin > {
0 commit comments