public async Task EventsTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); await BaseTests.BaseInstanceTestAsync <IEventsClass>( GetFullName(typeof(EventsClass)), async (instance, cancellationToken) => { instance.Event1 += (_, value) => { Console.WriteLine($"Hello, I'm the Event1. My value is {value}"); }; instance.Event3 += (value) => { Console.WriteLine($"Hello, I'm the Event3. My value is {value}"); }; var event1Value = await instance.WaitEventAsync <int>(_ => { instance.RaiseEvent1(); return(Task.CompletedTask); }, nameof(instance.Event1), cancellationToken); Assert.AreEqual(777, event1Value); var event2Values = await instance.WaitEventAsync(_ => { instance.RaiseEvent3(); return(Task.CompletedTask); }, nameof(instance.Event3), cancellationToken); Assert.IsNotNull(event2Values); Assert.AreEqual(1, event2Values.Length); Assert.AreEqual("555", event2Values[0]); }, cancellationTokenSource.Token); }