Пример #1
0
    public async Task Cache_Should_Invalidator_WhenFeatureChanged()
    {
        // Arrange cache feature.
        (await _featureManagementStore.GetOrNullAsync(
             TestFeatureDefinitionProvider.SocialLogins,
             EditionFeatureValueProvider.ProviderName,
             TestEditionIds.Regular.ToString()
             )
        ).ShouldNotBeNull();

        var feature = await _featureValueRepository.FindAsync(
            TestFeatureDefinitionProvider.SocialLogins,
            EditionFeatureValueProvider.ProviderName,
            TestEditionIds.Regular.ToString()
            );

        // Act
        await _featureValueRepository.DeleteAsync(feature);

        // Assert
        (await _cache.GetAsync(
             FeatureValueCacheItem.CalculateCacheKey(
                 TestFeatureDefinitionProvider.SocialLogins,
                 EditionFeatureValueProvider.ProviderName,
                 TestEditionIds.Regular.ToString()
                 )
             )
        ).ShouldBeNull();
    }
Пример #2
0
    public async Task Cache_Should_Invalidator_WhenSettingChanged_Between_Tenant_And_Host()
    {
        var tenantId = Guid.NewGuid();

        using (_currentTenant.Change(tenantId))
        {
            // Arrange cache feature.
            (await _featureManagementStore.GetOrNullAsync(
                 TestFeatureDefinitionProvider.SocialLogins,
                 EditionFeatureValueProvider.ProviderName,
                 TestEditionIds.Regular.ToString()
                 )
            ).ShouldNotBeNull();
        }

        using (_currentTenant.Change(null))
        {
            await _featureManagementStore.SetAsync(TestFeatureDefinitionProvider.SocialLogins,
                                                   false.ToString(),
                                                   EditionFeatureValueProvider.ProviderName,
                                                   TestEditionIds.Regular.ToString());
        }

        using (_currentTenant.Change(tenantId))
        {
            // Arrange cache feature.
            (await _cache.GetAsync(
                 FeatureValueCacheItem.CalculateCacheKey(
                     TestFeatureDefinitionProvider.SocialLogins,
                     EditionFeatureValueProvider.ProviderName,
                     TestEditionIds.Regular.ToString()
                     )
                 )
            ).ShouldBeNull();
        }
    }
Пример #3
0
 protected virtual string CalculateCacheKey(string name, string providerName, string providerKey)
 {
     return(FeatureValueCacheItem.CalculateCacheKey(name, providerName, providerKey));
 }