public void CanInvokeSimpleActionEvent() { var target = new SomeClassWithEvents(); int simpleActionEventCount = 0; target.SimpleActionEvent += () => Interlocked.Increment(ref simpleActionEventCount); target.FireSimpleActionEventWithStandardInvocatorPattern(); simpleActionEventCount.ShouldBe(1); target.FireSimpleActionEventWithEventHandlerInvoker(); simpleActionEventCount.ShouldBe(2); }
public void CanInvokeEventWithArgs() { var target = new SomeClassWithEvents(); var invocationHistory = new List <(object, object)>(); target.EventWithArgs += (sender, args) => invocationHistory.Add((sender, args)); var arg1 = "arg1"; var arg2 = "arg2"; var arg3 = "arg3"; var arg4 = "arg4"; target.FireEventWithArgsWithStandardInvocatorPattern(arg1, arg2); target.FireEventWithArgsWithEventHandlerInvoker(arg3, arg4); invocationHistory.Count.ShouldBe(2); invocationHistory[0].Item1.ShouldBe(arg1); invocationHistory[0].Item2.ShouldBe(arg2); invocationHistory[1].Item1.ShouldBe(arg3); invocationHistory[1].Item2.ShouldBe(arg4); }