public void Should_serialize_and_deserialize_envelope() { var commitId = Guid.NewGuid(); var inputEvent = new Envelope <MyEvent>(new MyEvent { MyProperty = "My-Property" }); inputEvent.SetAggregateId(DomainId.NewGuid()); inputEvent.SetCommitId(commitId); inputEvent.SetEventId(Guid.NewGuid()); inputEvent.SetEventPosition("1"); inputEvent.SetEventStreamNumber(1); inputEvent.SetTimestamp(SystemClock.Instance.GetCurrentInstant()); var eventData = sut.ToEventData(inputEvent, commitId); var eventStored = new StoredEvent("stream", "0", -1, eventData); var outputEvent = sut.Parse(eventStored).To <MyEvent>(); AssertHeaders(inputEvent.Headers, outputEvent.Headers); AssertPayload(inputEvent, outputEvent); }
public async Task Should_read_latest_events(int count) { var streamName = $"test-{Guid.NewGuid()}"; var events = new List <EventData>(); for (var i = 0; i < count; i++) { events.Add(new EventData($"Type{i}", new EnvelopeHeaders(), i.ToString())); } for (var i = 0; i < events.Count / 2; i++) { var commit = events.Skip(i * 2).Take(2); await Sut.AppendAsync(Guid.NewGuid(), streamName, commit.ToArray()); } var offset = 25; var take = count - offset; var expected1 = events .Skip(offset) .Select((x, i) => new StoredEvent(streamName, "Position", i + offset, events[i + offset])) .ToArray(); var expected2 = new StoredEvent[0]; var readEvents1 = await Sut.QueryLatestAsync(streamName, take); var readEvents2 = await Sut.QueryLatestAsync(streamName, 0); ShouldBeEquivalentTo(readEvents1, expected1); ShouldBeEquivalentTo(readEvents2, expected2); }
private Task OnEventAsync(IEventSubscription subscriber, StoredEvent ev) { return(sutSubscriber.OnEventAsync(subscriber, ev)); }
Task IEventSubscriber.OnEventAsync(IEventSubscription subscription, StoredEvent storedEvent) { return(dispatcher.DispatchAsync(() => HandleEventAsync(subscription, storedEvent))); }
public async Task OnEventAsync(IEventSubscription subscription, StoredEvent storedEvent) { await eventSubscriber.OnEventAsync(subscription, storedEvent); }
public bool Handles(StoredEvent @event) { return(inners.Any(x => x.Handles(@event))); }
public bool Handles(StoredEvent @event) { return(true); }