[英]How to ignore nested transactions using in-memory Sqlite on Unit Tests?
I am using AspNetZero/ AspNetBoilerplate to do some automated tests and I configured my Module to not disable transactions我正在使用 AspNetZero/AspNetBoilerplate 进行一些自动化测试,并将我的模块配置为不禁用事务
Configuration.UnitOfWork.IsTransactional = false;
But it is not working and I am having the following message:但它不起作用,我收到以下消息:
Configuration.UnitOfWork.IsTransactional = false;
My test is calling the following method:我的测试正在调用以下方法:
UnitOfWork(TransactionScopeOption.Suppress)]
public virtual async Task<Guid> CreateAsync(CreateEntryRequest input)
{
// Some code here ...
}
Did I miss any setting?我错过了任何设置吗?
[UnitOfWork(isTransactional: false)]
public GetTasksOutput GetTasks(GetTasksInput input)
{
var tasks = _taskRepository.GetAllWithPeople(input.AssignedPersonId, input.State);
return new GetTasksOutput
{
Tasks = Mapper.Map<List<TaskDto>>(tasks)
};
}
https://aspnetboilerplate.com/Pages/Documents/Unit-Of-Work#non-transactional-unit-of-work https://aspnetboilerplate.com/Pages/Documents/Unit-Of-Work#non-transactional-unit-of-work
I ended up with this solution:我最终得到了这个解决方案:
public virtual async Task<Guid> CreateAsync(CreateEntryRequest input)
{
using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
{
// Some code here ...
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.