コード例 #1
0
        public async Task CommitAsync_Success_Should_CommitTransaction()
        {
            var expCount = 1;

            var aggregateRep = Mock.Of <IRepositoryAsync <TestAggregateRoot, Guid> >();

            ITestUnitOfWork unitOfWork = new TestUnitOfWork(_Context, aggregateRep);

            await unitOfWork.CreateTransactionAsync();

            var aggregateRoot = new TestAggregateRoot("testing");

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

            _Context.ChangeTracker.Clear();

            await unitOfWork.CommitAsync();

            await unitOfWork.FinishTransactionAsync();

            _Context.TestAggregateRoots.Should().HaveCount(expCount);
        }