コード例 #1
0
        public void ReturnsTheColorPresentInUnicolorImage()
        {
            Img = new Bitmap(1, 1);
            Img.SetPixel(0, 0, Color.Red);

            var actual = ColorFinder.FindColors(Img);

            Assert.That(actual.Contains(Color.FromArgb(255, 0, 0)));
        }
コード例 #2
0
        public void FindsTheColorInTheLastPixel()
        {
            Img = new Bitmap(Images.LastPixel);
            List <Color> expected = new List <Color> {
                Color.FromArgb(0, 0, 0), Color.FromArgb(255, 255, 255)
            };

            var actual = ColorFinder.FindColors(Img);


            Assert.AreEqual(expected.Count, actual.Count);

            foreach (var color in expected)
            {
                Assert.That(actual.Contains(color), "Color not found : " + color);
            }
        }
コード例 #3
0
        public void ReturnsTheListOfColorsPresentInAnImage()
        {
            Img = new Bitmap(5, 5);
            Img.SetPixel(2, 1, Color.FromArgb(255, 0, 0));
            Img.SetPixel(1, 2, Color.FromArgb(0, 255, 0));
            Img.SetPixel(4, 4, Color.FromArgb(0, 0, 255));

            List <Color> expected = new List <Color>
            {
                Color.FromArgb(255, 0, 0),
                Color.FromArgb(0, 255, 0),
                Color.FromArgb(0, 0, 255),
                Color.FromArgb(0, 0, 0), // default color
            };

            var actual = ColorFinder.FindColors(Img);

            Assert.AreEqual(expected.Count, actual.Count);

            foreach (var color in expected)
            {
                Assert.That(actual.Contains(color), "Color not found : " + color);
            }
        }