~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/mono-addins/Test/UnitTests/TestEvents.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
using System;
 
3
using System.Collections;
 
4
using NUnit.Framework;
 
5
using Mono.Addins;
 
6
using SimpleApp;
 
7
 
 
8
namespace UnitTests
 
9
{
 
10
        [TestFixture()]
 
11
        public class TestEvents: TestBase
 
12
        {
 
13
                int notifyCount;
 
14
                int addCount;
 
15
                int removeCount;
 
16
                int eventCount;
 
17
 
 
18
                Counter[] counters = new Counter [3];
 
19
                
 
20
                class Counter
 
21
                {
 
22
                        public int notifyCount;
 
23
                        public int addCount;
 
24
                        public int removeCount;
 
25
                        public int eventCount;
 
26
                        
 
27
                        public void Reset ()
 
28
                        {
 
29
                                notifyCount = 0;
 
30
                                addCount = 0;
 
31
                                removeCount = 0;
 
32
                                eventCount = 0;
 
33
                        }
 
34
                        
 
35
                        public void Check (string test, int notifyCount, int addCount, int removeCount, int eventCount)
 
36
                        {
 
37
                                Assert.AreEqual (notifyCount, this.notifyCount, test + " (notifyCount)");
 
38
                                Assert.AreEqual (addCount, this.addCount, test + " (addCount)");
 
39
                                Assert.AreEqual (removeCount, this.removeCount, test + " (removeCount)");
 
40
                                Assert.AreEqual (eventCount, this.eventCount, test + " (eventCount)");
 
41
                                Reset ();
 
42
                        }
 
43
                        
 
44
                        public void Update (ExtensionNodeEventArgs args)
 
45
                        {
 
46
                                notifyCount++;
 
47
                                if (args.Change == ExtensionChange.Add)
 
48
                                        addCount++;
 
49
                                else
 
50
                                        removeCount++;
 
51
                        }
 
52
                        
 
53
                        public void Update (ExtensionEventArgs args)
 
54
                        {
 
55
                                eventCount++;
 
56
                        }
 
57
                }
 
58
 
 
59
                string errorTag;
 
60
                
 
61
                [Test()]
 
62
                public void TestLoadEvents()
 
63
                {
 
64
                        errorTag = "";
 
65
                        notifyCount = addCount = removeCount = eventCount = 0;
 
66
                        
 
67
                        Assert.AreEqual (4, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 1");
 
68
                        
 
69
                        AddinManager.Registry.DisableAddin ("SimpleApp.HelloWorldExtension,0.1.0");
 
70
                        AddinManager.Registry.DisableAddin ("SimpleApp.FileContentExtension,0.1.0");
 
71
 
 
72
                        Assert.AreEqual (2, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 2");
 
73
                        
 
74
                        string[] addinExtensions = new string[] {
 
75
                                "/SimpleApp/Writers",
 
76
                                "/SimpleApp.Core/TypeExtensions/SimpleApp.ISampleExtender",
 
77
                                "/SimpleApp.Core/TypeExtensions/SimpleApp.IWriterWithMetadata",
 
78
                                "/SimpleApp/NodesWithAttribute",
 
79
                                "/SimpleApp/DataExtensionWithAttribute",
 
80
                        };
 
81
 
 
82
                        InitChangedExtensionEvent (addinExtensions);
 
83
                        
 
84
                        AddinManager.ExtensionChanged += OnExtensionChangedHandler;
 
85
                        AddinManager.AddExtensionNodeHandler ("/SimpleApp/Writers", OnExtensionChange);
 
86
                        
 
87
                        Assert.IsTrue (errorTag == "", errorTag);
 
88
                        Assert.AreEqual (2, notifyCount, "notifyCount 1");
 
89
                        Assert.AreEqual (2, addCount, "addCount 1");
 
90
                        Assert.AreEqual (0, removeCount, "removeCount 1");
 
91
                        Assert.AreEqual (0, eventCount, "eventCount 1");
 
92
                        
 
93
                        notifyCount = addCount = removeCount = eventCount = 0;
 
94
                        AddinManager.Registry.EnableAddin ("SimpleApp.HelloWorldExtension,0.1.0");
 
95
                        
 
96
                        Assert.AreEqual (3, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 3");
 
97
                        
 
98
                        CheckChangedExtensionEvent ("events check 3");
 
99
                        Assert.IsTrue (errorTag == "", errorTag);
 
100
                        Assert.AreEqual (1, notifyCount, "notifyCount 2");
 
101
                        Assert.AreEqual (1, addCount, "addCount 2");
 
102
                        Assert.AreEqual (0, removeCount, "removeCount 2");
 
103
                        Assert.AreEqual (addinExtensions.Length, eventCount, "eventCount 2"); // 1 for each extension of HelloWorldExtension, not only /SimpleApp/Writers
 
104
                        
 
105
                        // Now unregister
 
106
                        
 
107
                        notifyCount = addCount = removeCount = eventCount = 0;
 
108
                        AddinManager.ExtensionChanged -= OnExtensionChangedHandler;
 
109
                        AddinManager.RemoveExtensionNodeHandler ("/SimpleApp/Writers", OnExtensionChange);
 
110
                        
 
111
                        AddinManager.Registry.EnableAddin ("SimpleApp.FileContentExtension,0.1.0");
 
112
                        
 
113
                        Assert.IsTrue (errorTag == "", errorTag);
 
114
                        Assert.AreEqual (0, notifyCount, "notifyCount 3");
 
115
                        Assert.AreEqual (0, addCount, "addCount 3");
 
116
                        Assert.AreEqual (0, removeCount, "removeCount 3");
 
117
                        Assert.AreEqual (0, eventCount, "eventCount 3");
 
118
                        
 
119
                        Assert.AreEqual (4, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 4");
 
120
                }
 
121
                
 
122
                void OnExtensionChange (object s, ExtensionNodeEventArgs args)
 
123
                {
 
124
                        notifyCount++;
 
125
                        
 
126
                        TypeExtensionNode nod = args.ExtensionNode as TypeExtensionNode;
 
127
                        if (nod == null)
 
128
                                errorTag += "t1 ";
 
129
 
 
130
                        if (args.Change == ExtensionChange.Add) {
 
131
                                addCount++;
 
132
                                        
 
133
                                IWriter w = ((TypeExtensionNode)args.ExtensionNode).CreateInstance () as IWriter;
 
134
                                if (w == null)
 
135
                                        errorTag += "t2 ";
 
136
                        }
 
137
                        if (args.Change == ExtensionChange.Remove) {
 
138
                                removeCount++;
 
139
                        }
 
140
                }
 
141
                
 
142
                ArrayList expectedPathsEvent = new ArrayList ();
 
143
                void OnExtensionChangedHandler (object s, ExtensionEventArgs args)
 
144
                {
 
145
                        eventCount++;
 
146
                        if (expectedPathsEvent.Contains (args.Path))
 
147
                                expectedPathsEvent.Remove (args.Path);
 
148
                        else
 
149
                                errorTag += "t4 (" + args.Path + ") ";
 
150
                }
 
151
                
 
152
                void InitChangedExtensionEvent (params string[] expectedPaths)
 
153
                {
 
154
                        expectedPathsEvent.Clear ();
 
155
                        expectedPathsEvent.AddRange (expectedPaths);
 
156
                }
 
157
                
 
158
                void CheckChangedExtensionEvent (string tag)
 
159
                {
 
160
                        Assert.IsTrue (expectedPathsEvent.Count == 0, tag + ": Event not fired for paths: " + string.Join (", ", (string[])expectedPathsEvent.ToArray (typeof(string))));
 
161
                }
 
162
                
 
163
                
 
164
                [Test()]
 
165
                public void TestUnloadEvents()
 
166
                {
 
167
                        errorTag = "";
 
168
                        notifyCount = addCount = removeCount = eventCount = 0;
 
169
                        
 
170
                        // All addins are enabled
 
171
                        
 
172
                        Assert.AreEqual (4, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 1");
 
173
                        
 
174
                        string[] addinExtensions = new string[] {
 
175
                                "/SimpleApp/Writers",
 
176
                                "/SimpleApp.Core/TypeExtensions/SimpleApp.ISampleExtender",
 
177
                                "/SimpleApp.Core/TypeExtensions/SimpleApp.IWriterWithMetadata",
 
178
                                "/SimpleApp/NodesWithAttribute",
 
179
                                "/SimpleApp/DataExtensionWithAttribute",
 
180
                        };
 
181
 
 
182
                        InitChangedExtensionEvent (addinExtensions);
 
183
                        
 
184
                        AddinManager.ExtensionChanged += OnExtensionChangedHandler;
 
185
                        AddinManager.AddExtensionNodeHandler ("/SimpleApp/Writers", OnExtensionChange);
 
186
                        
 
187
                        Assert.IsTrue (errorTag == "", errorTag);
 
188
                        Assert.AreEqual (4, notifyCount, "notifyCount 1");
 
189
                        Assert.AreEqual (4, addCount, "addCount 1");
 
190
                        Assert.AreEqual (0, removeCount, "removeCount 1");
 
191
                        Assert.AreEqual (0, eventCount, "eventCount 1");
 
192
                        
 
193
                        notifyCount = addCount = removeCount = eventCount = 0;
 
194
                        AddinManager.Registry.DisableAddin ("SimpleApp.HelloWorldExtension,0.1.0");
 
195
                        
 
196
                        Assert.AreEqual (3, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 2");
 
197
 
 
198
                        CheckChangedExtensionEvent ("events check 2");
 
199
                        Assert.IsTrue (errorTag == "", errorTag);
 
200
                        Assert.AreEqual (1, notifyCount, "notifyCount 2");
 
201
                        Assert.AreEqual (0, addCount, "addCount 2");
 
202
                        Assert.AreEqual (1, removeCount, "removeCount 2");
 
203
                        Assert.AreEqual (addinExtensions.Length, eventCount, "eventCount 2"); // 1 for each extension of HelloWorldExtension, not only /SimpleApp/Writers
 
204
                        
 
205
                        InitChangedExtensionEvent ("/SimpleApp/Writers",
 
206
                                                   "/SimpleApp.Core/TypeExtensions/SimpleApp.ISampleExtender",
 
207
                                                   "/SimpleApp/NodeWithChildren",
 
208
                                                   "/SystemInformation/Modules");
 
209
                        notifyCount = addCount = removeCount = eventCount = 0;
 
210
                        AddinManager.Registry.DisableAddin ("SimpleApp.FileContentExtension,0.1.0");
 
211
                        
 
212
                        Assert.AreEqual (2, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 3");
 
213
                        
 
214
                        CheckChangedExtensionEvent ("events check 3");
 
215
                        Assert.IsTrue (errorTag == "", errorTag);
 
216
                        Assert.AreEqual (1, notifyCount, "notifyCount 3");
 
217
                        Assert.AreEqual (0, addCount, "addCount 3");
 
218
                        Assert.AreEqual (1, removeCount, "removeCount 3");
 
219
                        Assert.AreEqual (4, eventCount, "eventCount 3");
 
220
                        
 
221
                        // Now unregister
 
222
                        
 
223
                        AddinManager.ExtensionChanged -= OnExtensionChangedHandler;
 
224
                        AddinManager.RemoveExtensionNodeHandler ("/SimpleApp/Writers", OnExtensionChange);
 
225
                        
 
226
                        notifyCount = addCount = removeCount = eventCount = 0;
 
227
                        AddinManager.Registry.DisableAddin ("SimpleApp.CommandExtension,0.1.0");
 
228
                        
 
229
                        Assert.AreEqual (0, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 4");
 
230
                        
 
231
                        Assert.IsTrue (errorTag == "", errorTag);
 
232
                        Assert.AreEqual (0, notifyCount, "notifyCount 4");
 
233
                        Assert.AreEqual (0, addCount, "addCount 4");
 
234
                        Assert.AreEqual (0, removeCount, "removeCount 4");
 
235
                        Assert.AreEqual (0, eventCount, "eventCount 4");
 
236
                }
 
237
                
 
238
                [Test]
 
239
                public void TestExtensionContextEvents ()
 
240
                {
 
241
                        AddinManager.Registry.EnableAddin ("SimpleApp.SystemInfoExtension,0.1.0");
 
242
                        
 
243
                        counters [0] = new Counter ();
 
244
                        counters [1] = new Counter ();
 
245
                        counters [2] = new Counter ();
 
246
                        
 
247
                        GlobalInfoCondition.Value = "";
 
248
                        
 
249
                        ExtensionContext c1 = AddinManager.CreateExtensionContext ();
 
250
                        ExtensionContext c2 = AddinManager.CreateExtensionContext ();
 
251
                        
 
252
                        ParameterInfoCondition pinfo1 = new ParameterInfoCondition ();
 
253
                        ParameterInfoCondition pinfo2 = new ParameterInfoCondition ();
 
254
                        
 
255
                        pinfo1.Value = "";
 
256
                        pinfo2.Value = "";
 
257
                        
 
258
                        c1.RegisterCondition ("InputParameter", pinfo1);
 
259
                        c2.RegisterCondition ("InputParameter", pinfo2);
 
260
                        
 
261
                        // Test registering
 
262
                         
 
263
                        c1.GetExtensionNode ("/SimpleApp/ExtraWriters").ExtensionNodeChanged += NodeListener_1;
 
264
                        c2.AddExtensionNodeHandler ("/SimpleApp/ExtraWriters", NodeListener_2);
 
265
                        AddinManager.AddExtensionNodeHandler ("/SimpleApp/Writers2", NodeListener_g);
 
266
                        
 
267
                        counters[0].Check ("t1.0", 2, 2, 0, 0);
 
268
                        counters[1].Check ("t1.1", 2, 2, 0, 0);
 
269
                        counters[2].Check ("t1.2", 2, 2, 0, 0);
 
270
                        
 
271
                        c1.AddExtensionNodeHandler ("/SimpleApp/Writers2", NodeListener_1);
 
272
                        c2.AddExtensionNodeHandler ("/SimpleApp/Writers2", NodeListener_2);
 
273
 
 
274
                        counters[1].Check ("t2.1", 2, 2, 0, 0);
 
275
                        counters[2].Check ("t2.2", 2, 2, 0, 0);
 
276
 
 
277
                        c1.ExtensionChanged += ExtensionListener_1;
 
278
                        c2.ExtensionChanged += ExtensionListener_2;
 
279
                        AddinManager.ExtensionChanged += ExtensionListener_g;
 
280
                        
 
281
                        counters[0].Check ("t3.0", 0, 0, 0, 0);
 
282
                        counters[1].Check ("t3.1", 0, 0, 0, 0);
 
283
                        counters[2].Check ("t3.2", 0, 0, 0, 0);
 
284
                        
 
285
                        CheckWriters ("t4.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
286
                        CheckWriters ("t4.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
287
                        CheckWriters ("t4.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
288
                        CheckWriters ("t4.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
 
289
                        CheckWriters ("t4.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
 
290
                        
 
291
                        // Test change global var
 
292
                        
 
293
                        GlobalInfoCondition.Value = "yes2";
 
294
                        
 
295
                        counters[0].Check ("t5.0", 2, 2, 0, 1);
 
296
                        counters[1].Check ("t5.1", 2, 2, 0, 1);
 
297
                        counters[2].Check ("t5.2", 2, 2, 0, 1);
 
298
                        
 
299
                        CheckWriters ("t6.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
 
300
                        CheckWriters ("t6.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
 
301
                        CheckWriters ("t6.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
 
302
                        CheckWriters ("t6.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
 
303
                        CheckWriters ("t6.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
 
304
                        
 
305
                        // Test change global var
 
306
                        
 
307
                        GlobalInfoCondition.Value = "no";
 
308
                        
 
309
                        counters[0].Check ("t7.0", 2, 0, 2, 1);
 
310
                        counters[1].Check ("t7.1", 5, 3, 2, 2);
 
311
                        counters[2].Check ("t7.2", 5, 3, 2, 2);
 
312
                        
 
313
                        CheckWriters ("t7.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
314
                        CheckWriters ("t7.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
315
                        CheckWriters ("t7.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
316
                        CheckWriters ("t7.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:cn1", "cmd:cn2", "cmd:cn3");
 
317
                        CheckWriters ("t7.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:cn1", "cmd:cn2", "cmd:cn3");
 
318
                        
 
319
                        // Test reset global var
 
320
                        
 
321
                        GlobalInfoCondition.Value = "";
 
322
                        
 
323
                        counters[0].Check ("t8.0", 0, 0, 0, 0);
 
324
                        counters[1].Check ("t8.1", 3, 0, 3, 1);
 
325
                        counters[2].Check ("t8.2", 3, 0, 3, 1);
 
326
                        
 
327
                        CheckWriters ("t8.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
328
                        CheckWriters ("t8.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
329
                        CheckWriters ("t8.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
330
                        CheckWriters ("t8.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
 
331
                        CheckWriters ("t8.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
 
332
                        
 
333
                        // Test local var
 
334
                        
 
335
                        pinfo1.Value = "simple";
 
336
                        
 
337
                        counters[0].Check ("t9.0", 0, 0, 0, 0);
 
338
                        counters[1].Check ("t9.1", 2, 2, 0, 1);
 
339
                        counters[2].Check ("t9.2", 0, 0, 0, 0);
 
340
                        
 
341
                        CheckWriters ("t9.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
342
                        CheckWriters ("t9.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
343
                        CheckWriters ("t9.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
344
                        CheckWriters ("t9.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
 
345
                        CheckWriters ("t9.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
 
346
                        
 
347
                        // Test local var
 
348
                        
 
349
                        pinfo2.Value = "simple";
 
350
                        
 
351
                        counters[0].Check ("t10.0", 0, 0, 0, 0);
 
352
                        counters[1].Check ("t10.1", 0, 0, 0, 0);
 
353
                        counters[2].Check ("t10.2", 2, 2, 0, 1);
 
354
                        
 
355
                        CheckWriters ("t10.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
356
                        CheckWriters ("t10.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
357
                        CheckWriters ("t10.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
358
                        CheckWriters ("t10.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
 
359
                        CheckWriters ("t10.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
 
360
                        
 
361
                        // Test unset local var
 
362
                        
 
363
                        pinfo2.Value = "";
 
364
                        
 
365
                        counters[0].Check ("t10.0", 0, 0, 0, 0);
 
366
                        counters[1].Check ("t10.1", 0, 0, 0, 0);
 
367
                        counters[2].Check ("t10.2", 2, 0, 2, 1);
 
368
                        
 
369
                        CheckWriters ("t10.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
370
                        CheckWriters ("t10.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
371
                        CheckWriters ("t10.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
372
                        CheckWriters ("t10.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
 
373
                        CheckWriters ("t10.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
 
374
                        
 
375
                        // Combined global/local var change
 
376
                        
 
377
                        GlobalInfoCondition.Value = "yes1";
 
378
                        pinfo2.Value = "x1";
 
379
                        
 
380
                        counters[0].Check ("t11.0", 0, 0, 0, 0);
 
381
                        counters[1].Check ("t11.1", 0, 0, 0, 0);
 
382
                        counters[2].Check ("t11.2", 2, 2, 0, 1);
 
383
                        
 
384
                        CheckWriters ("t11.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
385
                        CheckWriters ("t11.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
386
                        CheckWriters ("t11.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
 
387
                        CheckWriters ("t11.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
 
388
                        CheckWriters ("t11.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:c3 x1 and yes1", "cmd:c4 x1 and yes1");
 
389
 
 
390
                        GlobalInfoCondition.Value = "";
 
391
                }
 
392
                
 
393
                void CheckWriters (string test, ExtensionContext ctx, string path, params string[] values)
 
394
                {
 
395
                        IWriter[] nodes;
 
396
                        if (ctx != null)
 
397
                                nodes = (IWriter[]) ctx.GetExtensionObjects (path, typeof(IWriter));
 
398
                        else
 
399
                                nodes = (IWriter[]) AddinManager.GetExtensionObjects (path, typeof(IWriter));
 
400
                        
 
401
                        Assert.AreEqual (nodes.Length, values.Length, test + " (count)");
 
402
                        for (int n=0; n<values.Length; n++) {
 
403
                                Assert.AreEqual (values[n], nodes[n].Write(), test + " (result #" + n + ")");
 
404
                        }
 
405
                }
 
406
                
 
407
                void NodeListener_1 (object s, ExtensionNodeEventArgs args)
 
408
                {
 
409
                        counters[1].Update (args);
 
410
                }
 
411
                
 
412
                void NodeListener_2 (object s, ExtensionNodeEventArgs args)
 
413
                {
 
414
                        counters[2].Update (args);
 
415
                }
 
416
                
 
417
                void NodeListener_g (object s, ExtensionNodeEventArgs args)
 
418
                {
 
419
                        counters[0].Update (args);
 
420
                }
 
421
                
 
422
                void ExtensionListener_1 (object s, ExtensionEventArgs args)
 
423
                {
 
424
                        counters[1].Update (args);
 
425
                }
 
426
                
 
427
                void ExtensionListener_2 (object s, ExtensionEventArgs args)
 
428
                {
 
429
                        counters[2].Update (args);
 
430
                }
 
431
                
 
432
                void ExtensionListener_g (object s, ExtensionEventArgs args)
 
433
                {
 
434
                        counters[0].Update (args);
 
435
                }
 
436
        }
 
437
}