public void TestDoesntCallManipulationsWithoutChanges() { var image = new CodedImage { Size = new Size(5, 5) }; var cropper = new ImageCropController4Test(new ImageCropManipulator(image)); Assert.AreEqual(ImageCropper.CropKind.None, cropper.CropKind, "Prerequisits"); Assert.AreEqual(new Rectangle(0, 0, 5, 5), cropper.CropRect, "Prerequisits"); Assert.IsFalse(cropper.CallManipulationsCoreFired, "Prerequisits"); cropper.CropKind = ImageCropper.CropKind.Rectangle; Assert.IsTrue(cropper.CallManipulationsCoreFired, "Should call manipulations for initial crop kind change."); cropper.CallManipulationsCoreFired = false; cropper.CropKind = ImageCropper.CropKind.Rectangle; Assert.IsFalse(cropper.CallManipulationsCoreFired, "Should not call manipulations because there are no changes."); cropper.CropKind = ImageCropper.CropKind.Arc; Assert.IsTrue(cropper.CallManipulationsCoreFired, "Should call manipulations after changed parameters."); cropper.CallManipulationsCoreFired = false; cropper.CropRect = new Rectangle(0, 0, 5, 5); Assert.IsFalse(cropper.CallManipulationsCoreFired, "Should not call manipulations because there are no changes."); cropper.CropRect = new Rectangle(1, 1, 3, 2); Assert.IsTrue(cropper.CallManipulationsCoreFired, "Should call manipulations after changed parameters."); }
public void TestCropRectCorrectLimits() { var image = new CodedImage { Size = new Size(5, 5) }; var cropper = new ImageCropController4Test(new ImageCropManipulator(image)); cropper.CropRect = new Rectangle(-2, -3, 3, 2); Assert.AreEqual(new Rectangle(0, 0, 3, 2), cropper.CropRect, "Should move to 0 from outside of left/top borders."); cropper.CropRect = new Rectangle(2, 3, 5, 5); Assert.AreEqual(new Rectangle(2, 3, 3, 2), cropper.CropRect, "Should trim width/height to source image borders."); }