Exemple #1
0
        internal static ContainerBuilder BuilderContainer()
        {
            var builder = new ContainerBuilder();

            #region CommandHandlers
            builder.RegisterType <CreateOrdineClienteCommandHandler>().As <IHandleRequestsAsync <CreateOrdineCliente> >().AsSelf()
            .InstancePerLifetimeScope();
            #endregion

            var commandStore = new InMemoryCommandStore();
            builder.RegisterInstance <IAmACommandStore>(commandStore).AsSelf().SingleInstance();

            var eventStoreRepository = new InMemoryEventRepository(new List <Event>());
            builder.RegisterInstance <IRepository>(eventStoreRepository).SingleInstance();

            return(builder);
        }
        protected bool RunTest(InMemoryEventRepository inMemoryRepository)
        {
            this.Caught     = null;
            this.Repository = inMemoryRepository;
            this.Repository.SetGivenEvents(this.Given().ToList());
            var handler = this.OnHandler();

            try
            {
                handler.HandleAsync(this.When()).Wait();
                var expected  = this.Expect().ToList();
                var published = this.Repository.Events;
                CompareEvents(expected, published);
            }
            catch (Exception exception)
            {
                this.Caught = exception;
                return(false);
            }

            return(true);
        }