// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; using System.Collections.Generic; using System.Text; using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests { public abstract class BaseImageOperationsExtensionTest { protected readonly IImageProcessingContext operations; private readonly FakeImageOperationsProvider.FakeImageOperations internalOperations; protected readonly Rectangle rect; protected readonly GraphicsOptions options; private Image source; public BaseImageOperationsExtensionTest() { this.options = new GraphicsOptions(false); this.source = new Image(91 + 324, 123 + 56); this.rect = new Rectangle(91, 123, 324, 56); // make this random? this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations(this.source, false); this.operations = this.internalOperations; } public T Verify(int index = 0) { Assert.InRange(index, 0, this.internalOperations.Applied.Count - 1); var operation = this.internalOperations.Applied[index]; return Assert.IsType(operation.Processor); } public T Verify(Rectangle rect, int index = 0) { Assert.InRange(index, 0, this.internalOperations.Applied.Count - 1); var operation = this.internalOperations.Applied[index]; Assert.Equal(rect, operation.Rectangle); return Assert.IsType(operation.Processor); } } }