public void construct() { var streamId = "sId"; var position = (long)1; var e = new StreamEventLink(streamId, position); Assert.Equal(streamId, e.StreamId); Assert.Equal(position, e.Position); }
public void construct_with_link() { var streamId = "sId"; var position = (long)1; var linkStreamId = "lId"; var linkPosition = (long)20; var eventType = "a"; var data = Encoding.UTF8.GetBytes("{}"); var link = new StreamEventLink(linkStreamId, linkPosition); var e = new StreamEvent(streamId, position, link, eventType, data); Assert.Equal(streamId, e.StreamId); Assert.Equal(position, e.Position); Assert.Equal(eventType, e.EventType); Assert.Equal(data, e.Data); // Reference equality, not value eq. Assert.Equal(link, e.Link); Assert.True(e.IsLink); }
private async Task ReceiveResolvedEventAsync(Func <StreamEvent, Task> receiverAsync, ResolvedEvent resolvedEvent, CancellationToken cancellationToken) { if (!cancellationToken.IsCancellationRequested) { var streamId = resolvedEvent.Event.EventStreamId; var position = resolvedEvent.Event.EventNumber; StreamEventLink link = null; if (resolvedEvent.Link != null) { link = new StreamEventLink(resolvedEvent.Event.EventStreamId, resolvedEvent.Event.EventNumber); streamId = resolvedEvent.Link.EventStreamId; position = resolvedEvent.Link.EventNumber; } var streamEvent = new StreamEvent(resolvedEvent.OriginalStreamId, resolvedEvent.OriginalEventNumber, link, resolvedEvent.Event.EventType, resolvedEvent.Event.Data); // Send the assembled stream event to the receiver. await receiverAsync(streamEvent); } }