Exemplo n.º 1
0
 protected override void Context()
 {
     _unitOfWork = new UnitOfWork(_commandContextProvider.Object, _eventSourceMapper.Object);
     _aggregate = new AggregateStringStub();
     _commandContextProvider.Setup(p => p.Get()).Returns(_commandContext);
     _unitOfWork.Register(_aggregate);
 }
Exemplo n.º 2
0
 protected override void Context()
 {
     _unitOfWork = new UnitOfWork(_commandContextProvider.Object, _eventSourceMapper.Object);
     _aggregate  = new AggregateStringStub();
     _commandContextProvider.Setup(p => p.Get()).Returns(_commandContext);
     _unitOfWork.Register(_aggregate);
 }
Exemplo n.º 3
0
            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;
            }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
0
 protected override void Event()
 {
     _returnedEventSource = _eventSourceMapper.Get<IEventSource<Guid>, Guid>(BucketSupport.DefaultBucketId, Guid.NewGuid().ToString(), int.MaxValue);
 }
Exemplo n.º 6
0
 protected override void Event()
 {
     _returnedEventSource = _eventSourceMapper.Get <IEventSource <Guid>, Guid>(BucketSupport.DefaultBucketId, Guid.NewGuid().ToString(), int.MaxValue);
 }
Exemplo n.º 7
0
            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;
            }
Exemplo n.º 8
0
 protected override void Context()
 {
     _eventSource = _aggregate = new AggregateStub();
     _aggregate.DoSomething(_value);
 }
Exemplo n.º 9
0
 protected override void Context()
 {
     _eventSource = _aggregate = new AggregateStub();
 }
Exemplo n.º 10
0
 protected override void Context()
 {
     _eventSource = _aggregate = new AggregateStub();
     _events.Add(_eventFactory.Create<SomethingHappenedEvent>(e => {}));
 }
Exemplo n.º 11
0
 protected override void Context()
 {
     _eventSource = _aggregate = new AggregateStub();
 }
Exemplo n.º 12
0
 protected override void Context()
 {
     _eventSource = _aggregate = new AggregateStub();
     _events.Add(_eventFactory.Create <SomethingHappenedEvent>(e => {}));
 }
Exemplo n.º 13
0
 protected override void Context()
 {
     _eventSource = _aggregate = new AggregateStub();
     _aggregate.DoSomething(_value);
 }