예제 #1
0
        public void TestInitialize()
        {
            var eventstorage     = new SpecDomainEventStorage(Given().ToList());
            var snapshotstorage  = new SpecSnapShotStorage(Snapshot);
            var eventpublisher   = new SpecDomainEventPublisher();
            var snapshotStrategy = new DefaultSnapshotStrategy();
            var repository       = new SnapshotRepository(snapshotstorage, snapshotStrategy,
                                                          new DomainRepository(eventstorage, eventpublisher), eventstorage);

            Session = new Session(repository);

            try
            {
                Aggregate = Session.Get <TAggregate>(Guid.Empty);
            }
            catch (AggregateNotFoundException)
            {
            }

            var handler = BuildHandler();

            handler.Handle(When());

            Snapshot = snapshotstorage.Snapshot;

            PublishedEvents  = eventpublisher.PublishedEvents;
            EventDescriptors = eventstorage.Events;
        }
예제 #2
0
        public void TestInitialize()
        {
            var eventstorage     = new SpecDomainEventStorage(Given().ToList());
            var snapshotstorage  = new SpecSnapShotStorage(Snapshot);
            var eventpublisher   = new SpecDomainEventPublisher();
            var snapshotStrategy = new DefaultSnapshotStrategy();

            DomainRepository = new SnapshotRepository(snapshotstorage, snapshotStrategy,
                                                      new DomainRepository(eventstorage, eventpublisher), eventstorage);
            Session = new Session(DomainRepository);

            var handler = BuildHandler();

            try
            {
                var @when = When();
                if (@when != null)
                {
                    handler.Handle(@when);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Exception = e;
            }

            Snapshot = snapshotstorage.Snapshot;

            PublishedEvents  = eventpublisher.PublishedEvents;
            EventDescriptors = eventstorage.Events;
        }