Browse Source
Use generic EntityNotFoundException<TEntity> in GetManyAsync for consistency with GetAsync
pull/25088/head
maliming
7 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
3 additions and
3 deletions
-
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.cs
-
framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/EntityCache_Tests.cs
|
|
|
@ -90,7 +90,7 @@ public abstract class EntityCacheBase<TEntity, TEntityCacheItem, TKey> : |
|
|
|
var cacheItem = cacheItemDict.TryGetValue(id!, out var wrapper) ? wrapper?.Value : null; |
|
|
|
if (cacheItem == null) |
|
|
|
{ |
|
|
|
throw new EntityNotFoundException(typeof(TEntity), id); |
|
|
|
throw new EntityNotFoundException<TEntity>(id); |
|
|
|
} |
|
|
|
|
|
|
|
return cacheItem; |
|
|
|
|
|
|
|
@ -66,8 +66,8 @@ public abstract class EntityCache_Tests<TStartupModule> : TestAppTestBase<TStart |
|
|
|
public async Task GetMany_Should_Throw_EntityNotFoundException_For_Not_Existing_Entities() |
|
|
|
{ |
|
|
|
var notExistId = Guid.NewGuid(); |
|
|
|
await Assert.ThrowsAsync<EntityNotFoundException>(() => ProductEntityCache.GetManyAsync(new[] { notExistId })); |
|
|
|
await Assert.ThrowsAsync<EntityNotFoundException>(() => ProductCacheItem.GetManyAsync(new[] { notExistId })); |
|
|
|
await Assert.ThrowsAsync<EntityNotFoundException<Product>>(() => ProductEntityCache.GetManyAsync(new[] { notExistId })); |
|
|
|
await Assert.ThrowsAsync<EntityNotFoundException<Product>>(() => ProductCacheItem.GetManyAsync(new[] { notExistId })); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
|