public void GetEvent_EventWithoutHandlers_ReturnNull() { // Arrange var anyClass = new AnyClass(); // Act var evt = MagicToolbox.GetEvent(anyClass, nameof(AnyClass.Event)); // Assert evt.Should().BeNull(); }
public void GetEvent_EventWithHandlers_InvokeEventHandlerByReflection() { // Arrange var anyClass = new AnyClass(); var receivedSender = default(object); var receivedEventArgs = default(EventArgs); var anyEventArgs = EventArgs.Empty; anyClass.Event += (sender, e) => { receivedSender = sender; receivedEventArgs = e; }; // Act var evt = MagicToolbox.GetEvent(anyClass, nameof(AnyClass.Event)); evt.Invoke(this, anyEventArgs); // Assert receivedSender.Should().BeEquivalentTo(this); receivedEventArgs.Should().BeEquivalentTo(anyEventArgs); }