public void BindToNonExistent() { dynamic d = new TypeWithEvents(); Action <int> handler = i => { }; Assert.Throws <RuntimeBinderException>(() => d.NothingHere += handler); }
public void BindToNonEvents() { dynamic d = new TypeWithEvents(); Action <int> handler = i => { }; Assert.Throws <RuntimeBinderException>(() => d.NonEventField += handler); Assert.Throws <RuntimeBinderException>(() => d.NonEventProperty += handler); Assert.Throws <RuntimeBinderException>(() => d.Raise += handler); }
public void BindToEvent() { dynamic d = new TypeWithEvents(); int output = 0; d.Event += (Action <int>)(i => { output = i; }); d.Raise(49); Assert.Equal(49, output); }
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); }