public void GetTenantFeatureCacheItem_ShouldEnableFilterMayHaveTenant_Test()
        {
            // Arrange
            var tenant = new Tenant("TestTenant", "TestTenant");

            _tenantRepository.Insert(tenant);

            var tenant2 = new Tenant("TestTenant2", "TestTenant2");

            _tenantRepository.Insert(tenant2);

            using (var uow = _unitOfWorkManager.Begin())
            {
                _tenantFeatureRepository.Insert(new TenantFeatureSetting(tenant.Id, AppFeatures.SimpleBooleanFeature, "true"));
                _unitOfWorkManager.Current.SaveChanges();

                // Assert (before disable filter)
                _featureValueStore.GetValueOrNull(tenant.Id, AppFeatures.SimpleBooleanFeature).ShouldBe("true");
                _featureValueStore.GetValueOrNull(tenant2.Id, AppFeatures.SimpleBooleanFeature).ShouldBeNull();

                // Act (clear cache and disable filter)
                _cacheManager.GetTenantFeatureCache().Clear();

                using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
                {
                    // Assert (after disable filter)
                    _featureValueStore.GetValueOrNull(tenant.Id, AppFeatures.SimpleBooleanFeature).ShouldBe("true");
                    _featureValueStore.GetValueOrNull(tenant2.Id, AppFeatures.SimpleBooleanFeature).ShouldBeNull();
                }

                uow.Complete();
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public string GetValue(int tenantId, string name)
        {
            var feature = _featureManager.Get(name);
            var value   = FeatureValueStore.GetValueOrNull(tenantId, feature);

            return(value ?? feature.DefaultValue);
        }