public override void SetUp()
        {
            base.SetUp();

            DatabaseHelper.CleanEvents();
            DatabaseHelper.CleanEventStreams();

            var eventRepository = new EventRepository(DatabaseHelper.GetConnectionStringBuilder());

            EventSerializer = new Serialization.Newtonsoft.EventSerializer();

            var logger = new SerilogLogger(Log.ForContext<EventStore>());

            var eventStore = new EventStore(
                EventSerializer,
                eventRepository,
                logger,
                Guid.NewGuid);

            AggregateContext = new AggregateContext(
                eventStore,
                null, // TODO: replace with actual SnapshotStore
                new AggregateHydrator(),
                new DummyDispatcher());
        }
Beispiel #2
0
 public static Product Create(
     IAggregateContext context,
     ProductName productName)
 {
     return(Product.CreateWithEvent <Product, ProductCreated>(
                context,
                new ProductCreated(
                    ProductIdentifier.New(),
                    productName)));
 }
Beispiel #3
0
 public static Order Create(
     IAggregateContext context,
     OrderIdentifier orderIdentifier,
     CustomerIdentifier customerIdentifier)
 {
     return(CreateWithEvent <Order, OrderCreated>(
                context,
                new OrderCreated(
                    orderIdentifier,
                    customerIdentifier)));
 }
Beispiel #4
0
        protected static TAggregateRoot CreateWithEvent <TAggregateRoot, TEvent>(IAggregateContext context, TEvent firstEvent)
            where TAggregateRoot : AggregateRoot <TIdentifier>
            where TEvent : Event
        {
            var now           = context.GetDateTime();
            var aggregateRoot = CallAggregateConstructor <TAggregateRoot, TEvent>(new TypedEvent <TEvent>(now, firstEvent));

            aggregateRoot._context = context;

            aggregateRoot.ApplyInitialEvent(new LoadedEvent(now, firstEvent));
            return(aggregateRoot);
        }
Beispiel #5
0
 void IAggregateLoader.SetAggregateContext(IAggregateContext context)
 {
     _context = context;
 }
Beispiel #6
0
 public ProductRepository(IEventStore eventStore, IAggregateContext context)
     : base(eventStore, context)
 {
 }
 protected override AggregateValue CreateAggregate(IAggregateContext context)
 {
     return this.CreateAggregate(context.DataType);
 }
Beispiel #8
0
 public Repository(IEventStore eventStore, IAggregateContext aggregateContext)
 {
     AggregateContext = aggregateContext;
     _eventStore      = eventStore;
 }
Beispiel #9
0
 public OrderRepository(IEventStore eventStore, IAggregateContext context)
     : base(eventStore, context)
 {
 }