public void RandomizeSaturation_AdjustsColor() { // prereq MathTest.MathTest math = new MathTest.MathTest(); math.IsBetween_ReturnsCorrectAnswer(); // arrange Color color = new Color(0.1f, 0.2f, 0.3f); float variation = 0.1f; // act float minR = color.r; float maxR = minR + (1 - color.r) * variation; color = Palette.RandomizeSaturation(color, variation); // assert Assert.AreNotEqual(0.1f, color.r); Assert.IsTrue(color.r.IsBetween(minR, maxR)); }
public void RandomizeAlpha_AdjustsAlpha() { // prereq MathTest.MathTest math = new MathTest.MathTest(); math.IsBetween_ReturnsCorrectAnswer(); // arrange Color color = new Color(0.1f, 0.2f, 0.3f, 0.5f); float variation = 0.25f; // act float min = 0.5f - variation; float max = 0.5f + variation; color = Palette.RandomizeAlpha(color, variation); // assert Assert.AreNotEqual(0.5f, color.a, "Does not always pass. Try running this test again."); Assert.IsTrue(color.a.IsBetween(min, max, true, true)); }
public void Darken_ReturnsDarkerColor() { // prereq IsValidColor_ExtensionReturnsAnswer(); IsBlack_ExtensionReturnsCorrectReponse(); Min_ExtensionReturnsSmallestRGBComponent(); MathTest.MathTest math = new MathTest.MathTest(); math.RemoveMin_ReturnsMinValueAndRemovesItFromList(); // arrange Color source = new Color(0.2f, 0.3f, 0.5f); float percent = 0.1f; float distance = source.Min(); float fullAdjust = distance * 1.0f; float partialAdjust = distance * percent; Color expectedFull = new Color( source.r - fullAdjust, source.g - fullAdjust, source.b - fullAdjust, source.a ); Color expectedPartial = new Color( source.r - partialAdjust, source.g - partialAdjust, source.b - partialAdjust, source.a ); // act Color full = Palette.Darken(source); Color partial = Palette.Darken(source, percent); // assert Assert.IsTrue(full.IsValidColor(), "'full' " + full.ToString() + " is not a valid color"); Assert.AreEqual(expectedFull, full, "expected color and 'full' do not match"); Assert.IsTrue(partial.IsValidColor(), "'partial' " + partial.ToString() + " is not a valid color"); Assert.AreEqual(expectedPartial, partial, "expected color and 'partial' do not match"); }