public when_using_listener_start_with_aggregate_and_guid(StreamStoreConnectionFixture fixture) { var conn = fixture.Connection; conn.Connect(); // Build an origin stream to which the the events are appended. We are testing this stream directly var originalStreamGuid = Guid.NewGuid(); var originStreamName = _streamNameBuilder.GenerateForAggregate(typeof(AggregateIdTestAggregate), originalStreamGuid); // Drop an event into the stream testAggregate-guid var result = conn.AppendToStream( originStreamName, ExpectedVersion.NoStream, null, _eventSerializer.Serialize(new TestEvent())); Assert.True(result.NextExpectedVersion == 0); // Wait for the stream to be written CommonHelpers.WaitForStream(conn, originStreamName); StreamListener listener = new QueuedStreamListener( "guidStream", conn, _streamNameBuilder, _eventSerializer); listener.EventStream.Subscribe(new AdHocHandler <Event>(Handle)); // This will start listening on the TestAggregate-guid stream. listener.Start <AggregateIdTestAggregate>(originalStreamGuid); }
public when_using_listener_start_with_event_type(StreamStoreConnectionFixture fixture) { var streamNameBuilder = new PrefixedCamelCaseStreamNameBuilder(); var conn = fixture.Connection; conn.Connect(); var originalAggregateStream = streamNameBuilder.GenerateForAggregate( typeof(TestAggregate), Guid.NewGuid()); var evt = new EventProjectionTestEvent(); //drop the event into the stream var result = conn.AppendToStream( originalAggregateStream, ExpectedVersion.NoStream, null, _eventSerializer.Serialize(evt)); Assert.True(result.NextExpectedVersion == 0); //wait for the projection to be written CommonHelpers.WaitForStream(conn, streamNameBuilder.GenerateForEventType(nameof(EventProjectionTestEvent))); //build the listener StreamListener listener = new QueuedStreamListener( "event listener", conn, streamNameBuilder, _eventSerializer); listener.EventStream.Subscribe(new AdHocHandler <EventProjectionTestEvent>(Handle)); listener.Start(typeof(EventProjectionTestEvent)); }
public when_using_listener_start_with_custom_stream_synched(StreamStoreConnectionFixture fixture) { var conn = fixture.Connection; conn.Connect(); // Build an origin stream from strings to which the the events are appended var originStreamName = $"testStream-{Guid.NewGuid():N}"; var result = fixture.Connection.AppendToStream( originStreamName, ExpectedVersion.NoStream, null, _eventSerializer.Serialize(new TestEvent())); Assert.True(result.NextExpectedVersion == 0); // Wait for the stream to be written CommonHelpers.WaitForStream(conn, originStreamName); StreamListener listener = new QueuedStreamListener( originStreamName, fixture.Connection, new PrefixedCamelCaseStreamNameBuilder(), _eventSerializer); listener.EventStream.Subscribe(new AdHocHandler <Event>(Handle)); listener.Start(originStreamName); }
public when_using_listener_start_with_category_aggregate(StreamStoreConnectionFixture fixture) { var streamNameBuilder = new PrefixedCamelCaseStreamNameBuilder(); var conn = fixture.Connection; conn.Connect(); var aggStream = streamNameBuilder.GenerateForAggregate(typeof(AggregateCategoryTestAggregate), Guid.NewGuid()); var categoryStream = streamNameBuilder.GenerateForCategory(typeof(AggregateCategoryTestAggregate)); // Drop an event into the stream testAggregate-guid var result = conn.AppendToStream( aggStream, ExpectedVersion.NoStream, null, _eventSerializer.Serialize(new TestEvent())); Assert.True(result.NextExpectedVersion == 0); //wait for the projection to be written. CommonHelpers.WaitForStream(conn, categoryStream); // Now set up the projection listener, and start it. var listener = new QueuedStreamListener( "category listener", conn, streamNameBuilder, new JsonMessageSerializer()); listener.EventStream.Subscribe <TestEvent>(new AdHocHandler <TestEvent>(Handle)); listener.Start <AggregateCategoryTestAggregate>(); }