public async Task DeleteAsync_should_notity_provider_deleted()
        {
            using var documentStore = new RavenDbTestDriverWrapper().GetDocumentStore();
            var services = new ServiceCollection()
                           .AddLogging();

            services.AddIdentity <IdentityUser, IdentityRole>()
            .AddRavenDbStores(p => documentStore);

            services.AddSingleton(p => documentStore)
            .AddAuthentication()
            .AddDynamic <SchemeDefinition>()
            .AddRavenDbStore()
            .AddGoogle();

            IServiceProvider provider = services.AddIdentityServer4AdminRavenDbkStores <IdentityUser, IdentityRole>(p => documentStore).BuildServiceProvider();

            using var scope = provider.CreateScope();
            provider        = scope.ServiceProvider;

            var manager            = provider.GetRequiredService <PersistentDynamicManager <SchemeDefinition> >();
            var serializer         = provider.GetRequiredService <IAuthenticationSchemeOptionsSerializer>();
            var mockProviderClient = new Mock <IProviderClient>();

            mockProviderClient.Setup(m => m.ProviderRemovedAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).Verifiable();

            var id = Guid.NewGuid().ToString();
            await manager.AddAsync(new SchemeDefinition
            {
                DisplayName = Guid.NewGuid().ToString(),
                Options     = new GoogleOptions(),
                HandlerType = typeof(GoogleHandler),
                Scheme      = id
            });

            var sut = new ExternalProviderStore(manager,
                                                serializer,
                                                new ScopedAsynDocumentcSession(documentStore.OpenAsyncSession()),
                                                mockProviderClient.Object);

            await sut.DeleteAsync(id);

            mockProviderClient.Verify();
        }
        public async Task DeleteAsync_should_delete_scheme()
        {
            using var documentStore = new RavenDbTestDriverWrapper().GetDocumentStore();
            var services = new ServiceCollection()
                           .AddLogging();

            services.AddIdentity <IdentityUser, IdentityRole>()
            .AddRavenDbStores(p => documentStore);

            services.AddSingleton(p => documentStore)
            .AddAuthentication()
            .AddDynamic <SchemeDefinition>()
            .AddRavenDbStore()
            .AddGoogle();

            IServiceProvider provider = services.AddIdentityServer4AdminRavenDbkStores <IdentityUser, IdentityRole>(p => documentStore).BuildServiceProvider();

            using var scope = provider.CreateScope();
            provider        = scope.ServiceProvider;

            var manager    = provider.GetRequiredService <PersistentDynamicManager <SchemeDefinition> >();
            var serializer = provider.GetRequiredService <IAuthenticationSchemeOptionsSerializer>();

            var id = Guid.NewGuid().ToString();
            await manager.AddAsync(new SchemeDefinition
            {
                DisplayName = Guid.NewGuid().ToString(),
                Options     = new GoogleOptions(),
                HandlerType = typeof(GoogleHandler),
                Scheme      = id
            });

            var sut = new ExternalProviderStore(manager,
                                                serializer,
                                                new ScopedAsynDocumentcSession(documentStore.OpenAsyncSession()),
                                                null);

            await sut.DeleteAsync(id);

            var scheme = await manager.FindBySchemeAsync(id);

            Assert.Null(scheme);
        }