Esempio n. 1
0
        public static Task AssertEqual(this UIImage bitmap, UIImage other)
        {
            Assert.NotNull(bitmap);
            Assert.NotNull(other);

            Assert.Equal(bitmap.Size, other.Size);

            Assert.True(IsMatching(), CreateEqualError(bitmap, other, $"Images did not match."));

            return(Task.CompletedTask);

            bool IsMatching()
            {
                for (int x = 0; x < bitmap.Size.Width; x++)
                {
                    for (int y = 0; y < bitmap.Size.Height; y++)
                    {
                        var first  = bitmap.ColorAtPoint(x, y);
                        var second = other.ColorAtPoint(x, y);

                        if (!ColorComparison.ARGBEquivalent(first, second))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
        }
Esempio n. 2
0
        public static UIImage AssertColorAtPoint(this UIImage bitmap, UIColor expectedColor, int x, int y)
        {
            var cap = bitmap.ColorAtPoint(x, y);

            if (!ColorComparison.ARGBEquivalent(cap, expectedColor))
            {
                Assert.Equal(cap, expectedColor, new ColorComparison());
            }

            return(bitmap);
        }
Esempio n. 3
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.True(false, CreateColorError(bitmap, $"Color {expectedColor} not found."));
            return(bitmap);
        }
Esempio n. 4
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.Equal(cap, expectedColor, new ColorComparison());

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

            return(null);
        }