public void RemoveHandler() { TypeWithEvents with = new TypeWithEvents(); int output = 0; Action <int> setOutput = i => { output = i; }; with.Event += setOutput; with.Raise(1); dynamic d = with; d.Event -= setOutput; with.Raise(2); Assert.Equal(1, output); d.Raise(3); Assert.Equal(1, output); }
public void BindToEvent() { dynamic d = new TypeWithEvents(); int output = 0; d.Event += (Action <int>)(i => { output = i; }); d.Raise(49); Assert.Equal(49, output); }