public async Task GetTenantFeatureCacheItemAsync_ShouldEnableFilterMayHaveTenant_Test() { // Arrange var tenant = new Tenant("TestTenant", "TestTenant"); await _tenantRepository.InsertAsync(tenant); var tenant2 = new Tenant("TestTenant2", "TestTenant2"); await _tenantRepository.InsertAsync(tenant2); using (var uow = _unitOfWorkManager.Begin()) { await _tenantFeatureRepository.InsertAsync(new TenantFeatureSetting(tenant.Id, AppFeatures.SimpleBooleanFeature, "true")); await _unitOfWorkManager.Current.SaveChangesAsync(); // Assert (before disable filter) (await _featureValueStore.GetValueOrNullAsync(tenant.Id, AppFeatures.SimpleBooleanFeature)).ShouldBe("true"); (await _featureValueStore.GetValueOrNullAsync(tenant2.Id, AppFeatures.SimpleBooleanFeature)).ShouldBeNull(); // Act (clear cache and disable filter) await _cacheManager.GetTenantFeatureCache().ClearAsync(); using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant)) { // Assert (after disable filter) (await _featureValueStore.GetValueOrNullAsync(tenant.Id, AppFeatures.SimpleBooleanFeature)).ShouldBe("true"); (await _featureValueStore.GetValueOrNullAsync(tenant2.Id, AppFeatures.SimpleBooleanFeature)).ShouldBeNull(); } await uow.CompleteAsync(); } }
/// <inheritdoc/> public async Task <string> GetValueAsync(int tenantId, string name) { var feature = _featureManager.Get(name); var value = await FeatureValueStore.GetValueOrNullAsync(tenantId, feature); return(value ?? feature.DefaultValue); }