|
|
@ -1,10 +1,8 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.Text; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Castle.DynamicProxy.Generators; |
|
|
|
|
|
using Shouldly; |
|
|
using Shouldly; |
|
|
using Volo.Abp.Caching; |
|
|
using Volo.Abp.Caching; |
|
|
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
using Volo.Abp.Settings; |
|
|
using Volo.Abp.Settings; |
|
|
using Xunit; |
|
|
using Xunit; |
|
|
|
|
|
|
|
|
@ -16,6 +14,7 @@ namespace Volo.Abp.SettingManagement |
|
|
private readonly ISettingManagementStore _settingManagementStore; |
|
|
private readonly ISettingManagementStore _settingManagementStore; |
|
|
private readonly ISettingRepository _settingRepository; |
|
|
private readonly ISettingRepository _settingRepository; |
|
|
private readonly SettingTestData _testData; |
|
|
private readonly SettingTestData _testData; |
|
|
|
|
|
private readonly ICurrentTenant _currentTenant; |
|
|
|
|
|
|
|
|
public SettingCacheItemInvalidator_Tests() |
|
|
public SettingCacheItemInvalidator_Tests() |
|
|
{ |
|
|
{ |
|
|
@ -23,6 +22,7 @@ namespace Volo.Abp.SettingManagement |
|
|
_cache = GetRequiredService<IDistributedCache<SettingCacheItem>>(); |
|
|
_cache = GetRequiredService<IDistributedCache<SettingCacheItem>>(); |
|
|
_settingRepository = GetRequiredService<ISettingRepository>(); |
|
|
_settingRepository = GetRequiredService<ISettingRepository>(); |
|
|
_testData = GetRequiredService<SettingTestData>(); |
|
|
_testData = GetRequiredService<SettingTestData>(); |
|
|
|
|
|
_currentTenant = GetRequiredService<ICurrentTenant>(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
@ -49,5 +49,35 @@ namespace Volo.Abp.SettingManagement |
|
|
(await _cache.GetAsync( |
|
|
(await _cache.GetAsync( |
|
|
SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString())).ConfigureAwait(false)).ShouldBeNull(); |
|
|
SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString())).ConfigureAwait(false)).ShouldBeNull(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task Cache_Should_Invalidator_WhenSettingChanged_Between_Tenant_And_Host() |
|
|
|
|
|
{ |
|
|
|
|
|
var tenantId = Guid.NewGuid(); |
|
|
|
|
|
|
|
|
|
|
|
using (_currentTenant.Change(tenantId)) |
|
|
|
|
|
{ |
|
|
|
|
|
// GetOrNullAsync will cache language.
|
|
|
|
|
|
await _settingManagementStore |
|
|
|
|
|
.GetOrNullAsync("MySetting2", GlobalSettingValueProvider.ProviderName, null) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
using (_currentTenant.Change(null)) |
|
|
|
|
|
{ |
|
|
|
|
|
// SetAsync will make cache invalid.
|
|
|
|
|
|
await _settingManagementStore |
|
|
|
|
|
.SetAsync("MySetting2", "MySetting2Value", GlobalSettingValueProvider.ProviderName, null) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
using (_currentTenant.Change(tenantId)) |
|
|
|
|
|
{ |
|
|
|
|
|
// Assert
|
|
|
|
|
|
(await _cache.GetAsync( |
|
|
|
|
|
SettingCacheItem.CalculateCacheKey("MySetting2", GlobalSettingValueProvider.ProviderName, null)) |
|
|
|
|
|
.ConfigureAwait(false)).ShouldBeNull(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|