public override void TestRestoreManipulationsCore() { var image = new CodedImage { Size = new Size(30, 20), Palette = new CodedPalette() }; image.CompletePalette(); for (int x = 0; x < 30; x++) { for (int y = 0; y < 20; y++) { image[x, y] = new CodedColor((byte)(x * 8), (byte)(y * 12), (byte)((x + y) * 5)); } } var dummyManipulator = new ImageManipulatorTest.DummyManipulator(image); var colorer = new ImageColorsManipulator(dummyManipulator); var childManipulator = new ImageManipulatorTest.DummyManipulator(colorer); colorer.QuantizeColors(3); Assert.AreEqual(3, colorer.ManipulatedImage.Palette.Count); colorer.ManipulatedImage.Palette.Add(new CodedColor(254, 254, 254)); childManipulator.RestoreManipulationsCoreFired = false; Assert.AreEqual(4, colorer.ManipulatedImage.Palette.Count, "Precondition"); Assert.IsFalse(childManipulator.RestoreManipulationsCoreFired); dummyManipulator.CallOnImageChanged(); Assert.AreEqual(3, colorer.ManipulatedImage.Palette.Count); Assert.IsFalse(childManipulator.RestoreManipulationsCoreFired); Assert.NotNull(childManipulator.ManipulatedImage); Assert.IsTrue(childManipulator.RestoreManipulationsCoreFired); }
void AssertResizeWithLastSettingsOnParentImageChanged(Size initialSize, Size changedSize, ImageSizeManipulator.SizeLockType sizeLockBy, Size newSize, Size expectedSize) { var dummyManipulator = new ImageManipulatorTest.DummyManipulator(new CodedImage { Size = initialSize }); var resizer = new ImageSizeManipulator(dummyManipulator); Assert.AreEqual(initialSize, resizer.ManipulatedImage.Size, "Precondition"); resizer.Resize(changedSize, ImageResampler.FilterType.Box, sizeLockBy); Assert.AreEqual(changedSize, resizer.ManipulatedImage.Size, "Precondition 2"); dummyManipulator.ManipulatedImage.Size = newSize; Assert.AreEqual(changedSize, resizer.ManipulatedImage.Size, "Not changed yet"); dummyManipulator.CallOnImageChanged(); Assert.AreEqual(expectedSize, resizer.ManipulatedImage.Size); }