public void PaintOverlays_PaintsAllOverlaysAndRestoresGraphicsContextForEachOne() { var overlayManager = new OverlayManager(); var overlay1 = new OverlayThatChangesInterpolationMode(); var overlay2 = new OverlayThatChangesInterpolationMode(); overlayManager.AddOverlay(overlay1); overlayManager.AddOverlay(overlay2); using (Bitmap bitmap = new Bitmap(32, 32)) { using (Graphics graphics = Graphics.FromImage(bitmap)) { graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; var request = new OverlayPaintRequest(graphics, new Rectangle(0, 0, 32, 32), 0, 0); overlayManager.PaintOverlays(request); Assert.Multiple(() => { Assert.AreEqual(InterpolationMode.HighQualityBilinear, graphics.InterpolationMode); Assert.IsTrue(overlay1.WasPainted); Assert.AreEqual(InterpolationMode.HighQualityBilinear, overlay1.OldInterpolationMode); Assert.IsTrue(overlay2.WasPainted); Assert.AreEqual(InterpolationMode.HighQualityBilinear, overlay2.OldInterpolationMode); }); } } }
public void ToOverlay_ReturnsACompositeOverlay() { var overlayManager = new OverlayManager(); var overlay = new OverlayThatChangesInterpolationMode(); overlayManager.AddOverlay(overlay); Overlay compositeOverlay = overlayManager.ToOverlay(); var compositeOverlayManager = new OverlayManager(); compositeOverlayManager.AddOverlay(compositeOverlay); using (Bitmap bitmap = new Bitmap(32, 32)) compositeOverlayManager.PaintOverlaysOnImage(bitmap, 0, 0); Assert.IsTrue(overlay.WasPainted); }