/// <summary> /// Creates an Event Handler for the EventInfo Passed to Hook it the Event Up to an Event Recorder. /// </summary> private static EventRecorder Monitor(object eventSource, EventInfo eventInfo) { // Create EventRecorder var eventRecorder = new EventRecorder(eventSource, eventInfo.Name); // Subscribe EventRecorder to event var handler = EventSubscriber.GenerateHandler(eventInfo.EventHandlerType, eventRecorder); eventInfo.AddEventHandler(eventSource, handler); return eventRecorder; }
public void CanCodeGenDelegate() { var recorder = new EventRecorder(this, "test"); var testHandler = EventSubscriber.GenerateHandler(typeof(SimpleDelegate), recorder) as SimpleDelegate; Assert.NotNull(testHandler); }
public void Should_Register_Event() { var recorder = new EventRecorder(this, string.Empty); recorder.RecordEvent(); Assert.Equal(1, recorder.Count()); }
public void Should_Register_Events_Parameters() { var recorder = new EventRecorder(this, string.Empty); recorder.RecordEvent(3, 8, "some info"); Assert.Equal(3, recorder.ElementAt(0).Parameters[0]); Assert.Equal(8, recorder.ElementAt(0).Parameters[1]); Assert.Equal("some info", recorder.ElementAt(0).Parameters[2]); }