private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { var currentPinValue = Pin.Read(); System.Diagnostics.Debug.WriteLine(currentPinValue); // If same value of last read, exits. if (currentPinValue == lastPinValue) { return; } // Checks the pin value. if (currentPinValue == ActualHighPinValue) { IsWhiteLineDetected = true; RaiseEventHelper.CheckRaiseEventOnUIThread(this, WhiteLineDetected, RaiseEventsOnUIThread); } else if (currentPinValue == ActualLowPinValue) { IsWhiteLineDetected = false; RaiseEventHelper.CheckRaiseEventOnUIThread(this, BlackLineDetected, RaiseEventsOnUIThread); } lastPinValue = currentPinValue; }
private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { var dataValue = dataPin.Pin.Read(); var clockValue = clockPin.Pin.Read(); var highCount = (dataValue == GpioPinValue.High ? 1 : 0) + (clockValue == GpioPinValue.High ? 1 : 0); if (highCount == (previousHighCount + 1)) { if (previousHighCount == 0) { direction = (dataValue == GpioPinValue.High) ? RotaryEncoderDirection.Anticlockwise : RotaryEncoderDirection.Clockwise; } previousHighCount = highCount; } else if (previousHighCount == 2 && highCount == 1) { RaiseEventHelper.CheckRaiseEventOnUIThread(this, Rotate, new RotaryEncoderEventArgs(direction), RaiseEventsOnUIThread); previousHighCount = 0; } else { previousHighCount = 0; } }
private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { var currentPinValue = Pin.Read(); //Debug.WriteLine(currentPinValue); // If same value of last read, exits. if (currentPinValue == lastPinValue) { return; } // Checks the pin value. if (currentPinValue == ActualHighPinValue) { IsInContact = true; RaiseEventHelper.CheckRaiseEventOnUIThread(this, TouchDetected, RaiseEventsOnUIThread); } else if (currentPinValue == ActualLowPinValue) { IsInContact = false; RaiseEventHelper.CheckRaiseEventOnUIThread(this, TouchRemoved, RaiseEventsOnUIThread); } lastPinValue = currentPinValue; }
private void CheckState(object state) { var currentPinValue = Pin.Read(); //System.Diagnostics.Debug.WriteLine(currentPinValue); // If same value of last read, exits. if (currentPinValue == lastPinValue) { return; } // Checks the pin value. if (currentPinValue == ActualHighPinValue) { PhotoPassThrough = false; RaiseEventHelper.CheckRaiseEventOnUIThread(this, Interrupted, RaiseEventsOnUIThread); } else if (currentPinValue == ActualLowPinValue) { PhotoPassThrough = true; RaiseEventHelper.CheckRaiseEventOnUIThread(this, PassThrough, RaiseEventsOnUIThread); } lastPinValue = currentPinValue; }
public void RaiseGenericBuildEventArgs() { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); eventHelper.RaiseBuildEvent(RaiseEventHelper.GenericBuildEvent); }
public void VerifyShutdown() { EventSourceSink sink = new EventSourceSink(); // Registers event handlers onto the event source EventHandlerHelper handlerHelper = new EventHandlerHelper(sink, null); RaiseEventHelper raiseEventHelper = new RaiseEventHelper(sink); raiseEventHelper.RaiseBuildEvent(RaiseEventHelper.ProjectStarted); Assert.IsTrue(handlerHelper.EnteredEventHandler); Assert.IsTrue(handlerHelper.EnteredAnyEventHandler); Assert.IsTrue(handlerHelper.EnteredStatusEventHandler); Assert.IsTrue(handlerHelper.RaisedEvent == RaiseEventHelper.ProjectStarted); Assert.IsTrue(handlerHelper.RaisedAnyEvent == RaiseEventHelper.ProjectStarted); Assert.IsTrue(handlerHelper.RaisedStatusEvent == RaiseEventHelper.ProjectStarted); sink.ShutDown(); handlerHelper.ResetRaisedEvent(); raiseEventHelper.RaiseBuildEvent(RaiseEventHelper.ProjectStarted); Assert.IsFalse(handlerHelper.EnteredEventHandler); Assert.IsFalse(handlerHelper.EnteredAnyEventHandler); Assert.IsFalse(handlerHelper.EnteredStatusEventHandler); Assert.IsNull(handlerHelper.RaisedEvent); Assert.IsNull(handlerHelper.RaisedAnyEvent); Assert.IsNull(handlerHelper.RaisedStatusEvent); }
/// <summary> /// Take an event and an exception to raise, create a new sink and raise the event on it. /// In the event handler registered on the sink, the exception will be thrown. /// </summary> /// <param name="buildEventToRaise">BuildEvent to raise on the </param> /// <param name="exceptionToRaise">Exception to throw in the event handler </param> private static void RaiseExceptionInEventHandler(BuildEventArgs buildEventToRaise, Exception exceptionToRaise) { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); EventHandlerHelper testHandlers = new EventHandlerHelper(sink, exceptionToRaise); try { eventHelper.RaiseBuildEvent(buildEventToRaise); } catch (Exception e) { // Logger exceptions should be rethrown as is with no wrapping if (exceptionToRaise is LoggerException) { Assert.IsTrue(e == exceptionToRaise, "Expected Logger exception to be raised in event handler and re-thrown by event source"); } else { if (ExceptionHandling.IsCriticalException(e)) { Assert.IsTrue(e == exceptionToRaise, "Expected Logger exception to be raised in event handler and re-thrown by event source"); } else { // All other exceptions should be wrapped in an InternalLoggerException, with the original exception as the inner exception Assert.IsTrue(e is InternalLoggerException, "Expected general exception to be raised in event handler and re-thrown by event source as a InternalLoggerException"); } } } }
private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { var currentPinValue = Pin.Read(); // If same value of last read, exits. if (currentPinValue == lastPinValue) { return; } // Checks the pin value. if (currentPinValue == ActualHighPinValue) { IsPressed = true; RaiseEventHelper.CheckRaiseEventOnUIThread(this, Pressed, RaiseEventsOnUIThread); } else if (currentPinValue == ActualLowPinValue) { RaiseEventHelper.CheckRaiseEventOnUIThread(this, Released, RaiseEventsOnUIThread); if (IsPressed) { RaiseEventHelper.CheckRaiseEventOnUIThread(this, Click, RaiseEventsOnUIThread); } IsPressed = false; } lastPinValue = currentPinValue; }
protected override void OnTimer() { var acceleration = this.ReadAcceleration(); if (currentAcceleration.X != acceleration.X || currentAcceleration.Y != acceleration.Y || currentAcceleration.Z != acceleration.Z) { currentAcceleration = acceleration; RaiseEventHelper.CheckRaiseEventOnUIThread(this, AccelerationChanged, RaiseEventsOnUIThread); } }
protected override void OnTimer() { var distance = this.GetDistance(); if (currentDistance != distance) { currentDistance = distance; RaiseEventHelper.CheckRaiseEventOnUIThread(this, DistanceChanged, RaiseEventsOnUIThread); } }
public void RaiseGenericBuildEventArgs() { Assert.Throws <InternalErrorException>(() => { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); eventHelper.RaiseBuildEvent(RaiseEventHelper.GenericBuildEvent); } ); }
protected override void OnTimer() { // Retrive luminosity value. var lux = this.GetLux(); if (currentLux != lux) { currentLux = lux; RaiseEventHelper.CheckRaiseEventOnUIThread(this, LuxChanged, RaiseEventsOnUIThread); } }
protected override async void OnTimer() { var humiture = await this.GetHumitureAsync(); if (humiture.IsValid && (CurrentTemperature != humiture.Temperature || CurrentHumidity != humiture.Humidity)) { currentTemperature = humiture.Temperature; currentHumidity = humiture.Humidity; RaiseEventHelper.CheckRaiseEventOnUIThread(this, ReadingChanged, RaiseEventsOnUIThread); } }
private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { var currentPinValue = Pin.Read(); // Checks the pin value. if (currentPinValue != lastPinValue && currentPinValue == ActualHighPinValue) { RaiseEventHelper.CheckRaiseEventOnUIThread(this, Shaked, RaiseEventsOnUIThread); } lastPinValue = currentPinValue; }
private void CheckState(object state) { var currentPinValue = Pin.Read(); // Checks the pin value. if (currentPinValue != lastPinValue && currentPinValue == ActualHighPinValue) { RaiseEventHelper.CheckRaiseEventOnUIThread(this, Tilt, RaiseEventsOnUIThread); } lastPinValue = currentPinValue; }
protected override async void OnTimer() { // Retrive luminosity value. var sensorData = await this.GetSensorDataAsync(); if (sensorData.Pressure != currentPressure || sensorData.Temperature != currentTemperature) { currentPressure = sensorData.Pressure; currentTemperature = sensorData.Temperature; RaiseEventHelper.CheckRaiseEventOnUIThread(this, ReadingChanged, RaiseEventsOnUIThread); } }
public void TreatWarningsAsErrorWhenAllSpecified() { EventSourceSink eventSourceSink = new EventSourceSink() { WarningsAsErrors = new HashSet <string>(), }; RaiseEventHelper raiseEventHelper = new RaiseEventHelper(eventSourceSink); EventHandlerHelper eventHandlerHelper = new EventHandlerHelper(eventSourceSink, null); raiseEventHelper.RaiseBuildEvent(RaiseEventHelper.Warning); Assert.IsType <BuildErrorEventArgs>(eventHandlerHelper.RaisedEvent); }
private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { var currentPinValue = Pin.Read(); //System.Diagnostics.Debug.WriteLine(currentPinValue); // Checks the pin value. if (currentPinValue != lastPinValue && currentPinValue == ActualHighPinValue) { RaiseEventHelper.CheckRaiseEventOnUIThread(this, Knocked, RaiseEventsOnUIThread); } lastPinValue = currentPinValue; }
public void ConsumeEventsGoodEventsNoHandlers() { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); eventHelper.RaiseBuildEvent(RaiseEventHelper.BuildStarted); eventHelper.RaiseBuildEvent(RaiseEventHelper.BuildFinished); eventHelper.RaiseBuildEvent(RaiseEventHelper.NormalMessage); eventHelper.RaiseBuildEvent(RaiseEventHelper.TaskFinished); eventHelper.RaiseBuildEvent(RaiseEventHelper.CommandLine); eventHelper.RaiseBuildEvent(RaiseEventHelper.Warning); eventHelper.RaiseBuildEvent(RaiseEventHelper.Error); eventHelper.RaiseBuildEvent(RaiseEventHelper.TargetStarted); eventHelper.RaiseBuildEvent(RaiseEventHelper.TargetFinished); eventHelper.RaiseBuildEvent(RaiseEventHelper.ProjectStarted); eventHelper.RaiseBuildEvent(RaiseEventHelper.ProjectFinished); eventHelper.RaiseBuildEvent(RaiseEventHelper.ExternalStartedEvent); eventHelper.RaiseBuildEvent(RaiseEventHelper.ExternalStartedEvent); eventHelper.RaiseBuildEvent(RaiseEventHelper.GenericStatusEvent); }
public void ConsumeEventsGoodEventsNoHandlers() { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); eventHelper.RaiseBuildEvent(RaiseEventHelper.BuildStarted); eventHelper.RaiseBuildEvent(RaiseEventHelper.BuildFinished); eventHelper.RaiseBuildEvent(RaiseEventHelper.NormalMessage); eventHelper.RaiseBuildEvent(RaiseEventHelper.TaskFinished); eventHelper.RaiseBuildEvent(RaiseEventHelper.CommandLine); eventHelper.RaiseBuildEvent(RaiseEventHelper.Warning); eventHelper.RaiseBuildEvent(RaiseEventHelper.Error); eventHelper.RaiseBuildEvent(RaiseEventHelper.TargetStarted); eventHelper.RaiseBuildEvent(RaiseEventHelper.TargetFinished); eventHelper.RaiseBuildEvent(RaiseEventHelper.ProjectStarted); eventHelper.RaiseBuildEvent(RaiseEventHelper.ProjectFinished); eventHelper.RaiseBuildEvent(RaiseEventHelper.ExternalStartedEvent); eventHelper.RaiseBuildEvent(RaiseEventHelper.ExternalStartedEvent); eventHelper.RaiseBuildEvent(RaiseEventHelper.GenericStatusEvent); }
public void ConsumeEventsGoodEvents() { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); EventHandlerHelper testHandlers = new EventHandlerHelper(sink, null); VerifyRegisteredHandlers(RaiseEventHelper.BuildStarted, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.BuildFinished, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.NormalMessage, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.TaskFinished, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.CommandLine, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.Warning, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.Error, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.TargetStarted, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.TargetFinished, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.ProjectStarted, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.ProjectFinished, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.ExternalStartedEvent, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.BuildStarted, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.GenericStatusEvent, eventHelper, testHandlers); }
public void NotTreatWarningsAsMessagesWhenNotSpecified() { BuildWarningEventArgs expectedBuildEvent = RaiseEventHelper.Warning; EventSourceSink eventSourceSink = new EventSourceSink() { WarningsAsMessages = new HashSet <string> { "123", "ABC", }, }; RaiseEventHelper raiseEventHelper = new RaiseEventHelper(eventSourceSink); EventHandlerHelper eventHandlerHelper = new EventHandlerHelper(eventSourceSink, null); raiseEventHelper.RaiseBuildEvent(RaiseEventHelper.Warning); Assert.Equal(expectedBuildEvent, eventHandlerHelper.RaisedEvent); }
public void ConsumeEventsGoodEvents() { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); EventHandlerHelper testHandlers = new EventHandlerHelper(sink, null); VerifyRegisteredHandlers(RaiseEventHelper.BuildStarted, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.BuildFinished, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.NormalMessage, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.TaskFinished, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.CommandLine, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.Warning, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.Error, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.TargetStarted, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.TargetFinished, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.ProjectStarted, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.ProjectFinished, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.ExternalStartedEvent, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.BuildStarted, eventHelper, testHandlers); VerifyRegisteredHandlers(RaiseEventHelper.GenericStatusEvent, eventHelper, testHandlers); }
public void TreatWarningsAsMessagesWhenSpecified() { BuildWarningEventArgs expectedBuildEvent = RaiseEventHelper.Warning; EventSourceSink eventSourceSink = new EventSourceSink() { WarningsAsMessages = new HashSet <string> { "FOO", expectedBuildEvent.Code, "BAR", }, }; RaiseEventHelper raiseEventHelper = new RaiseEventHelper(eventSourceSink); EventHandlerHelper eventHandlerHelper = new EventHandlerHelper(eventSourceSink, null); raiseEventHelper.RaiseBuildEvent(RaiseEventHelper.Warning); Assert.IsType <BuildMessageEventArgs>(eventHandlerHelper.RaisedEvent); BuildMessageEventArgs actualBuildEvent = (BuildMessageEventArgs)eventHandlerHelper.RaisedEvent; Assert.Equal(expectedBuildEvent.BuildEventContext, actualBuildEvent.BuildEventContext); Assert.Equal(expectedBuildEvent.Code, actualBuildEvent.Code); Assert.Equal(expectedBuildEvent.ColumnNumber, actualBuildEvent.ColumnNumber); Assert.Equal(expectedBuildEvent.EndColumnNumber, actualBuildEvent.EndColumnNumber); Assert.Equal(expectedBuildEvent.EndLineNumber, actualBuildEvent.EndLineNumber); Assert.Equal(expectedBuildEvent.File, actualBuildEvent.File); Assert.Equal(expectedBuildEvent.HelpKeyword, actualBuildEvent.HelpKeyword); Assert.Equal(MessageImportance.Low, actualBuildEvent.Importance); Assert.Equal(expectedBuildEvent.LineNumber, actualBuildEvent.LineNumber); Assert.Equal(expectedBuildEvent.Message, actualBuildEvent.Message); Assert.Equal(expectedBuildEvent.ProjectFile, actualBuildEvent.ProjectFile); Assert.Equal(expectedBuildEvent.SenderName, actualBuildEvent.SenderName); Assert.Equal(expectedBuildEvent.Subcategory, actualBuildEvent.Subcategory); Assert.Equal(expectedBuildEvent.ThreadId, actualBuildEvent.ThreadId); Assert.Equal(expectedBuildEvent.Timestamp, actualBuildEvent.Timestamp); }
private void Awake() { instance = this; }
public void RaiseGenericBuildEventArgs() { Assert.Throws<InternalErrorException>(() => { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); eventHelper.RaiseBuildEvent(RaiseEventHelper.GenericBuildEvent); } ); }
/// <summary> /// Verify when an is raised the handlers which are registered to handle the event should handle them /// </summary> /// <param name="buildEventToRaise">A buildEventArgs to raise on the event source</param> /// <param name="eventHelper">Helper class which events are raised on</param> /// <param name="testHandlers">Class which contains a set of event handlers registered on the event source</param> private static void VerifyRegisteredHandlers(BuildEventArgs buildEventToRaise, RaiseEventHelper eventHelper, EventHandlerHelper testHandlers) { try { eventHelper.RaiseBuildEvent(buildEventToRaise); if (buildEventToRaise.GetType() != typeof(GenericBuildStatusEventArgs)) { Assert.IsTrue(testHandlers.RaisedEvent == buildEventToRaise, "Expected buildevent in handler to match buildevent raised on event source"); Assert.IsTrue(testHandlers.RaisedEvent == testHandlers.RaisedAnyEvent, "Expected RaisedEvent and RaisedAnyEvent to match"); Assert.IsTrue(testHandlers.EnteredEventHandler, "Expected to enter into event handler"); } Assert.IsTrue(testHandlers.RaisedAnyEvent == buildEventToRaise, "Expected buildEvent in any event handler to match buildevent raised on event source"); Assert.IsTrue(testHandlers.EnteredAnyEventHandler, "Expected to enter into AnyEvent handler"); if (buildEventToRaise is BuildStatusEventArgs) { Assert.IsTrue(testHandlers.RaisedStatusEvent == buildEventToRaise, "Expected buildevent in handler to match buildevent raised on event source"); Assert.IsTrue(testHandlers.EnteredStatusEventHandler, "Expected to enter into Status event handler"); } else { Assert.IsNull(testHandlers.RaisedStatusEvent); Assert.IsFalse(testHandlers.EnteredStatusEventHandler); } } finally { testHandlers.ResetRaisedEvent(); } }
/// <summary> /// Take an event and an exception to raise, create a new sink and raise the event on it. /// In the event handler registered on the sink, the exception will be thrown. /// </summary> /// <param name="buildEventToRaise">BuildEvent to raise on the </param> /// <param name="exceptionToRaise">Exception to throw in the event handler </param> private static void RaiseExceptionInEventHandler(BuildEventArgs buildEventToRaise, Exception exceptionToRaise) { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); EventHandlerHelper testHandlers = new EventHandlerHelper(sink, exceptionToRaise); try { eventHelper.RaiseBuildEvent(buildEventToRaise); } catch (Exception e) { // Logger exceptions should be rethrown as is with no wrapping if (exceptionToRaise is LoggerException) { Assert.IsTrue(e == exceptionToRaise, "Expected Logger exception to be raised in event handler and re-thrown by event source"); } else { if (ExceptionHandling.IsCriticalException(e)) { Assert.IsTrue(e == exceptionToRaise, "Expected Logger exception to be raised in event handler and re-thrown by event source"); } else { // All other exceptions should be wrapped in an InternalLoggerException, with the original exception as the inner exception Assert.IsTrue(e is InternalLoggerException, "Expected general exception to be raised in event handler and re-thrown by event source as a InternalLoggerException"); } } } }
public void VerifyShutdown() { EventSourceSink sink = new EventSourceSink(); // Registers event handlers onto the event source EventHandlerHelper handlerHelper = new EventHandlerHelper(sink, null); RaiseEventHelper raiseEventHelper = new RaiseEventHelper(sink); raiseEventHelper.RaiseBuildEvent(RaiseEventHelper.ProjectStarted); Assert.IsTrue(handlerHelper.EnteredEventHandler); Assert.IsTrue(handlerHelper.EnteredAnyEventHandler); Assert.IsTrue(handlerHelper.EnteredStatusEventHandler); Assert.IsTrue(handlerHelper.RaisedEvent == RaiseEventHelper.ProjectStarted); Assert.IsTrue(handlerHelper.RaisedAnyEvent == RaiseEventHelper.ProjectStarted); Assert.IsTrue(handlerHelper.RaisedStatusEvent == RaiseEventHelper.ProjectStarted); sink.ShutDown(); handlerHelper.ResetRaisedEvent(); raiseEventHelper.RaiseBuildEvent(RaiseEventHelper.ProjectStarted); Assert.IsFalse(handlerHelper.EnteredEventHandler); Assert.IsFalse(handlerHelper.EnteredAnyEventHandler); Assert.IsFalse(handlerHelper.EnteredStatusEventHandler); Assert.IsNull(handlerHelper.RaisedEvent); Assert.IsNull(handlerHelper.RaisedAnyEvent); Assert.IsNull(handlerHelper.RaisedStatusEvent); }
public void RaiseGenericBuildEventArgs() { EventSourceSink sink = new EventSourceSink(); RaiseEventHelper eventHelper = new RaiseEventHelper(sink); eventHelper.RaiseBuildEvent(RaiseEventHelper.GenericBuildEvent); }
/// <summary> /// Verify when an is raised the handlers which are registered to handle the event should handle them /// </summary> /// <param name="buildEventToRaise">A buildEventArgs to raise on the event source</param> /// <param name="eventHelper">Helper class which events are raised on</param> /// <param name="testHandlers">Class which contains a set of event handlers registered on the event source</param> private static void VerifyRegisteredHandlers(BuildEventArgs buildEventToRaise, RaiseEventHelper eventHelper, EventHandlerHelper testHandlers) { try { eventHelper.RaiseBuildEvent(buildEventToRaise); if (buildEventToRaise.GetType() != typeof(GenericBuildStatusEventArgs)) { Assert.IsTrue(testHandlers.RaisedEvent == buildEventToRaise, "Expected buildevent in handler to match buildevent raised on event source"); Assert.IsTrue(testHandlers.RaisedEvent == testHandlers.RaisedAnyEvent, "Expected RaisedEvent and RaisedAnyEvent to match"); Assert.IsTrue(testHandlers.EnteredEventHandler, "Expected to enter into event handler"); } Assert.IsTrue(testHandlers.RaisedAnyEvent == buildEventToRaise, "Expected buildEvent in any event handler to match buildevent raised on event source"); Assert.IsTrue(testHandlers.EnteredAnyEventHandler, "Expected to enter into AnyEvent handler"); if (buildEventToRaise is BuildStatusEventArgs) { Assert.IsTrue(testHandlers.RaisedStatusEvent == buildEventToRaise, "Expected buildevent in handler to match buildevent raised on event source"); Assert.IsTrue(testHandlers.EnteredStatusEventHandler, "Expected to enter into Status event handler"); } else { Assert.IsNull(testHandlers.RaisedStatusEvent); Assert.IsFalse(testHandlers.EnteredStatusEventHandler); } } finally { testHandlers.ResetRaisedEvent(); } }