public static async Task SaveEventsAsync(this BoostRoom.Infrastructure.EventStore eventStore, string stream, int version, IReadOnlyCollection <IDomainEvent> events) { await eventStore.Connection.AppendToStreamAsync(stream, version, events.Select(e => { var json = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(e, BoostRoom.Infrastructure.EventStore.SerializerSettings)); return(new EventData(Guid.NewGuid(), e.GetType().Name, true, json, new byte[] { })); })); }
public static async Task <IReadOnlyCollection <IDomainEvent> > LoadAllEventsAsync( this BoostRoom.Infrastructure.EventStore eventStore) { var streamEvents = await eventStore.Connection.ReadAllEventsForwardAsync(Position.Start, 4096, false); return(streamEvents.Events .Where(e => e.Event.EventStreamId[0] != '$') .Select(BoostRoom.Infrastructure.EventStore.DeserializeDomainEvent) .ToList() .AsReadOnly()); }
public ClientsControllerTests( IntegrationFixture fixture, AccountsApplicationFactory <Startup> factory) : base(fixture) { _client = factory.WithWebHostBuilder(builder => { builder.ConfigureServices(services => { _eventStore = new BoostRoom.Infrastructure.EventStore(EventStoreConnection); services.AddSingleton <IEventStore>(_eventStore); services.AddSingleton <BoostRoom.Infrastructure.IEventStore>(_eventStore); services.AddSingleton(DocumentStore); }); }) .CreateClient(); }