public static ChaosEvent FromNativeEvent(NativeTypes.FABRIC_CHAOS_EVENT nativeEvent) { switch (nativeEvent.Kind) { case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_STARTED: return(StartedEvent.FromNative(nativeEvent.Value)); case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_EXECUTING_FAULTS: return(ExecutingFaultsEvent.FromNative(nativeEvent.Value)); case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_STOPPED: return(StoppedEvent.FromNative(nativeEvent.Value)); case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_TEST_ERROR: return(TestErrorEvent.FromNative(nativeEvent.Value)); case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_VALIDATION_FAILED: return(ValidationFailedEvent.FromNative(nativeEvent.Value)); case NativeTypes.FABRIC_CHAOS_EVENT_KIND.FABRIC_CHAOS_EVENT_KIND_WAITING: return(WaitingEvent.FromNative(nativeEvent.Value)); default: return(null); } }
public static ChaosEvent GetEventFromBytes(byte[] data) { ChaosEvent e = null; ChaosEventType type = (ChaosEventType)BitConverter.ToInt32(data, 0); switch (type) { case ChaosEventType.Started: { e = new StartedEvent(); } break; case ChaosEventType.Stopped: { e = new StoppedEvent(); } break; case ChaosEventType.ExecutingFaults: { e = new ExecutingFaultsEvent(); } break; case ChaosEventType.ValidationFailed: { e = new ValidationFailedEvent(); } break; case ChaosEventType.TestError: { e = new TestErrorEvent(); } break; case ChaosEventType.Waiting: { e = new WaitingEvent(); } break; } if (e != null) { byte[] eventData = new byte[data.Length - 4]; Array.Copy(data, 4, eventData, 0, eventData.Length); e.FromBytes(eventData); } return(e); }
public void OnTestError(ITest test, Exception e) { if (testError != null) { TestErrorEvent evnt = testError; //avoid race condition evnt(test, e); } }