示例#1
0
        public async Task DeleteAsync_OneGenericVersion_Success_Should_HaveZeroCountInTrackedEntities()
        {
            const int expCount = 0;
            IRepositoryAsync <TestAggregateRoot> repository = new TestAggregateRootRepository1(_Context);
            var aggregateRoot = new TestAggregateRoot("testing");

            var entry = await repository.DeleteAsync(new object[] { aggregateRoot.Id });

            entry.Should().BeNull();
            _Context.ChangeTracker.Entries <TestAggregateRoot>()
            .Should().HaveCount(expCount);
        }
示例#2
0
        public async Task DeleteAsync_OneGenericVersion_Success_Should_AddEntityWithDeletedState()
        {
            const int expCount      = 1;
            var       aggregateRoot = new TestAggregateRoot("testing");

            _Context.Add(aggregateRoot);
            await _Context.SaveChangesAsync();

            _Context.ChangeTracker.Clear();

            IRepositoryAsync <TestAggregateRoot> repository = new TestAggregateRootRepository1(_Context);

            var entry = await repository.DeleteAsync(new object[] { aggregateRoot.Id });

            entry.Should().NotBeNull();
            _Context.ChangeTracker.Entries <TestAggregateRoot>()
            .Should().HaveCount(expCount);
            _Context.ChangeTracker.Entries <TestAggregateRoot>()
            .Should().Contain(e => e.Entity.Id == aggregateRoot.Id && e.State == EntityState.Deleted);
        }