public async Task ShouldResolveAllSupportedProviders() { var provider = new ProviderStorage(new Dictionary <string, Func <Guid, IProvider> > { [typeof(LocalProvider).Name] = id => new LocalProvider(id), [typeof(VkDocsProvider).Name] = id => new VkDocsProvider(id, _blobCache), [typeof(YandexDiskProvider).Name] = id => new YandexDiskProvider(id, _authenticator, _blobCache), }, _blobCache); await provider.Add(typeof(LocalProvider).Name); await provider.Add(typeof(VkDocsProvider).Name); await provider.Add(typeof(YandexDiskProvider).Name); var providers = provider.Providers().AsAggregator(); Assert.Equal(3, providers.Data.Count); Assert.Contains(providers.Data.Items, x => x is LocalProvider); Assert.Contains(providers.Data.Items, x => x is VkDocsProvider); Assert.Contains(providers.Data.Items, x => x is YandexDiskProvider); }
public async Task ShouldResolveOnlySpecifiedProvidersIfNeeded() { var provider = new ProviderStorage(new Dictionary <string, Func <Guid, IProvider> > { [typeof(LocalProvider).Name] = id => new LocalProvider(id), }, _blobCache); await provider.Add(typeof(LocalProvider).Name); var providers = provider.Providers().AsAggregator(); Assert.Equal(1, providers.Data.Count); Assert.Contains(providers.Data.Items, x => x is LocalProvider); Assert.DoesNotContain(providers.Data.Items, x => x is VkDocsProvider); Assert.DoesNotContain(providers.Data.Items, x => x is YandexDiskProvider); }
public async Task ShouldRemoveProviders() { var provider = new ProviderStorage(new Dictionary <string, Func <Guid, IProvider> > { [typeof(LocalProvider).Name] = id => new LocalProvider(id), }, _blobCache); await provider.Add(typeof(LocalProvider).Name); var providers = provider.Providers().AsAggregator(); Assert.Equal(1, providers.Data.Count); await provider.Remove(providers.Data.Items.First().Id); Assert.Equal(0, providers.Data.Count); }