mirror of https://github.com/abpframework/abp.git
6 changed files with 86 additions and 10 deletions
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Abp.TestApp.Testing; |
||||
|
|
||||
|
namespace Volo.Abp.EntityFrameworkCore.Repositories; |
||||
|
|
||||
|
public class RepositoryExtensions_Tests : RepositoryExtensions_Tests<AbpEntityFrameworkCoreTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Abp.TestApp.Testing; |
||||
|
|
||||
|
namespace Volo.Abp.MemoryDb.Repositories; |
||||
|
|
||||
|
public class RepositoryExtensions_Tests : RepositoryExtensions_Tests<AbpMemoryDbTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
using Volo.Abp.TestApp.Testing; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.MongoDB.Repositories; |
||||
|
|
||||
|
[Collection(MongoTestCollection.Name)] |
||||
|
public class RepositoryExtensions_Tests : RepositoryExtensions_Tests<AbpMongoDbTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Entities; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.TestApp.Domain; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.TestApp.Testing; |
||||
|
|
||||
|
public abstract class RepositoryExtensions_Tests<TStartupModule> : TestAppTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
protected readonly IRepository<Person, Guid> PersonRepository; |
||||
|
|
||||
|
protected RepositoryExtensions_Tests() |
||||
|
{ |
||||
|
PersonRepository = GetRequiredService<IRepository<Person, Guid>>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task EnsureExistsAsync_Test() |
||||
|
{ |
||||
|
await WithUnitOfWorkAsync(async () => |
||||
|
{ |
||||
|
var id = Guid.NewGuid(); |
||||
|
await Assert.ThrowsAsync<EntityNotFoundException>(async () => |
||||
|
await PersonRepository.EnsureExistsAsync(Guid.NewGuid()) |
||||
|
); |
||||
|
await Assert.ThrowsAsync<EntityNotFoundException>(async () => |
||||
|
await PersonRepository.EnsureExistsAsync(x => x.Id == id) |
||||
|
); |
||||
|
|
||||
|
await PersonRepository.EnsureExistsAsync(TestDataBuilder.UserDouglasId); |
||||
|
await PersonRepository.EnsureExistsAsync(x => x.Id == TestDataBuilder.UserDouglasId); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue