public void imageShouldBeShownAllIfFitsAndNoShift() { ImageUtils target = new ImageUtils(); int left = 0; int top = 0; int right = 100; int bottom = 100; float otherImageScaleH = 1; float otherImageScaleW = 1; ImageState actual; ImageState expected = new ImageState(); expected.X = 0; expected.Y = 0; expected.Zoom = 1f; target.ImageSize = new Size(100,100); target.BoxSize = new Size(100, 100); actual = target.AdjustPositionAndScale(left, top, right, bottom, otherImageScaleH, otherImageScaleW); Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); Assert.AreEqual(expected.Zoom, actual.Zoom); Assert.AreEqual(expected.Angle, actual.Angle); }
public void imageShouldBeZommedWithSamePositioningWhenRotated90AndIsNotSquared() { ImageUtils target = new ImageUtils(); int left = 50; int top = 50; int right = 75; int bottom = 75; float otherImageScaleH = 1; float otherImageScaleW = 1; ImageState actual; ImageState expected = new ImageState(); expected.X = -left; expected.Y = -top; expected.Zoom = 4f; expected.Angle = 90; target.ImageSize = new Size(200, 100); target.BoxSize = new Size(100, 100); actual = target.AdjustPositionAndScale(left, top, right, bottom, otherImageScaleH, otherImageScaleW, 90); Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); Assert.AreEqual(expected.Zoom, actual.Zoom); Assert.AreEqual(expected.Angle, actual.Angle); }
public void imageShouldBeShiftedToTwiceBottomWhenScaledRightIsDoubled() { ImageUtils target = new ImageUtils(); int left = 0; int top = 100; int right = 200; int bottom = 300; float otherImageScaleH = 2f; float otherImageScaleW = 2f; ImageState actual; ImageState expected = new ImageState(); expected.X = 0; expected.Y = -50; expected.Zoom = 1f; expected.Angle = 0; target.ImageSize = new Size(100, 200); target.BoxSize = new Size(100, 100); actual = target.AdjustPositionAndScale(left, top, right, bottom, otherImageScaleH, otherImageScaleW); Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); Assert.AreEqual(expected.Zoom, actual.Zoom); Assert.AreEqual(expected.Angle, actual.Angle); }
public void imageShouldBeShiftedToBottomAsRequestedAndCantFitAllWhenRotated90() { ImageUtils target = new ImageUtils(); int left = 0; int top = 100; int right = 100; int bottom = 200; float otherImageScaleH = 1; float otherImageScaleW = 1; ImageState actual; ImageState expected = new ImageState(); expected.X = 0; expected.Y = -top; expected.Zoom = 1f; expected.Angle = 90; target.ImageSize = new Size(100, 1000); target.BoxSize = new Size(100, 100); actual = target.AdjustPositionAndScale(left, top, right, bottom, otherImageScaleH, otherImageScaleW, 90); Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); Assert.AreEqual(expected.Zoom, actual.Zoom); Assert.AreEqual(expected.Angle, actual.Angle); }
public void imageShouldBeShiftedRightSameWayWhenIsRotated180() { ImageUtils target = new ImageUtils(); int left = 100; int top = 0; int right = 200; int bottom = 100; float otherImageScaleH = 1; float otherImageScaleW = 1; ImageState actual; ImageState expected = new ImageState(); expected.X = -left; expected.Y = 0; expected.Zoom = 1f; expected.Angle = 180; target.ImageSize = new Size(1000, 100); target.BoxSize = new Size(100, 100); actual = target.AdjustPositionAndScale(left, top, right, bottom, otherImageScaleH, otherImageScaleW, 180); Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); Assert.AreEqual(expected.Zoom, actual.Zoom); Assert.AreEqual(expected.Angle, actual.Angle); }
public void imageShouldBeZommedIfDesiredPartCanBeShownBigger() { ImageUtils target = new ImageUtils(); int left = 50; int top = 50; int right = 75; int bottom = 75; float otherImageScaleH = 1; float otherImageScaleW = 1; ImageState actual; ImageState expected = new ImageState(); expected.X = -left; expected.Y = -top; expected.Zoom = 4f; target.ImageSize = new Size(100, 100); target.BoxSize = new Size(100, 100); actual = target.AdjustPositionAndScale(left, top, right, bottom, otherImageScaleH, otherImageScaleW); Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); Assert.AreEqual(expected.Zoom, actual.Zoom); Assert.AreEqual(expected.Angle, actual.Angle); }