public async Task storing_an_aggregate_resets_list_of_changes() { var agg = PersonAggregateFactory.Create($"persons-{Guid.NewGuid()}", "Joe"); await Repository.StoreAsync(agg); Assert.That(agg.Changes, Is.Empty); }
public async Task saving_an_aggregate_clears_list_of_changes() { var id = $"Persons-{Guid.NewGuid()}"; var p = PersonAggregateFactory.Create(id, "Mary"); await Repository.StoreAsync(p); Assert.That(p.Changes, Is.Empty); }
public async Task cannot_load_aggregate_with_invalid_version_param() { var id = $"persons-{Guid.NewGuid()}"; var agg = PersonAggregateFactory.Create(id, "Joe"); await Repository.StoreAsync(agg); Assert.That(async() => await Repository.GetAsync <PersonAggregate>(agg.Id, -1), Throws.Exception.TypeOf <InvalidOperationException>()); }
public async Task can_store_and_load_aggregate() { var id = $"Persons-{Guid.NewGuid()}"; await Repository.StoreAsync(PersonAggregateFactory.Create(id, "Joe")); var pl = await Repository.GetAsync <PersonAggregate>(id); Assert.That(pl.Version, Is.EqualTo(1)); }
public async Task can_store_and_load_aggregates_below_page_size_treshold() { var id = $"persons-{Guid.NewGuid()}"; await Repository.StoreAsync(PersonAggregateFactory.Create(id, "Joe")); var agg = await Repository.GetAsync <PersonAggregate>(id); Assert.That(agg.Version, Is.EqualTo(1)); }
public async Task concurrent_updates_cause_WrongExpectedVersionException() { var id = $"persons-{Guid.NewGuid()}"; await Repository.StoreAsync(PersonAggregateFactory.Create(id, "Joe")); var agg = await Repository.GetAsync <PersonAggregate>(id); await TestingUtils.UpdateOutOfSession(id, Repository); TestingUtils.Rename(agg, "New name"); Assert.That(async() => { await Repository.StoreAsync(agg); }, Throws.Exception.TypeOf <ConcurrencyException>()); }
public async Task concurrent_updates_throw_AggregateConcurrencyException() { var id = $"Persons-{Guid.NewGuid()}"; await Repository.StoreAsync(PersonAggregateFactory.Create(id, "Joe")); var loadedAggregate = await Repository.GetAsync <PersonAggregate>(id); await TestingUtils.UpdateOutOfSession(id, Repository); TestingUtils.Rename(loadedAggregate, "Gary"); Assert.That(async() => await Repository.StoreAsync(loadedAggregate), Throws.Exception.TypeOf <AggregateConcurrencyException>()); }