Exemplo n.º 1
0
        public void CanHookUpEventAutoSave()
        {
            SimpleTextAggregate agg = new SimpleTextAggregate("foo");
            IEvent @event           = agg.GetUncommittedEvents().Single();

            SaveEvent(@event, _conn);

            agg.Commit();

            agg.EventCreated += Agg_EventCreated;

            agg.Text = "bar";

            Assert.Empty(agg.GetUncommittedEvents());

            Assert.Equal(2, GetRowCount("events"));
        }
Exemplo n.º 2
0
        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);
        }