Beispiel #1
0
        public BaseSpec()
        {
            var builder = new BoundedContextModelBuilder();

            builder.UseInMemoryBuses();
            builder.UseInMemoryEventStore();
            builder.Aggregate <FlightReservation>(cfg =>
            {
                cfg
                .WithId(c => c.Localizer)
                .CreatedBy <CreateFlightReservation>()
                .Executes <CancelFlightReservation>(c => c.Localizer);
            });
            builder.Projection <ReservationViewProjection>(cfg =>
            {
                cfg
                .WithState(c => c.LastEventId)
                .AutoSubscribe();
            });
            builder.ReadModel <ReservationView, ReservationViewRepository>(cfg =>
            {
                cfg.RespondsTo <SearchReservationsByFlight>(c => c.Query);
            });
            Model      = builder.Build();
            CommandBus = Model.Services.GetRequiredService <ICommandBus>();
            Host       = new Hosting.HostProcess(Model);
            Host.Start();
        }