Esempio n. 1
0
    public async Task RaiseChangeEventAfterProviderSetToNull()
    {
        var testFileProvider = new TestFileProvider(
            new TestFile("Secret1", "SecretValue1"),
            new TestFile("Secret2", "SecretValue2"));
        var configurationSource = new KeyPerFileConfigurationSource
        {
            FileProvider = testFileProvider,
            Optional     = true,
        };
        var keyPerFileProvider = new KeyPerFileConfigurationProvider(configurationSource);
        var config             = new ConfigurationRoot(new[] { keyPerFileProvider });

        var changeToken          = config.GetReloadToken();
        var changeTaskCompletion = new TaskCompletionSource <object>();

        changeToken.RegisterChangeCallback(state =>
                                           ((TaskCompletionSource <object>)state).TrySetResult(null), changeTaskCompletion);

        configurationSource.FileProvider = null;
        config.Reload();

        await changeTaskCompletion.Task;

        Assert.Empty(config.AsEnumerable());
    }
Esempio n. 2
0
 public IChangeToken GetReloadToken() => _configuration.GetReloadToken();
 IChangeToken IConfiguration.GetReloadToken() => _configuration.GetReloadToken();