public async Task Verify_population_of_basic_properties_on_insert() { var rm = CreateNew(); SampleAggregateCreated evt = HandleEvent(new SampleAggregateCreated()); await sut.InsertAsync(evt, rm); var reloaded = await sut.FindOneByIdAsync(rm.Id); Assert.That(reloaded.CheckpointToken, Is.EqualTo(1L)); Assert.That(reloaded.SecondaryToken, Is.GreaterThan(0)); }
public async Task upsert_update_old_readmodel() { var insert = new InsertEvent() { Text = "one" }; var update = new InsertEvent() { Text = "one" }; update.AssignIdForTest(insert.AggregateId); await _collection.InsertAsync(insert, new MyReadModel() { Id = insert.AggregateId.AsString(), Text = "created" }); await _collection.UpsertAsync( update, update.AggregateId.AsString(), () => new MyReadModel() { Id = insert.AggregateId.AsString(), Text = "created" }, r => { r.Text = "updated"; } ); var saved = _collection.All.FirstOrDefault(x => x.Id == insert.AggregateId.AsString()); Assert.IsNotNull(saved); Assert.AreEqual("updated", saved.Text); }
public async Task Verify_basic_delete() { var rm = new SampleReadModelTest(); rm.Id = new TestId(1); rm.Value = "test"; await sut.InsertAsync(new SampleAggregateCreated(), rm).ConfigureAwait(false); var all = sut.All.ToList(); Assert.That(all, Has.Count.EqualTo(1)); await sut.DeleteAsync(new SampleAggregateInvalidated(), rm.Id).ConfigureAwait(false); all = sut.All.ToList(); Assert.That(all, Has.Count.EqualTo(0)); }