public void Raise_should_not_throw_if_event_delegate_is_null() { // Arrange EventArgsTestEvent = null; EventArgs eventArgs = new EventArgs(); // Act FlowUtils.RaiseAll(this, eventArgs, ref EventArgsTestEvent); // Assert }
public void Raise_all_should_call_test_handlers() { // Arrange int a = 0; EventArgs eventArgs = new EventArgs(); EventHandler <EventArgs> testDelegate = (sender, args) => { a += 1; }; EventArgsTestEvent = null; EventArgsTestEvent += testDelegate; EventArgsTestEvent += testDelegate; EventArgsTestEvent += testDelegate; // Act FlowUtils.RaiseAll(this, eventArgs, ref EventArgsTestEvent); // Assert Assert.Equal(3, a); }
public void Raise_all_should_return_exception_of_all_handlers() { // Arrange int a = 10; EventArgs eventArgs = new EventArgs(); EventHandler <EventArgs> testDelegate = (sender, args) => { a = 20; }; EventHandler <EventArgs> testDelegate2 = (sender, args) => { a = 30; throw new Exception("test"); }; EventArgsTestEvent += testDelegate; EventArgsTestEvent += testDelegate2; // Act Assert.Throws <AggregateException>(() => { FlowUtils.RaiseAll(this, eventArgs, ref EventArgsTestEvent); }); // Assert Assert.Equal(30, a); }