protected static void ExpectedValuesForRoundTrip <T>(Rgb knownColor) where T : IColorSpace, new() { var midColor = knownColor.To <T>(); var target = midColor.To <Rgb>(); Assert.AreEqual(knownColor.R, target.R, 1.2, knownColor.ToString() + " => " + midColor.ToString() + " => " + target.ToString() + " R: " + knownColor.R + " != " + target.R); Assert.AreEqual(knownColor.G, target.G, 1.2, knownColor.ToString() + " => " + midColor.ToString() + " => " + target.ToString() + " G: " + knownColor.G + " != " + target.G); Assert.AreEqual(knownColor.B, target.B, 1.2, knownColor.ToString() + " => " + midColor.ToString() + " => " + target.ToString() + " B: " + knownColor.B + " != " + target.B); }
public void TestToString() { Rgb a = new Rgb(1, 2, 3); string s = "(R 1 G 2 B 3)"; Assert.Equal(s, a.ToString()); }
public void UpdateColor(Rgb color) { if (color != null) { WriteToDevice(color.ToString()); } }
public static void ToString_WhenInvoked_ReturnsCorrectRepresentation() { var rgb = new Rgb(12, 34, 56); const string strRep = "Red = 12, Green = 34, Blue = 56"; Assert.AreEqual(strRep, rgb.ToString()); }
public void ConsolePalette() { var ConsolePalette = new Palette <Rgb>() { new Rgb(0x00, 0x00, 0x00), new Rgb(0x80, 0x00, 0x00), new Rgb(0x00, 0x80, 0x00), new Rgb(0x80, 0x80, 0x00), new Rgb(0x00, 0x00, 0x80), new Rgb(0x80, 0x00, 0x80), new Rgb(0x00, 0x80, 0x80), new Rgb(0xc0, 0xc0, 0xc0), new Rgb(0x80, 0x80, 0x80), new Rgb(0xff, 0x00, 0x00), new Rgb(0x00, 0xff, 0x00), new Rgb(0xff, 0xff, 0x00), new Rgb(0x00, 0x00, 0xff), new Rgb(0xff, 0x00, 0xff), new Rgb(0x00, 0xff, 0xff), new Rgb(0xff, 0xff, 0xff) }; Rgb testColor; Palette <Rgb> .FindResult <Rgb> testResult; // Going to run a test at each end of the spectrum testColor = new Rgb(0x70, 0x20, 0x20); testResult = ConsolePalette.FindClosestColor <Rgb>(testColor); Assert.AreEqual(1, testResult.Index, testColor.ToString() + " != " + testResult.ToString() + " => " + testResult.Distance); testColor = new Rgb(0x20, 0x90, 0x20); testResult = ConsolePalette.FindClosestColor <Rgb>(testColor); Assert.AreEqual(2, testResult.Index, testColor.ToString() + " != " + testResult.ToString() + " => " + testResult.Distance); testColor = new Rgb(0x90, 0x70, 0x20); testResult = ConsolePalette.FindClosestColor <Rgb>(testColor); Assert.AreEqual(3, testResult.Index, testColor.ToString() + " != " + testResult.ToString() + " => " + testResult.Distance); testColor = new Rgb(0x20, 0x20, 0x87); testResult = ConsolePalette.FindClosestColor <Rgb>(testColor); Assert.AreEqual(4, testResult.Index, testColor.ToString() + " != " + testResult.ToString() + " => " + testResult.Distance); testColor = new Rgb(0x90, 0x00, 0x87); testResult = ConsolePalette.FindClosestColor <Rgb>(testColor); Assert.AreEqual(5, testResult.Index, testColor.ToString() + " != " + testResult.ToString() + " => " + testResult.Distance); testColor = new Rgb(0x20, 0x90, 0x87); testResult = ConsolePalette.FindClosestColor <Rgb>(testColor); Assert.AreEqual(6, testResult.Index, testColor.ToString() + " != " + testResult.ToString() + " => " + testResult.Distance); }