Beispiel #1
0
        public static void Given(Guid eventSourceId, Event @event)
        {
            var givenEvents = GivenEvents(eventSourceId);

            var expectedVersion = givenEvents.Count();
            @event.Version = expectedVersion + 1;

            var store = GetEventStore();
            store.SaveEventsFromAggregate(eventSourceId, new[] {@event}, expectedVersion);
            var events = GetEvents();
            if (!events.ContainsKey(eventSourceId))
                events[eventSourceId] = new List<Event>();
            events[eventSourceId].Add(@event);
        }
Beispiel #2
0
        private void SaveEvents(Guid eventSourceId, Event[] events, int expectedVersion)
        {
            if (!events.Any())
                return;
            var eventDescriptors = new List<EventDescriptor>();
            var i = expectedVersion;
            foreach (var @event in events)
            {
                i++;
                @event.Version = i;
                eventDescriptors.Add(new EventDescriptor(eventSourceId, @event, i));
            }

            PersistEventDescriptors(eventDescriptors, eventSourceId, expectedVersion);
        }
Beispiel #3
0
 private void ApplyChange(Event @event, bool isNew)
 {
     this.AsDynamic().Apply(@event);
     if (isNew) _changes.Add(@event);
 }
Beispiel #4
0
 protected void ApplyChange(Event @event)
 {
     ApplyChange(@event, true);
 }
Beispiel #5
0
 public EventDescriptor(Guid id, Event eventData, int version)
 {
     EventData = eventData;
     Version = version;
     Id = id;
 }