mirror of https://github.com/abpframework/abp.git
8 changed files with 84 additions and 18 deletions
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.TestApp.Testing; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.Uow |
|||
{ |
|||
public class Uow_Completed_Tests : Uow_Completed_Tests<AbpEntityFrameworkCoreTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.TestApp.Testing; |
|||
|
|||
namespace Volo.Abp.MongoDB.Uow |
|||
{ |
|||
public class Uow_Completed_Tests : Uow_Completed_Tests<AbpMongoDbTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.TestApp.Domain; |
|||
using Volo.Abp.Uow; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TestApp.Testing |
|||
{ |
|||
public abstract class Uow_Completed_Tests<TStartupModule> : TestAppTestBase<TStartupModule> |
|||
where TStartupModule : IAbpModule |
|||
{ |
|||
private readonly IUnitOfWorkManager _unitOfWorkManager; |
|||
private readonly ICityRepository _cityRepository; |
|||
|
|||
protected Uow_Completed_Tests() |
|||
{ |
|||
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>(); |
|||
_cityRepository = GetRequiredService<ICityRepository>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Be_Able_To_Perform_Database_Operation_On_Uow_Complete() |
|||
{ |
|||
using (var uow = _unitOfWorkManager.Begin()) |
|||
{ |
|||
//Perform an arbitrary database operation
|
|||
await _cityRepository.InsertAsync(new City(Guid.NewGuid(), Guid.NewGuid().ToString())); |
|||
|
|||
uow.OnCompleted(async () => |
|||
{ |
|||
//Perform another database operation inside the OnCompleted handler
|
|||
await _cityRepository.InsertAsync(new City(Guid.NewGuid(), Guid.NewGuid().ToString())); |
|||
}); |
|||
|
|||
await uow.CompleteAsync(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue