예제 #1
0
            public void ShouldThrowExceptionWhenColorDoesNotStartWithHash()
            {
                var factory = new MagickColorFactory();

                ExceptionAssert.Throws <ArgumentException>("color", () =>
                {
                    factory.Create("FFFFFF");
                });
            }
예제 #2
0
            public void ShouldThrowExceptionWhenColorHasInvalidLength()
            {
                var factory = new MagickColorFactory();

                ExceptionAssert.Throws <ArgumentException>("color", () =>
                {
                    factory.Create("#FFFFF");
                });
            }
예제 #3
0
            public void ShouldThrowExceptionWhenColorIsEmpty()
            {
                var factory = new MagickColorFactory();

                ExceptionAssert.Throws <ArgumentException>("color", () =>
                {
                    factory.Create(string.Empty);
                });
            }
예제 #4
0
            public void ShouldThrowExceptionWhenColorIsNull()
            {
                var factory = new MagickColorFactory();

                ExceptionAssert.Throws <ArgumentNullException>("color", () =>
                {
                    factory.Create((string)null);
                });
            }
예제 #5
0
            public void ShouldThrowExceptionWhenColorHasInvalidHexValue()
            {
                var factory = new MagickColorFactory();

                Assert.Throws <ArgumentException>("color", () =>
                {
                    factory.Create("#FGF");
                });

                Assert.Throws <ArgumentException>("color", () =>
                {
                    factory.Create("#GGFFFF");
                });

                Assert.Throws <ArgumentException>("color", () =>
                {
                    factory.Create("#FFFG000000000000");
                });
            }
예제 #6
0
            private void TestColor(string hexValue, double red, double green, double blue, bool isTransparent, double delta)
            {
                var factory = new MagickColorFactory();
                var color   = factory.Create(hexValue);

                Assert.AreEqual(red, color.R, delta);
                Assert.AreEqual(green, color.G, delta);
                Assert.AreEqual(blue, color.B, delta);

                if (isTransparent)
                {
                    ColorAssert.IsTransparent(color.A);
                }
                else
                {
                    ColorAssert.IsNotTransparent(color.A);
                }
            }
예제 #7
0
            private void TestColor(string hexValue, double red, double green, double blue, bool isTransparent, double delta)
            {
                var factory = new MagickColorFactory();
                var color   = factory.Create(hexValue);

                Assert.InRange(color.R, red - delta, red + delta);
                Assert.InRange(color.G, green - delta, green + delta);
                Assert.InRange(color.B, blue - delta, blue + delta);

                if (isTransparent)
                {
                    ColorAssert.Transparent(color.A);
                }
                else
                {
                    ColorAssert.NotTransparent(color.A);
                }
            }