Example #1
0
        public void NullPalette_ReturnsNull()
        {
            var testClass = new KMeansColourMatcher();

            var rgbPixels = GetTestPixels(Color.Red, 1000);

            var testResult = testClass.GetClosestMatch(rgbPixels, null);

            Assert.IsNull(testResult);
        }
Example #2
0
        public void NullPixels_ReturnsNull()
        {
            var testClass = new KMeansColourMatcher();

            var palette = GetTestPaletteOptions(Color.Black, Color.Blue, Color.Green);

            var testResult = testClass.GetClosestMatch(null, palette);

            Assert.IsNull(testResult);
        }
Example #3
0
        public void SolidColour_NoMatch()
        {
            var testClass = new KMeansColourMatcher();

            var rgbPixels = GetTestPixels(Color.Red, 1000);
            var palette   = GetTestPaletteOptions(Color.Black, Color.Blue, Color.Green);

            var testResult = testClass.GetClosestMatch(rgbPixels, palette);

            Assert.IsNull(testResult);
        }
Example #4
0
        public void EmptyPalette_ReturnsNull()
        {
            var testClass = new KMeansColourMatcher();

            var rgbPixels = GetTestPixels(Color.Red, 1000);
            var palette   = GetTestPaletteOptions(new Color[0]);

            var testResult = testClass.GetClosestMatch(rgbPixels, palette);

            Assert.IsNull(testResult);
        }
Example #5
0
        public void SolidColour_ExactMatch()
        {
            var testClass = new KMeansColourMatcher();

            var rgbPixels = GetTestPixels(Color.Red, 1000);
            var palette   = GetTestPaletteOptions(Color.Red, Color.Blue, Color.Green);

            var testResult = testClass.GetClosestMatch(rgbPixels, palette);

            Assert.IsNotNull(testResult);
            Assert.AreEqual(Color.Red.Name, testResult.Colour.Key);
            Assert.AreEqual(0, testResult.Distance);
        }