示例#1
0
        public AggregateRootTestFixture() : base()
        {
            Guid commitId = Guid.NewGuid();
            Guid sourceId = Guid.NewGuid();

            CreationStrategy = new SimpleAggregateRootCreationStrategy();

            AggregateRoot   = CreationStrategy.CreateAggregateRoot <TAggregateRoot>();
            PublishedEvents = new List <UncommittedEvent>();

            var history = Given();

            if (history != null)
            {
                long sequence = 0;
                var  stream   = Prepare.Events(history).ForSource(AggregateRoot.EventSourceId);
                AggregateRoot.InitializeFromHistory(stream);
            }

            try
            {
                AggregateRoot.EventApplied += (s, e) => PublishedEvents.Add(e.Event);
                When();
            }
            catch (Exception exception)
            {
                CaughtException = exception;
            }
            finally
            {
                Finally();
            }
        }
示例#2
0
        private UncommittedEventStream ConvertGivenEvents()
        {
            var history = GivenEvents();

            return(Prepare.Events(history)
                   .ForSourceUncomitted(EventSourceId, Guid.NewGuid()));
        }