protected override void Context() { _unitOfWork = new UnitOfWork(_commandContextProvider.Object, _eventSourceMapper.Object); _aggregate = new AggregateStringStub(); _commandContextProvider.Setup(p => p.Get()).Returns(_commandContext); _unitOfWork.Register(_aggregate); }
protected override void Context() { //var eventSourceMapper = new EventSourceMapper(new Mock<IEventSourceFactory>().Object, new Mock<IEventStore>().Object); _commandContextProvider.Setup(p => p.Get()).Returns(_commandContext); var aggregate = new AggregateStub(id); ((IEventSourceBase)aggregate).Flush(); _eventSourceMapper.Setup(m => m.Get <AggregateStub, Guid>(string.Empty, id.ToString(), 1)).Returns(aggregate); aggregate = new AggregateStub(id); aggregate.DoSomething("Hi version 2"); ((IEventSourceBase)aggregate).Flush(); _aggregate = aggregate; }
public void Set(CommandContext commandContext, IEventSourceBase eventSource) { var id = eventSource.StringId; var bucketId = eventSource.BucketId; var type = eventSource.GetType(); var oldVersion = eventSource.Version; var events = eventSource.Flush(); var newVersion = eventSource.Version; var commitId = commandContext.Id; var headers = commandContext.Headers; var eventHeaders = new Dictionary <object, Dictionary <string, object> >(); if (!events.Any()) { return; } Logger.Debug("Set event source Id '{0}', Version '{1}', Type '{2}', CommitId '{3}'", id, newVersion, eventSource.GetType().Name, commitId); headers["AggregateId"] = id; headers["AggregateBucketId"] = bucketId; headers["AggregateVersion"] = newVersion; headers["AggregateType"] = type.FullName; for (int i = 0; i < events.Count(); i++) { eventHeaders[events.ElementAt(i)] = new Dictionary <string, object> { { "EventVersion", oldVersion + i + 1 } }; } try { _eventStore.Write(bucketId, id, oldVersion, events, commitId, headers, eventHeaders); } catch (ConflictingCommandException) { // TODO: Check if the events actually conflict throw; } }
protected override void Event() { _returnedEventSource = _eventSourceMapper.Get<IEventSource<Guid>, Guid>(BucketSupport.DefaultBucketId, Guid.NewGuid().ToString(), int.MaxValue); }
protected override void Event() { _returnedEventSource = _eventSourceMapper.Get <IEventSource <Guid>, Guid>(BucketSupport.DefaultBucketId, Guid.NewGuid().ToString(), int.MaxValue); }
protected override void Context() { //var eventSourceMapper = new EventSourceMapper(new Mock<IEventSourceFactory>().Object, new Mock<IEventStore>().Object); _commandContextProvider.Setup(p => p.Get()).Returns(_commandContext); var aggregate = new AggregateStub(id); ((IEventSourceBase)aggregate).Flush(); _eventSourceMapper.Setup(m => m.Get<AggregateStub, Guid>(string.Empty, id.ToString(), 1)).Returns(aggregate); aggregate = new AggregateStub(id); aggregate.DoSomething("Hi version 2"); ((IEventSourceBase)aggregate).Flush(); _aggregate = aggregate; }
protected override void Context() { _eventSource = _aggregate = new AggregateStub(); _aggregate.DoSomething(_value); }
protected override void Context() { _eventSource = _aggregate = new AggregateStub(); }
protected override void Context() { _eventSource = _aggregate = new AggregateStub(); _events.Add(_eventFactory.Create<SomethingHappenedEvent>(e => {})); }
protected override void Context() { _eventSource = _aggregate = new AggregateStub(); _events.Add(_eventFactory.Create <SomethingHappenedEvent>(e => {})); }