public void when_payload_event_is_fired_twice_then_the_second_time_the_event_is_not_recieved() { var testScheduler = new CurrentThreadTaskScheduler(); var stub = new StubClassWithEvent(); var count = 0; EventAsync.FromEvent <DataEventArgs <Guid> >(eh => stub.Payload += eh, eh => stub.Payload -= eh) .Do(_ => count++, testScheduler); stub.FirePayloadEvent(Guid.NewGuid()); stub.FirePayloadEvent(Guid.NewGuid()); Assert.That(count, Is.EqualTo(1)); }
public void when_payload_event_is_fired_twice_then_the_second_time_the_event_is_not_recieved() { var testScheduler = new CurrentThreadTaskScheduler(); var stub = new StubClassWithEvent(); var count = 0; EventAsync.FromEvent<DataEventArgs<Guid>>(eh => stub.Payload += eh, eh => stub.Payload -= eh) .Do(_ => count++, testScheduler); stub.FirePayloadEvent(Guid.NewGuid()); stub.FirePayloadEvent(Guid.NewGuid()); Assert.That(count, Is.EqualTo(1)); }
public void when_payload_event_fires_then_the_action_is_executed_and_the_payload_is_passed_through() { var testScheduler = new CurrentThreadTaskScheduler(); var stub = new StubClassWithEvent(); var result = Guid.Empty; EventAsync.FromEvent <DataEventArgs <Guid> >(eh => stub.Payload += eh, eh => stub.Payload -= eh) .Do(payload => result = payload.Value, testScheduler); var expected = Guid.NewGuid(); stub.FirePayloadEvent(expected); Assert.That(result.Equals(expected), Is.True); }
public void when_payload_event_fires_then_the_action_is_executed_and_the_payload_is_passed_through() { var testScheduler = new CurrentThreadTaskScheduler(); var stub = new StubClassWithEvent(); var result = Guid.Empty; EventAsync.FromEvent<DataEventArgs<Guid>>(eh => stub.Payload += eh, eh => stub.Payload -= eh) .Do(payload => result = payload.Value, testScheduler); var expected = Guid.NewGuid(); stub.FirePayloadEvent(expected); Assert.That(result.Equals(expected), Is.True); }