public static Create ( IIdentity id, int size ) : |
||
id | IIdentity | |
size | int | |
Результат |
public async void ReadAppend() { var appender = new StreamAppenderAsync(StreamAppenderAsync.StreamAppenderOptions.UseSingleStream(this.appendStream)); var es = new EventStoreAsync(appender); var id = new StringId("id1"); var events = new IEvent[] { BigEventData.Create(id, 12), BigEventData.Create(id, 128), BigEventData.Create(id, 13) }; var id2 = new StringId("id2"); var events2 = new IEvent[] { BigEventData.Create(id, 100), BigEventData.Create(id, 128), BigEventData.Create(id, 100) }; var events3 = new IEvent[] { BigEventData.Create(id, 44) }; await es.AppendToStream(id, 0, events.ToList()); await es.AppendToStream(id2, 0, events2.ToList()); await es.AppendToStream(id, 1, events3.ToList()); Assert.Equal(2800, this.appendStream.Length); var stream = await es.LoadEventStream(id); Assert.Equal(2, stream.Version); var stream2 = await es.LoadEventStream(id2); Assert.Equal(1, stream2.Version); }
public async Task WriteTwoStreamsAndReadAll() { var id1 = GuidId.NewGuidId(); var id2 = GuidId.NewGuidId(); await this.eventstore.AppendToStream(id1, 0, new IEvent[] { BigEventData.Create(id1, 228) }); await this.eventstore.AppendToStream(id1, 1, new IEvent[] { BigEventData.Create(id1, 118), BigEventData.Create(id1, 98), BigEventData.Create(id1, 328) }); await this.eventstore.AppendToStream(id1, 2, new IEvent[] { BigEventData.Create(id1, 28) }); await this.eventstore.AppendToStream(id2, 0, new IEvent[] { BigEventData.Create(id2, 128), BigEventData.Create(id2, 228) }); var stream = await this.eventstore.LoadEventStream(id1, 1, 2); Assert.Equal(3, stream.Events.Count); Assert.Equal(2, stream.Version); }
public async Task WriteSingleAppend() { var id = new StringId("test-" + Guid.NewGuid()); await this.eventstore.AppendToStream(id, 0, new IEvent[] { BigEventData.Create(id, 120), BigEventData.Create(id, 110) }); }
public async Task AppendRandomId() { var id = GuidId.NewGuidId(); await this.eventstore.AppendToStream(id, 0, new IEvent[] { BigEventData.Create(id, 440), BigEventData.Create(id, 200) }); await this.eventstore.AppendToStream(id, 1, new IEvent[] { BigEventData.Create(id, 30), BigEventData.Create(id, 200) }); var events = await this.eventstore.LoadEventStream(id); Assert.Equal(2, events.Version); }
public async void WriteAppend() { var appender = new StreamAppenderAsync(StreamAppenderAsync.StreamAppenderOptions.UseSingleStream(this.appendStream)); var es = new EventStoreAsync(appender); var id = new StringId("id1"); var events = new IEvent[] { BigEventData.Create(id, 12), BigEventData.Create(id, 128), BigEventData.Create(id, 13) }; await es.AppendToStream(id, 0, events.ToList()); Assert.Equal(962, this.appendStream.Length); }
public async Task CanAppendEvents() { var id = new StringId("mystream"); var events = new IEvent[] { BigEventData.Create(id, 20), BigEventData.Create(id, 1024), BigEventData.Create(id, 400121), BigEventData.Create(id, 2048) }; await this.eventstore.AppendToStream(id, 0, events); await this.eventstore.AppendToStream(id, 1, events); await this.eventstore.AppendToStream(new StringId("stream2"), 0, events); }
public async Task WriteTwoStreamsAndReadAll() { var id1 = GuidId.NewGuidId(); var id2 = GuidId.NewGuidId(); await this.eventstore.AppendToStream(id1, 0, new IEvent[] { BigEventData.Create(id1, 1024 * 1024 * 3) }); await this.eventstore.AppendToStream(id1, 1, new IEvent[] { BigEventData.Create(id1, 1024 * 1024 * 2), BigEventData.Create(id1, 98), BigEventData.Create(id1, 328) }); await this.eventstore.AppendToStream(id1, 2, new IEvent[] { BigEventData.Create(id1, 28) }); await this.eventstore.AppendToStream(id2, 0, new IEvent[] { BigEventData.Create(id2, 128), BigEventData.Create(id2, 228) }); var stream = await this.eventstore.LoadEventStream(id1, 1, 2); await this.appender.WriteAll(); var stream1 = await this.appender.ReadRecords(id1.ToString(), 0, Int32.MaxValue); Assert.Equal(3, stream1.Length); var stream2 = await this.appender.ReadRecords(id2.ToString(), 0, Int32.MaxValue); Assert.Equal(1, stream2.Length); Assert.Equal(869, stream1[0].Data.Length); Assert.Equal(1377, stream1[1].Data.Length); Assert.Equal(869, stream1[0].Data.Length); Assert.Equal(869, stream1[0].Data.Length); }
public async Task CanConflictOnAppend() { var id = GuidId.NewGuidId(); var events = new IEvent[] { BigEventData.Create(id, 20), BigEventData.Create(id, 1024), BigEventData.Create(id, 400121), BigEventData.Create(id, 2048) }; var run1 = this.eventstore.AppendToStream(id, 0, events); var run2 = this.eventstore.AppendToStream(id, 1, events); var run3 = this.eventstore.AppendToStream(id, 2, events); var run4 = this.eventstore.AppendToStream(id, 3, events); try { Task.WaitAll(run3, run2, run4, run1); } catch (AggregateException ex) { throw; } }