예제 #1
0
        public void EventsAreDeletedWhenUnitOfWorkIsCommitted()
        {
            var bus   = new MockServiceBus();
            var store = new MockEventStore();

            using (var session = new EventStoreSession(bus, store, new SingleThreadUseGuard(), DateTimeNowTimeSource.Instance))
            {
                var uow = new UnitOfWork(new SingleThreadUseGuard());
                uow.AddParticipant(session);

                var aggregate1 = new Guid("92EC4FE2-26A8-4274-8674-DC5D95513C83");
                var aggregate2 = new Guid("F08200E4-8790-4ECC-9F06-A3D3BAC9E21C");

                session.Delete(aggregate1);
                session.Delete(aggregate2);

                session.SaveChanges();

                Assert.That(store.DeletedAggregates, Is.Empty);

                uow.Commit();

                Assert.That(store.DeletedAggregates, Is.EquivalentTo(new[] { aggregate1, aggregate2 }));
            }
        }
예제 #2
0
        public void EventsAreDeletedWhenNotAUnitOfWorkParticipant()
        {
            var bus   = new MockServiceBus();
            var store = new MockEventStore();

            using (var session = new EventStoreSession(bus, store, new SingleThreadUseGuard(), DateTimeNowTimeSource.Instance))
            {
                var aggregate1 = new Guid("92EC4FE2-26A8-4274-8674-DC5D95513C83");
                var aggregate2 = new Guid("F08200E4-8790-4ECC-9F06-A3D3BAC9E21C");

                session.Delete(aggregate1);
                session.Delete(aggregate2);

                session.SaveChanges();
                session.SaveChanges();  // Verify that SaveChanges() does not delete the events twice.

                Assert.That(store.DeletedAggregates, Is.EquivalentTo(new[] { aggregate1, aggregate2 }));
            }
        }
        public void EventsAreDeletedWhenUnitOfWorkIsCommitted()
        {
            var bus = new MockServiceBus();
            var store = new MockEventStore();

            using (var session = new EventStoreSession(bus, store, new SingleThreadUseGuard()))
            {
                var uow = new UnitOfWork(new SingleThreadUseGuard());
                uow.AddParticipant(session);

                var aggregate1 = new Guid("92EC4FE2-26A8-4274-8674-DC5D95513C83");
                var aggregate2 = new Guid("F08200E4-8790-4ECC-9F06-A3D3BAC9E21C");

                session.Delete(aggregate1);
                session.Delete(aggregate2);

                session.SaveChanges();

                Assert.That(store.DeletedAggregates, Is.Empty);

                uow.Commit();

                Assert.That(store.DeletedAggregates, Is.EquivalentTo(new[] { aggregate1, aggregate2 }));
            }
        }
        public void EventsAreDeletedWhenNotAUnitOfWorkParticipant()
        {
            var bus = new MockServiceBus();
            var store = new MockEventStore();

            using (var session = new EventStoreSession(bus, store, new SingleThreadUseGuard()))
            {
                var aggregate1 = new Guid("92EC4FE2-26A8-4274-8674-DC5D95513C83");
                var aggregate2 = new Guid("F08200E4-8790-4ECC-9F06-A3D3BAC9E21C");

                session.Delete(aggregate1);
                session.Delete(aggregate2);

                session.SaveChanges();
                session.SaveChanges();  // Verify that SaveChanges() does not delete the events twice.

                Assert.That(store.DeletedAggregates, Is.EquivalentTo(new[] { aggregate1, aggregate2 }));
            }
        }