public void When_same_event_is_pulled_and_pushed_it_is_processed_only_once() { var eventCollection = new TestEventCollection(); var pushSource = new FakePushSource(); var pullSource = new FakePullSource(); pullSource.PrepareSlice(eventCollection.GenerateEvent()); var selector = new EventSourceSelector(pullSource, pushSource, new FakeEventIdentityExtractor()); selector.Event += (s, e) => eventCollection.MarkAsProcessed(e.Event); var duplicate = eventCollection.GenerateEvent(); pushSource.Started += (s, e) => pullSource.PrepareSlice(duplicate); selector.Start(); pushSource.PushEvent(duplicate); selector.Stop(); eventCollection.VerifyAllEventsProcessed(); }
public void When_some_events_are_pulled_after_push_is_started_they_are_processed_before_pushed_events() { var eventCollection = new TestEventCollection(); var pushSource = new FakePushSource(); var pullSource = new FakePullSource(); pullSource.PrepareSlice(eventCollection.GenerateEvent()); var selector = new EventSourceSelector(pullSource, pushSource, new FakeEventIdentityExtractor()); selector.Event += (s, e) => eventCollection.MarkAsProcessed(e.Event); var pullAfterPushEvent = eventCollection.GenerateEvent(); pushSource.Started += (s, e) => pullSource.PrepareSlice(pullAfterPushEvent); selector.Start(); pushSource.PushEvent(eventCollection.GenerateEvent()); selector.Stop(); eventCollection.VerifyAllEventsProcessed(); }
static void Main(string[] args) { var tcpEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113); using (var connection = EventStoreConnection.Create()) { connection.Connect(tcpEndpoint); var pullSource = new AllEventStreamsPullSource(connection); var pushSource = new AllEventStreamsPushSource(connection); var selector = new EventSourceSelector(pullSource, pushSource, new RecordedEventIdentityExtractor()); selector.Event += OnEvent; selector.Start(); Console.WriteLine("Press <enter> to exit."); Console.ReadLine(); selector.Stop(); } }
public void When_there_are_no_outstanding_events_it_switches_to_push_source() { var eventCollection = new TestEventCollection(); var pushSource = new FakePushSource(); var pullSource = new FakePullSource(); var selector = new EventSourceSelector(pullSource, pushSource, new FakeEventIdentityExtractor()); selector.Event += (s, e) => eventCollection.MarkAsProcessed(e.Event); selector.Start(); pushSource.PushEvent(eventCollection.GenerateEvent()); selector.Stop(); eventCollection.VerifyAllEventsProcessed(); }
public void When_there_are_some_outstanding_events_it_pulls_them_and_then_switches_to_push_source() { var eventCollection = new TestEventCollection(); var pushSource = new FakePushSource(); var pullSource = new FakePullSource(); pullSource.PrepareSlice(eventCollection.GenerateEvent()); var selector = new EventSourceSelector(pullSource, pushSource, new FakeEventIdentityExtractor()); selector.Event += (s, e) => eventCollection.MarkAsProcessed(e.Event); selector.Start(); pushSource.PushEvent(eventCollection.GenerateEvent()); selector.Stop(); eventCollection.VerifyAllEventsProcessed(); }