3 using System
.Collections
;
9 public class EventTracker
{
11 private enum EventType
{
17 public EventType Type
;
21 object big_lock
= new object ();
22 ArrayList expected_events
= new ArrayList ();
24 public EventTracker ()
29 ////////////////////////////////////////////////////////
31 public void ExpectingAdded (string uri
)
35 // Adding anything always generates a paired
37 ExpectingSubtracted (uri
);
39 Event ev
= new Event ();
40 ev
.Type
= EventType
.Added
;
42 expected_events
.Add (ev
);
44 //Log.Spew ("Expecting Added {0}", uri);
48 public void ExpectingSubtracted (string uri
)
51 Event ev
= new Event ();
52 ev
.Type
= EventType
.Subtracted
;
54 expected_events
.Add (ev
);
56 //Log.Spew ("Expecting Subtracted {0}", uri);
60 ////////////////////////////////////////////////////////
62 private void GotEvent (EventType type
, string uri
)
65 for (int i
= 0; i
< expected_events
.Count
; ++i
) {
66 Event ev
= (Event
) expected_events
[i
];
67 if (ev
.Type
== type
&& ev
.Uri
== uri
) {
68 expected_events
.RemoveAt (i
);
72 throw new Exception ("Spurious event " + type
+ " " + uri
);
76 public void GotAddedEvent (string uri
)
78 GotEvent (EventType
.Added
, uri
);
81 public void GotSubtractedEvent (string uri
)
83 GotEvent (EventType
.Subtracted
, uri
);