Browse Source
Add test to verify new entity cache is returned when added
pull/22720/head
maliming
1 year ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
23 additions and
0 deletions
-
framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/EntityCache_Tests.cs
|
|
|
@ -70,6 +70,29 @@ public abstract class EntityCache_Tests<TStartupModule> : TestAppTestBase<TStart |
|
|
|
(await ProductCacheItem.FindAsync(TestDataBuilder.ProductId)).ShouldBeNull(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Return_New_EntityCache_IF_Added() |
|
|
|
{ |
|
|
|
var productId = Guid.NewGuid(); |
|
|
|
(await ProductEntityCache.FindAsync(productId)).ShouldBeNull(); |
|
|
|
(await ProductCacheItem.FindAsync(productId)).ShouldBeNull(); |
|
|
|
|
|
|
|
var product = new Product(productId, "Product2", decimal.Zero); |
|
|
|
await ProductRepository.InsertAsync(product); |
|
|
|
|
|
|
|
product = await ProductEntityCache.FindAsync(product.Id); |
|
|
|
product.ShouldNotBeNull(); |
|
|
|
product.Id.ShouldBe(productId); |
|
|
|
product.Name.ShouldBe("Product2"); |
|
|
|
product.Price.ShouldBe(decimal.Zero); |
|
|
|
|
|
|
|
var productCacheItem = await ProductCacheItem.FindAsync(product.Id); |
|
|
|
productCacheItem.ShouldNotBeNull(); |
|
|
|
productCacheItem.Id.ShouldBe(productId); |
|
|
|
productCacheItem.Name.ShouldBe("Product2"); |
|
|
|
productCacheItem.Price.ShouldBe(decimal.Zero); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Return_New_EntityCache_IF_Updated() |
|
|
|
{ |
|
|
|
|