コード例 #1
0
        public async Task SaveChanges_RemovesDeleted()
        {
            TestAggregate testAggregate = new TestAggregate(Guid.NewGuid());

            crudRepository.Add(testAggregate);
            await crudRepository.SaveChangesAsync();

            testAggregate = await sut.GetAsync <TestAggregate>(testAggregate.Id);

            testAggregate.Do();
            var event1 = testAggregate.UncommittedEvents.First();

            testAggregate.Remove();

            await sut.SaveChangesAsync();

            Received.InOrder(() =>
            {
                crudRepository.SaveChangesAsync();
                crudRepository.Remove(testAggregate);
                crudRepository.SaveChangesAsync();
            });

            publishEventBuffer.Received(1).PushEvent(Arg.Is <IEventMessage>(x => x.Event == event1));
            crudRepository.GetEntityState(testAggregate).Should().Be(EntityState.Detached);
        }