예제 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            // Application dependencies

            var esSection = Configuration.GetSection("EventStore");

            var esConnection = BoostRoomEventStoreConnection.ConnectAsync(
                esSection["Host"],
                esSection["Username"],
                esSection["Password"]
                ).GetAwaiter().GetResult();

            var eventStore = new BoostRoom.Infrastructure.EventStore(esConnection);

            services.AddSingleton <IEventStore>(eventStore);
            services.AddSingleton <BoostRoom.Infrastructure.IEventStore>(eventStore);

            var rdbSection = Configuration.GetSection("RavenDB");

            var store = BoostRoomDocumentStore.Create(rdbSection["Host"], rdbSection["Database"]);

            services.AddSingleton <IDocumentStore>(store);
            services.AddSingleton <IUniqueAccountsRepository, UniqueAccountsRepository>();

            services.AddMediatR(typeof(AccountsApplicationAssembly));

            services.AddSingleton <IPasswordEncoder, AesPasswordEncoder>();
            services.AddSingleton <IClientRepository, ClientRepository>();
            services.AddSingleton <ISellerRepository, SellerRepository>();
            services.AddSingleton <IEmailSender, EmailSender>();

            services.AddScoped <RegistrationService, RegistrationService>();

            _uniqueAccountsProjection = new UniqueAccountsProjection(store, eventStore);

            // MVC Dependencies

            services
            .AddMvc(options => { options.Filters.Add <CustomExceptionFilterAttribute>(); })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddSwaggerGen(c =>
                                   c.SwaggerDoc("v1", new OpenApiInfo {
                Title = "Boostroom API", Version = "v1"
            })
                                   );

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; });
        }
        public UniqueAccountsProjectionTests(IntegrationFixture fixture) : base(fixture)
        {
            var eventStore = new Mock <BoostRoom.Infrastructure.IEventStore>();

            _projection = new UniqueAccountsProjection(DocumentStore, eventStore.Object);
        }