public void TestSimpleTextAggregate() { Guid guid = Guid.NewGuid(); DateTime createdDate = new DateTime(2020, 12, 25); SimpleTextAggregateCreatedEvent createdEvent = new SimpleTextAggregateCreatedEvent(Guid.NewGuid(), guid, createdDate, "foo"); SimpleTextAggregate agg = new SimpleTextAggregate(); agg.Apply(new List <IEvent>() { createdEvent }); Assert.Equal(guid, agg.AggregateId); Assert.Equal("foo", agg.Text); agg.Apply(new SimpleTextAggregateUpdatedEvent(Guid.NewGuid(), guid, DateTime.UtcNow, "bar")); Assert.Equal("bar", agg.Text); }
public void CanPersistAndRehydrateSimpleAggregate(IEventRepository repo) { SimpleTextAggregate agg = new SimpleTextAggregate("foo"); agg.Text = "bar"; foreach (IEvent @event in agg.GetUncommittedEvents()) { repo.Save(@event); } Assert.Equal(2, repo.GetEvents(agg.AggregateId).Count()); agg.Commit(); SimpleTextAggregate agg2 = new SimpleTextAggregate(); agg2.Apply(repo.GetEvents(agg.AggregateId)); Assert.Equal(agg.AggregateId, agg2.AggregateId); Assert.Equal(agg.Text, agg2.Text); }