public void DoWork() { // instantiate the Immutable color class var myColor1 = new Immutable.Color(red: 127, green: 63, blue: 255); Console.WriteLine(myColor1.ToString()); Console.WriteLine(myColor1.IsWhite); var myColor2 = new Immutable.Color(red: 191); Console.WriteLine(myColor2.ToString()); Console.WriteLine(myColor2.IsBlack()); Color color1 = new Color.Builder().Create(); // defaults Color color2 = new Color.Builder().Red(127).Create(); // red only Color color3 = new Color.Builder().Green(63).Alpha(255).Create(); // Green and Alpha var greenValue = color3.Green; Console.WriteLine(greenValue); //color2.Red = 0; Color lightenedColor = color3.Lighten(22); Console.WriteLine(lightenedColor.IsBlack()); Console.ReadLine(); }
public void ReturnDarkenedColorWhenClamped() { var color1 = new ConsoleApp.Immutable.Color(50, 40, 30); var darkenedColor = color1.Darken(70); Color expectedColor = new ConsoleApp.Immutable.Color(0, 0, 0); Assert.AreEqual(expectedColor.Red, darkenedColor.Red); Assert.AreEqual(expectedColor.Green, darkenedColor.Green); Assert.AreEqual(expectedColor.Blue, darkenedColor.Blue); }
public void ReturnDarkenedColor() { var color1 = new ConsoleApp.Immutable.Color(255, 255, 255); var darkenedColor = color1.Darken(15); Color expectedColor = new ConsoleApp.Immutable.Color(240, 240, 240); Assert.AreEqual(expectedColor.Red, darkenedColor.Red); Assert.AreEqual(expectedColor.Green, darkenedColor.Green); Assert.AreEqual(expectedColor.Blue, darkenedColor.Blue); }
public void ReturnLightenedColorWhenClamped() { var color1 = new ConsoleApp.Immutable.Color(200, 210, 220); var lightenedColor = color1.Lighten(60); Color expectedColor = new ConsoleApp.Immutable.Color(255, 255, 255); Assert.AreEqual(expectedColor.Red, lightenedColor.Red); Assert.AreEqual(expectedColor.Green, lightenedColor.Green); Assert.AreEqual(expectedColor.Blue, lightenedColor.Blue); }
public void ReturnLightenedColor() { var color1 = new ConsoleApp.Immutable.Color(0, 0, 0); var lightenedColor = color1.Lighten(10); Color expectedColor = new ConsoleApp.Immutable.Color(10, 10, 10); Assert.AreEqual(expectedColor.Red, lightenedColor.Red); Assert.AreEqual(expectedColor.Green, lightenedColor.Green); Assert.AreEqual(expectedColor.Blue, lightenedColor.Blue); }
public void ReturnFalseWhenRGBNotZero() { var color1 = new ConsoleApp.Immutable.Color(1, 0, 0); var color2 = new ConsoleApp.Immutable.Color(0, 1, 0); var color3 = new ConsoleApp.Immutable.Color(0, 0, 1); Assert.IsFalse(color1.IsBlack()); Assert.IsFalse(color2.IsBlack()); Assert.IsFalse(color3.IsBlack()); }
public void ReturnTrueWhenRGBAreZero() { // Arrange var color = new ConsoleApp.Immutable.Color(0, 0, 0); // Act var isBlack = color.IsBlack(); // Assert Assert.IsTrue(isBlack); }
public void ReturnCorrectToString() { // Arrange var color1 = new ConsoleApp.Immutable.Color(0, 0, 0); var color2 = new ConsoleApp.Immutable.Color(127, 0, 0); // Act string formattedString1 = $"Red: {0}, Green: {0}, Blue: {0}"; string formattedString2 = $"Red: {127}, Green: {0}, Blue: {0}"; // Assert Assert.AreEqual(formattedString1, color1.ToString()); Assert.AreEqual(formattedString2, color2.ToString()); }