Browse Source

Use generic EntityNotFoundException<TEntity> in GetManyAsync for consistency with GetAsync

pull/25088/head
maliming 7 months ago
parent
commit
08c6521a59
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.cs
  2. 4
      framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/EntityCache_Tests.cs

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.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;

4
framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/EntityCache_Tests.cs

@ -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]

Loading…
Cancel
Save