public void TestEventChild() { var hub = this.GetAsyncEventHub(); var args = new EventMockChild(10); int called = 0; hub.Subscribe<EventMock>(e => { e.Should().BeSameAs(args, "the passed arguments should be the same as provided"); called++; }); hub.Raise(args); this.app.Stop(); called.Should().Be(1, "event handler should be called exactly once"); }
private void TestPerformanceEventsRaiseInternal() { var hub = this.GetAsyncEventHub(); var args = new EventMockChild(10); var parentCalled = 0; var childCalled = 0; var interfaceCalled = 0; hub.Subscribe<EventMock>(e => parentCalled++); hub.Subscribe<EventMockChild>(e => childCalled++); hub.Subscribe<IEvent>(e => interfaceCalled++); var calledCount = 15000; for (int i = 0; i < calledCount; i++) { hub.Raise(args); } this.app.Stop(); parentCalled.Should().Be(calledCount, "The parent should be called exactly {0} times", calledCount); childCalled.Should().Be(calledCount, "The child should be called exactly {0} times", calledCount); interfaceCalled.Should().Be(calledCount, "The interface should be called exactly {0} times", calledCount); }
public void TestCallBaseSubscribeParent() { var hub = this.GetAsyncEventHub(); var args = new EventMockChild(10); int called = 0; hub.Subscribe<EventMockChild>(e => called++); hub.Raise<EventMock>(args); called.Should().Be(0, "event handler should not be called if the arguments are passed as base class"); }