public void ApplyTreshold(int level) { var oldR = LargeBitmap.GetPixel(0, 0).R; var oldG = LargeBitmap.GetPixel(0, 0).G; var oldB = LargeBitmap.GetPixel(0, 0).B; int intensity = (oldR + oldG + oldB) / 3; int newR; int newG; int newB; if (intensity >= 255 * level / 100) { newR = 255; newG = 255; newB = 255; } else { newR = 0; newG = 0; newB = 0; } ImageHandler.ApplyThreshold(LargeBitmap, level); Assert.AreEqual(newR, LargeBitmap.GetPixel(0, 0).R); Assert.AreEqual(newG, LargeBitmap.GetPixel(0, 0).G); Assert.AreEqual(newB, LargeBitmap.GetPixel(0, 0).B); }
public void ThrowArgumentOutOfRangeExc_WhenApplyThresholdWithWrongLevel(int level) { Assert.Throws <ArgumentOutOfRangeException>(() => ImageHandler.ApplyThreshold(LargeBitmap, level)); }