private void AddEventActions(EventAction<EventState> eventAction, AST whenNode) { for (int i = 1; // Skip first, which is event type i < whenNode.Children.Count; i++) { eventAction.Add(GetAction(whenNode.Children[i])); } }
public void AddAnyEvent(IFoo fake, EventHandler barHandler, EventHandler bazHandler, EventHandler handlers) { "Given a fake" .x(() => fake = A.Fake <IFoo>()); "And event handlers for Bar and Baz" .x(() => (barHandler, bazHandler) = (A.Fake <EventHandler>(), A.Fake <EventHandler>())); "And subscription to any event of the fake is configured to update a delegate" .x(() => A.CallTo(fake, EventAction.Add()).Invokes((EventHandler h) => handlers += h)); "When the handler for Bar is subscribed to the Bar event" .x(() => fake.Bar += barHandler); "And the handler for Baz is subscribed to the Baz event" .x(() => fake.Baz += bazHandler); "Then the handler list contains the handler for Bar" .x(() => handlers.GetInvocationList().Should().Contain(barHandler)); "And the handler list contains the handler for Baz" .x(() => handlers.GetInvocationList().Should().Contain(bazHandler)); }
public void UnnaturalFakeAddSpecificEvent(Fake <IFoo> fake, EventHandler barHandler, EventHandler bazHandler, EventHandler handlers) { "Given a fake" .x(() => fake = new Fake <IFoo>()); "And event handlers for Bar and Baz" .x(() => (barHandler, bazHandler) = (A.Fake <EventHandler>(), A.Fake <EventHandler>())); "And subscription to the Bar event of the fake is configured to update a delegate" .x(() => fake.CallsTo(EventAction.Add(nameof(IFoo.Bar))).Invokes((EventHandler h) => handlers += h)); "When the handler for Bar is subscribed to the Bar event" .x(() => fake.FakedObject.Bar += barHandler); "And the handler for Baz is subscribed to the Baz event" .x(() => fake.FakedObject.Baz += bazHandler); "Then the handler list contains the handler for Bar" .x(() => handlers.GetInvocationList().Should().Contain(barHandler)); "And the handler list doesn't contain the handler for Baz" .x(() => handlers.GetInvocationList().Should().NotContain(bazHandler)); }
/// <summary> /// Listener for plugging into an event /// </summary> public void Listener(T value) => aggregator.OnNext(EventAction <T> .Add(value));
/// <summary> /// Listener for plugging into an event /// </summary> public void Listener(int value) => aggregator.OnNext(EventAction.Add(value));