コード例 #1
0
        public static UIImage AssertContainsColor(this UIImage bitmap, UIColor expectedColor)
        {
            for (int x = 0; x < bitmap.Size.Width; x++)
            {
                for (int y = 0; y < bitmap.Size.Height; y++)
                {
                    if (ColorComparison.ARGBEquivalent(bitmap.ColorAtPoint(x, y), expectedColor))
                    {
                        return(bitmap);
                    }
                }
            }

            Assert.Fail(CreateColorError(bitmap, $"Color {expectedColor} not found."));
            return(bitmap);
        }
コード例 #2
0
        public static UIImage AssertColorAtPoint(this UIImage bitmap, UIColor expectedColor, int x, int y)
        {
            try
            {
                var cap = bitmap.ColorAtPoint(x, y);

                if (!ColorComparison.ARGBEquivalent(cap, expectedColor))
                {
                    System.Diagnostics.Debug.WriteLine("Here");
                }

                Assert.That(cap, Is.EqualTo(expectedColor).Using <UIColor>(ColorComparison.ARGBEquivalent),
                            () => bitmap.CreateColorAtPointError(expectedColor, x, y));

                return(bitmap);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }

            return(null);
        }