public void Handle(SonarrEvent type) { Program.LogMsg($"Waiting lock for {type.EventType} | {typeof(SonarrEvent)}", Discord.LogSeverity.Info, "OnGrab"); Lock.WaitOne(); Program.LogMsg($"Received lock for {type.EventType}", Discord.LogSeverity.Info, "OnGrab"); try { if (type is OnTestSonarrEvent t) { OnTest?.Invoke(this, t); } else if (type is OnGrabSonarrEvent g) { Program.LogMsg($"Invoking event for OnGrab", Discord.LogSeverity.Info, "OnGrab"); Program.LogMsg($"{OnGrab?.GetInvocationList().Length} listeners #4", LogSeverity.Info, "OnGrab"); OnGrab?.Invoke(this, g); } else if (type is OnDownloadSonarrEvent d) { OnDownload?.Invoke(this, d); } } finally { Lock.Release(); Program.LogMsg($"Released lock for {type.EventType}", Discord.LogSeverity.Info, "OnGrab"); } }
public bool OnMessageWithTypes(IMessageSinkMessage message, HashSet <string> messageTypes) { switch (message) { case ITestCaseDiscoveryMessage m: foreach (ITestCase testCase in m.TestCases) { LogWriter?.WriteLine("Discovered: {0}", testCase.DisplayName); TestCases.Add(testCase); } break; case IDiscoveryCompleteMessage _: DiscoveryCompletionWaitHandle.Set(); break; case ITestPassed m: OnTest?.Invoke( new TestPassedInfo( m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName, m.ExecutionTime, m.Output ) ); break; case ITestFailed m: OnTest?.Invoke( new TestFailedInfo( m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName, m.ExecutionTime, m.Output, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault() ) ); break; case ITestSkipped m: OnTest?.Invoke( new TestSkippedInfo( m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName, m.Reason ) ); break; case ITestAssemblyFinished m: OnExecutionComplete( new ExecutionCompleteInfo( m.TestsRun, m.TestsFailed, m.TestsSkipped, m.ExecutionTime ) ); ExecutionCompletionWaitHandle.Set(); break; default: LogWriter?.WriteLine("Received message: {0}", message); break; } return(true); }
public virtual void VirtualTest(string name) { OnTest?.Invoke(this, null); }