public void CanAddRemoveAllFactoryImageProviders()
        {
            var services = new ServiceCollection();
            IImageSharpBuilder builder = services.AddImageSharp();

            builder.AddProvider(_ => new MockImageProvider());
            Assert.Single(services, IsService <IImageProvider, MockImageProvider>);
            Assert.Single(services, IsServiceImplementationFactory <IImageProvider, MockImageProvider>);

            builder.ClearProviders();
            Assert.DoesNotContain(services, IsService <IImageProvider>);
        }
        /// <summary>
        /// Inserts the given <see cref="IImageProvider"/>  at the give index into the provider collection within the service collection.
        /// </summary>
        /// <typeparam name="TProvider">The type of class implementing <see cref="IImageProvider"/>to add.</typeparam>
        /// <param name="builder">The core builder.</param>
        /// <param name="index">The zero-based index at which the provider should be inserted.</param>
        /// <param name="implementationFactory">The factory method for returning a <see cref="IImageProvider"/>.</param>
        /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
        public static IImageSharpBuilder InsertProvider <TProvider>(this IImageSharpBuilder builder, int index, Func <IServiceProvider, TProvider> implementationFactory)
            where TProvider : class, IImageProvider
        {
            var descriptors = builder.Services.Where(x => x.ServiceType == typeof(IImageProvider)).ToList();

            builder.ClearProviders();

            descriptors.Insert(index, ServiceDescriptor.Singleton <IImageProvider>(implementationFactory));

            builder.Services.TryAddEnumerable(descriptors);
            return(builder);
        }
        public void CanAddRemoveAllImageProviders()
        {
            var services = new ServiceCollection();

            IImageSharpBuilder builder = services.AddImageSharp()
                                         .AddProvider <MockImageProvider>();

            Assert.Contains(services, x => x.ImplementationType == typeof(MockImageProvider));

            builder.ClearProviders();

            Assert.DoesNotContain(services, x => x.ImplementationType == typeof(MockImageProvider));
        }
        public void CanAddRemoveAllFactoryImageProviders()
        {
            var services = new ServiceCollection();

            IImageSharpBuilder builder = services.AddImageSharp()
                                         .AddProvider(_ => new MockImageProvider());

            Assert.DoesNotContain(services, x => x.ImplementationType == typeof(MockImageProvider));

            Assert.Contains(services, x => x.ImplementationFactory?.Method.ReturnType == typeof(MockImageProvider));

            builder.ClearProviders();

            Assert.DoesNotContain(services, x => x.ImplementationFactory?.Method.ReturnType == typeof(MockImageProvider));
        }