void CanAddEventHandlerWithLambdaExpression() { bool eventHasBeenRaised = false; var withEvents = new ClassWithEvents(); withEvents.SomeEvent += (s, a) => eventHasBeenRaised = true; withEvents.DoWork(); Assert.That(eventHasBeenRaised); }
public void CanUnsubsribeFromEvent() { var withEvents = new ClassWithEvents(); withEvents.SomeEvent += SomeEvent; withEvents.DoWork(); Assert.That(_eventHasBeenRaised); _eventHasBeenRaised = false; withEvents.SomeEvent -= SomeEvent; withEvents.DoWork(); Assert.That(!_eventHasBeenRaised); }