コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: EventStoreTests.cs プロジェクト: tom-houben/squidex
        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);
        }
コード例 #3
0
 private Task OnEventAsync(IEventSubscription subscriber, StoredEvent ev)
 {
     return(sutSubscriber.OnEventAsync(subscriber, ev));
 }
コード例 #4
0
ファイル: RetrySubscription.cs プロジェクト: zxbe/squidex
 Task IEventSubscriber.OnEventAsync(IEventSubscription subscription, StoredEvent storedEvent)
 {
     return(dispatcher.DispatchAsync(() => HandleEventAsync(subscription, storedEvent)));
 }
コード例 #5
0
 public async Task OnEventAsync(IEventSubscription subscription, StoredEvent storedEvent)
 {
     await eventSubscriber.OnEventAsync(subscription, storedEvent);
 }
コード例 #6
0
 public bool Handles(StoredEvent @event)
 {
     return(inners.Any(x => x.Handles(@event)));
 }
コード例 #7
0
 public bool Handles(StoredEvent @event)
 {
     return(true);
 }