@@ -205,5 +205,69 @@ public async Task TestFlushInterruptedWhenNoFileExist(IEventPipelineProvider pro
205
205
_mockHttpClient . Verify ( o => o . Upload ( _bytes ) , Times . Exactly ( 0 ) ) ;
206
206
_storage . Verify ( o => o . RemoveFile ( _file ) , Times . Exactly ( 0 ) ) ;
207
207
}
208
+
209
+ [ Theory ]
210
+ [ MemberData ( nameof ( GetPipelineProvider ) ) ]
211
+ public void TestConfigWithEventPipelineProviders ( IEventPipelineProvider provider )
212
+ {
213
+ // Just validate that the provider is used in the configuration
214
+ var config = new Configuration (
215
+ writeKey : "123" ,
216
+ autoAddSegmentDestination : false ,
217
+ useSynchronizeDispatcher : true ,
218
+ flushInterval : 0 ,
219
+ flushAt : 2 ,
220
+ httpClientProvider : new MockHttpClientProvider ( _mockHttpClient ) ,
221
+ storageProvider : new MockStorageProvider ( _storage ) ,
222
+ eventPipelineProvider : provider
223
+ ) ;
224
+ var analytics = new Analytics ( config ) ;
225
+ analytics . Track ( "test" ) ;
226
+ }
227
+
228
+ [ Fact ]
229
+ public void TestConfigWithCustomEventPipelineProvider ( )
230
+ {
231
+ // Just validate that the provider is used in the configuration
232
+ var config = new Configuration (
233
+ writeKey : "123" ,
234
+ useSynchronizeDispatcher : true ,
235
+ flushInterval : 0 ,
236
+ flushAt : 1 ,
237
+ httpClientProvider : new MockHttpClientProvider ( _mockHttpClient ) ,
238
+ storageProvider : new MockStorageProvider ( _storage ) ,
239
+ eventPipelineProvider : new CustomEventPipelineProvider ( )
240
+ ) ;
241
+ Assert . Throws < NotImplementedException > ( ( ) => {
242
+ var analytics = new Analytics ( config ) ;
243
+ analytics . Track ( "test" ) ;
244
+ analytics . Flush ( ) ;
245
+ } ) ;
246
+ }
247
+
248
+
249
+ public class CustomEventPipelineProvider : IEventPipelineProvider
250
+ {
251
+ public CustomEventPipelineProvider ( )
252
+ {
253
+ }
254
+
255
+ public IEventPipeline Create ( Analytics analytics , string key )
256
+ {
257
+ // Custom implementation
258
+ return new CustomEventPipeline ( analytics , key ) ;
259
+ }
260
+
261
+ private class CustomEventPipeline : IEventPipeline
262
+ {
263
+ public CustomEventPipeline ( Analytics analytics , string key ) { }
264
+ public bool Running => throw new NotImplementedException ( ) ;
265
+ public string ApiHost { get => throw new NotImplementedException ( ) ; set => throw new NotImplementedException ( ) ; }
266
+ public void Flush ( ) => throw new NotImplementedException ( ) ;
267
+ public void Put ( RawEvent @event ) => throw new NotImplementedException ( ) ;
268
+ public void Start ( ) => throw new NotImplementedException ( ) ;
269
+ public void Stop ( ) => throw new NotImplementedException ( ) ;
270
+ }
271
+ }
208
272
}
209
273
}
0 commit comments