public void CanAddRemoveImageProcessors() { void RemoveServices(IServiceCollection services) { var builder = services.AddImageSharp() .AddProcessor <MockWebProcessor>(); Assert.Contains(services, x => x.ImplementationType == typeof(MockWebProcessor)); builder.RemoveProcessor <MockWebProcessor>(); Assert.DoesNotContain(services, x => x.ImplementationType == typeof(MockWebProcessor)); } using (TestServer server = ImageSharpTestServer.Create(ImageSharpTestServer.DefaultConfig, RemoveServices)) { } }
public void CanAddRemoveFactoryImageProviders() { void RemoveServices(IServiceCollection services) { 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.RemoveProvider <MockImageProvider>(); Assert.DoesNotContain(services, x => x.ImplementationFactory?.Method.ReturnType == typeof(MockImageProvider)); } using (TestServer server = ImageSharpTestServer.Create(ImageSharpTestServer.DefaultConfig, RemoveServices)) { } }