Пример #1
0
        public void Can_apply_domain_events_to_entity()
        {
            var entity = new SomeDomainEntityWithEvents();
            var domainEvent = new SomeDomainEvent();

            entity.Apply(domainEvent);

            var changes = entity.GetChanges();

            changes.ShouldNotBeNull();
            changes.Count().ShouldBeEqualTo(1, "Only one event should have been applied to aggregate");
            changes.First().ShouldBeSameAs(domainEvent, "The event applied to aggregate was not the one expected");
        }
Пример #2
0
        public void can_write_aggregate_to_xml()
        {
            var storage = new XmlEventStorage(this);

            var aggregate = new SomeDomainEntityWithEvents();
            aggregate.Apply(new SomeDomainEvent());

            storage.Save(aggregate.Id, aggregate.GetChanges());

            _writtenXml.ShouldNotBeNull();
            _writtenXml.Length.ShouldNotBeEqualTo(0);

            var ev = DomainEventSerializer.Deserialize(_writtenXml.ToString());

            ev.ShouldNotBeNull();
            ev.ShouldBeOfType<SomeDomainEvent>();
        }